Jump to content

Guardado de asesinatos y muertes


CeKiT

Recommended Posts

function onPlayerQuit ( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            deaths = getElementData(source,"Reset") 
            setAccountData ( playeraccount, "Reset", deaths ) 
      end 
end 
  
function onPlayerLogin ( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            local deaths= getAccountData ( playeraccount, "Deaths" ) 
            if ( deaths) then 
            setElementData ( source, "Reset", deaths ) 
            end 
      end 
end 
  
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) 

prova haci

Link to comment

Reset? a que va ese codigo?

te dare el codigo que yo uso

addEventHandler ( "onPlayerWasted", root, 
    function ( totalAmmo, killer, killerWeapon, bodypart, stealth ) 
        if ( killer ) then 
            local account = getPlayerAccount ( killer ) 
            if ( killer ~= source ) then 
                setAccountData ( account, "totalkillsdeaths.Kills", tonumber ( getAccountData ( account, "totalkillsdeaths.Kills" ) or 0 ) +1 ) 
                setElementData ( killer, "Kills", tonumber ( getAccountData ( account, "totalkillsdeaths.Kills" ) ) ) 
            end 
        end 
        local accountSource = getPlayerAccount ( source ) 
        setAccountData ( accountSource, "totalkillsdeaths.Deaths", tonumber ( getAccountData ( accountSource, "totalkillsdeaths.Deaths" ) or 0 ) +1 ) 
        setElementData ( source, "Deaths", tonumber ( getAccountData ( accountSource, "totalkillsdeaths.Deaths" ) ) ) 
    end 
)     
  
addEventHandler( "onPlayerLogin",root, 
    function( thePreviousAccount, theCurrentAccount, autoLogin ) 
        local account = getPlayerAccount ( source ) 
        if not getAccountData( account,"totalkillsdeaths.Kills" ) and not getAccountData( account,"totalkillsdeaths.Deaths" ) then 
            setAccountData( account,"totalkillsdeaths.Kills",0 ) 
            setAccountData( account,"totalkillsdeaths.Deaths",0 ) 
        end 
        setElementData( source,"Deaths",tonumber( getAccountData( account,"totalkillsdeaths.Deaths" ) or 0 ) ) 
        setElementData( source,"Kills",tonumber( getAccountData( account,"totalkillsdeaths.Kills" ) or 0 ) ) 
    end 
 ) 
  
  
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), 
  
    function() 
        call(getResourceFromName("scoreboard"),"addScoreboardColumn","Kills", getRootElement(), 3, 35) 
        call(getResourceFromName("scoreboard"),"addScoreboardColumn","Deaths", getRootElement(), 4, 35) 
  
    end 
  
) 

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...