JuniorMelo Posted September 29, 2013 Share Posted September 29, 2013 Hello I have a problem with this script, When the player dies no account can help me ? function onVehicleExplode (hitElement) if ( isElement ( hitElement ) and getElementType ( hitElement ) == "player" ) then local car = getPedOccupiedVehicle(hitElement) if car then local accountSource = getPlayerAccount ( hitElement ) setAccountData( accountSource,"totalkillsdeaths.Deaths",tonumber( getAccountData(accountSource,"totalkillsdeaths.Deaths") or 0 ) +1 ) setElementData( hitElement, "T/D", tonumber( getAccountData( accountSource,"totalkillsdeaths.Deaths" ) )) end end end addEventHandler ( "onVehicleExplode", Cars[player], onVehicleExplode ) addEventHandler( "onResourceStart",resourceRoot, function( ) outputDebugString( "add Total Deaths to scoreboard Return: "..tostring( call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "T/D",root,3, 0.052 ) ) ) end ) Link to comment
Castillo Posted September 29, 2013 Share Posted September 29, 2013 onVehicleExplode has no arguments, if you are trying to make so when a player pushes another/destroys on race, then you'll have to do something more complex, as this won't work. Link to comment
BieHDC Posted September 30, 2013 Share Posted September 30, 2013 You have to use onClientVehicleCollision(https://wiki.multitheftauto.com/wiki/On ... eCollision) and then trigger this to a Server event Link to comment
JuniorMelo Posted September 30, 2013 Author Share Posted September 30, 2013 You have to use onClientVehicleCollision(https://wiki.multitheftauto.com/wiki/On ... eCollision)and then trigger this to a Server event sure ??? Client addEventHandler("onClientVehicleCollision", getRootElement(), function () localPlayer = getLocalPlayer() triggerServerEvent("Collision", getRootElement(), localPlayer) end ) Server addEvent("Collision", true) addEventHandler("Collision", getRootElement(), function (hitElement) if ( isElement ( hitElement ) and getElementType ( hitElement ) == "player" ) then local car = getPedOccupiedVehicle(hitElement) if car then local accountSource = getPlayerAccount ( hitElement ) setAccountData( accountSource,"totalkillsdeaths.Deaths",tonumber( getAccountData(accountSource,"totalkillsdeaths.Deaths") or 0 ) +1 ) setElementData( hitElement, "T/D", tonumber( getAccountData( accountSource,"totalkillsdeaths.Deaths" ) )) end end end ) addEventHandler( "onResourceStart",resourceRoot, function( ) outputDebugString( "add Total Deaths to scoreboard Return: "..tostring( call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "T/D",root,3, 0.052 ) ) ) end ) Link to comment
.:HyPeX:. Posted September 30, 2013 Share Posted September 30, 2013 That didnt worked? try this instead.. local accountSource = getPlayerAccount ( car ) Link to comment
xXMADEXx Posted October 1, 2013 Share Posted October 1, 2013 That didnt worked?try this instead.. local accountSource = getPlayerAccount ( car ) Um, did you just try to get the account of a vehicle? lol Link to comment
BieHDC Posted October 1, 2013 Share Posted October 1, 2013 yep he did try: local accountSource = getPlayerAccount(getVehicleOccupant(car)) Link to comment
JuniorMelo Posted October 1, 2013 Author Share Posted October 1, 2013 tested operates normally, Thank you all for your help! Client addEventHandler("onClientPlayerWasted", getRootElement(), function () localPlayer = getLocalPlayer() triggerServerEvent("Collision", getRootElement(), localPlayer) end ) server addEvent("Collision", true) addEventHandler("Collision", getRootElement(), function (hitElement) if ( isElement ( hitElement ) and getElementType ( hitElement ) == "player" ) then local car = getPedOccupiedVehicle(hitElement) if car then local accountSource = getPlayerAccount ( hitElement ) setAccountData( accountSource,"totalkillsdeaths.Deaths",tonumber( getAccountData(accountSource,"totalkillsdeaths.Deaths") or 0 ) +1 ) setElementData( hitElement, "T/D", tonumber( getAccountData( accountSource,"totalkillsdeaths.Deaths" ) )) end end end ) addEventHandler( "onResourceStart",resourceRoot, function( ) outputDebugString( "add Total Deaths to scoreboard Return: "..tostring( call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "T/D",root,3, 0.052 ) ) ) end ) Link to comment
.:HyPeX:. Posted October 3, 2013 Share Posted October 3, 2013 That didnt worked?try this instead.. local accountSource = getPlayerAccount ( car ) Um, did you just try to get the account of a vehicle? lol local car = getPedOccupiedVehicle(hitElement) i was using his local before 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