ItachiUchiha Posted June 16, 2016 Share Posted June 16, 2016 Hello, I have this script that creates an object when a player dies: addEventHandler("onPlayerWasted", getRootElement(), function () local creator = getPlayerName(source) local fX, fY, fZ = getElementPosition (source) createObject ( 1212, fX, fY, fZ+0.5) triggerClientEvent ( 'play', source ) end ) I have the problem that when the player is dead for afk (and the ped inside the car is killed) the object is created, and I want to create that object only when the player's vehicle is exploded. I tried to use isVehicleBlown but using it the object is not created, and that don't give me any errors on the debug. addEventHandler("onPlayerWasted", getRootElement(), function () local theVehicle = getPedOccupiedVehicle(source) if (theVehicle) then if isVehicleBlown(theVehicle) then local creator = getPlayerName(source) local fX, fY, fZ = getElementPosition (source) createObject ( 1212, fX, fY, fZ+0.5) triggerClientEvent ( 'play', source ) else --nothing end end end ) Link to comment
Dimos7 Posted June 16, 2016 Share Posted June 16, 2016 addEventHandler("onPlayerWasted", root, function() local theVehicle = getPedOccupiedVehicle(source) if isVehicleBlown(theVehicle) then local creator = getPlayerName(source) local x, y, ,z = getElementPosition(source) createObject(1212, x, y, z+0.5) triggerClientEvent(srouce, "play", source) end end) Link to comment
ItachiUchiha Posted June 16, 2016 Author Share Posted June 16, 2016 addEventHandler("onPlayerWasted", root, function() local theVehicle = getPedOccupiedVehicle(source) if isVehicleBlown(theVehicle) then local creator = getPlayerName(source) local x, y, ,z = getElementPosition(source) createObject(1212, x, y, z+0.5) triggerClientEvent(srouce, "play", source) end end) Didn't work, the object is not created and I get this error: Bad argument @ 'isVehicleBlown' [Expected vehicle at argument 1, got boolean] Link to comment
KariiiM Posted June 16, 2016 Share Posted June 16, 2016 Try this: addEventHandler ( "onPlayerWasted", root, function ( ) local theVeh = getPedOccupiedVehicle ( source ) if ( theVeh ) then if ( isVehicleBlown ( theVeh ) ) then local creator = getPlayerName ( source ) local x, y, z = getElementPosition ( source ) createObject ( 1212, x, y, z + 0.5 ) triggerClientEvent ( "play", source ) end end end ) Link to comment
ItachiUchiha Posted June 16, 2016 Author Share Posted June 16, 2016 Try this: addEventHandler ( "onPlayerWasted", root, function ( ) local theVeh = getPedOccupiedVehicle ( source ) if ( theVeh ) then if ( isVehicleBlown ( theVeh ) ) then local creator = getPlayerName ( source ) local x, y, z = getElementPosition ( source ) createObject ( 1212, x, y, z + 0.5 ) triggerClientEvent ( "play", source ) end end end ) Didn't work either. And now I don't get any errors on the debug. Link to comment
KariiiM Posted June 16, 2016 Share Posted June 16, 2016 Be sure your file is declared as server side in your meta.xml Link to comment
ItachiUchiha Posted June 16, 2016 Author Share Posted June 16, 2016 Be sure your file is declared as server side in your meta.xml It is: <script src="files/data/deathrepair/deathpickup.lua" type="server" /> Link to comment
ItachiUchiha Posted June 18, 2016 Author Share Posted June 18, 2016 any help? what else can I try? Link to comment
Castillo Posted June 18, 2016 Share Posted June 18, 2016 Why don't you use onVehicleExplode instead? Link to comment
KariiiM Posted June 18, 2016 Share Posted June 18, 2016 Yeah it's a good idea, and use getVehicleController to return the vehicle controller, since the source of this event is the vehicle. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now