Jump to content

Destroyelement


Xwad

Recommended Posts

Hi i made a script but its not working:/ The script is that if i enter the rustler(476) then the script will destroy the element(the rustler) in 5 sec and create a vehicle and warp me in that vehicle.

debugscript: ERROR: shop/server.lua:54: attempt to call global 'destroyVehiclesOfModel' (a nil value)

server.lua

  
function timerKill (modelID) 
local USAteam = getTeamFromName("USA") 
if(getPlayerTeam ( localPlayer ) == USAteam) then 
local vehicles = getElementsByType("vehicle") 
for i,v in ipairs(vehicles) do 
if (getElementModel(v) == modelID) then 
destroyElement(v) 
local x,y,z = getElementPosition(source) 
local vehicle = createVehicle(601,-2117.46, -2340.69, 100 + 3) 
warpPedIntoVehicle(source,vehicle) 
end 
end 
end 
end 
destroyVehiclesOfModel(476) 
setTimer ( timerKill, 5000, 1 ) 
  

Link to comment

i fixed the Destroyelemnt problem but now i have anbother problem.. After the vehicle is destroyed it must create and warp me i a vehicle but its not working:/

  
function vehicleExplode () 
    if (getElementModel(source) == 476) then 
    setTimer( destroyElement, 4000, 1, source) 
    local x,y,z = getElementPosition(source) 
    local vehicle = createVehicle(513,-2117.46, -2340.69, 100 + 3) 
    warpPedIntoVehicle(source,vehicle) 
end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), vehicleExplode ) 
  

Link to comment

Can you stop bumping the topic after 30 minutes? And a triple post? EDIT YOUR LAST POST.

Why did you use onVehicleEnter? Delete it.

Read wiki:

warpPedIntoVehicle 

Attention: If you used setElementPosition to spawn the ped/player, this function will not work and returns false.
Link to comment

How you expect this to work you use the function warpPlayerIntoVehicle for warpping vehicle (source) to vehicle (that you create)

TRY THIS :

  
  
function vehicleExplode (plr) 
    if (getElementModel(source) == 476) then 
    setTimer( destroyElement, 4000, 1, source) 
    local vehicle = createVehicle(513,-2117.46, -2340.69, 100 + 3) 
    warpPedIntoVehicle(plr,vehicle) 
end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), vehicleExplode ) 
  
  

Link to comment
  
function vehicleExplode (plr) 
    if (getElementModel(source) == 476) then 
    setTimer( replaceVehicle, 4000, 1, source, plr) 
end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), vehicleExplode ) 
  
function replaceVehicle(veh, plr) 
    destroyElement(veh) 
    local vehicle = createVehicle(513,-2117.46, -2340.69, 100 + 3) 
    warpPedIntoVehicle(plr,vehicle) 
end 
  

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...