Jump to content

Script Deaths


JuniorMelo

Recommended Posts

Posted

Hello

I have a problem with this script, When the player dies no account

can help me ? :oops:

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 
) 

Posted

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.

Posted
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 
) 

Posted

tested

operates normally, Thank you all for your help! :mrgreen:

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 
) 

Posted
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 :/

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