Jump to content

Script Deaths


JuniorMelo

Recommended Posts

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 
) 

Link to comment
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

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 
) 

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