Jump to content

Car respawn.


Ernis456

Recommended Posts

I have problem with car respawning script. When I run this script and destroy car :

function respawnVehicle( vehicle )
spawnVehicle ( vehicle, getElementData( vehicle, "posX" ), getElementData( vehicle, "posY" ), getElementData( vehicle, "posZ" ), getElementData( vehicle, "rotX" ), getElementData( vehicle, "rotY" ), getElementData( vehicle, "rotZ" ) )
end
 
function onVehicleSpawn ()
local x,y,z = getElementPosition (source)
setElementData (source,"posX",x)
setElementData (source,"posY",y)
setElementData (source,"posZ",z)
end
addEventHandler ("onVehicleExplode",getRootElement(),onVehicleSpawn)
 
function onVehicleExplode ()
setTimer( respawnVehicle, 5000, 1, source )
end
addEventHandler("onVehicleExplode", getRootElement(), onVehicleExplode)

I getting error in console :

[15:24:20] WARNING: spawn.lua: Bad 'element' pointer @ 'getElementData'(1) - Line: 2
[15:24:20] WARNING: spawn.lua: Bad 'element' pointer @ 'spawnVehicle'(1) - Line: 2

How Can I fix it ?

Another question:

I Have created Team Cops. Why

setPlayerTeam ( playerWhoUses, "Cops" )

doesn't work for me ?

Edited by Guest
Link to comment

for your first problem, the bad element pointer can actually only mean that the element was destroyed (maybe by another script). try to stop all resources which could have something to do with vehicles (play,broph,freeroam). if everything else fails you could simply try to use createVehicle instead of spawnVehicle, actually i have never seen that function being used before.

the second parameter of setPlayerTeam is a team element use getTeamFromName("Cops") or save the team element in a variable when you create it.

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