Jump to content

Vehicle destroy


mouadys

Recommended Posts

Hello , i made a script to spawn vehicle and set player as driver , and it only works if you are admin .

But i want to destroy that vehicle with a command and i dont know how .

function createVehicleForPlayer(thePlayer, command, ...) 
    local x,y,z = getElementPosition(thePlayer) -- get the position of the player 
  x = x + 3 
  local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
  local vehicleName = table.concat({...}, " ") 
  local vehID = getVehicleModelFromName ( vehicleName ) 
  if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
  local createdVehicle = createVehicle( vehID,x,y,z ) 
  warpPedIntoVehicle ( thePlayer, createdVehicle ) 
  setVehicleDamageProof(createdVehicle, true) 
     if (createdVehicle == false) then 
        -- if so, output a message to the chatbox, but only to this player. 
         outputChatBox("Failed to create vehicle.",thePlayer) 
     else outputChatBox("Vehicle has been created",thePlayer) 
 end 
 end 
end 
addCommandHandler("cv", createVehicleForPlayer) 
function destroy(thePlayer, command ) 
  destroyElement ( createdVehicle ) 
end 
addCommandHandler ("dv", destroy) 

Link to comment
  • Moderators
vehicle = {} 
function createVehicleForPlayer(thePlayer, command, ...) 
    local x,y,z = getElementPosition(thePlayer) -- get the position of the player 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    local vehicleName = table.concat({...}, " ") 
    local vehID = getVehicleModelFromName ( vehicleName ) 
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
        vehicle[thePlayer] = createVehicle( vehID,x,y,z ) 
        warpPedIntoVehicle ( thePlayer, vehicle[thePlayer] ) 
        setVehicleDamageProof(vehicle[thePlayer], true) 
        if (vehicle[thePlayer] == false) then 
            -- if so, output a message to the chatbox, but only to this player. 
            outputChatBox("Failed to create vehicle.",thePlayer) 
        else 
            outputChatBox("Vehicle has been created",thePlayer) 
        end 
    end 
end 
addCommandHandler("cv", createVehicleForPlayer) 
  
function destroy(thePlayer, command ) 
  if isElement(vehicle[thePlayer]) then destroyElement ( vehicle[thePlayer] ) end 
end 
addCommandHandler ("dv", destroy) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...