Jump to content

[Duda]deaths y kills


Recommended Posts

prueva con esto aver si te sirve D:

server.lua

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  
        else 
            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 
    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",resourceRoot, 
    function( ) 
        outputDebugString( "add Total Kills to scoreboard Return: "..tostring( 
            call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "Kills",root,2, 0.07 ) 
        ) ) 
         
        outputDebugString( "add Total Deaths to scoreboard Return: "..tostring( 
            call( getResourceFromName("Scoreboard"), "addScoreboardColumn", "Deaths",root,3, 0.09 ) 
        ) ) 
    end 
) 

Link to comment
¿ alguna forma para obtener cuantos jugadores mato y cuantas murio ? es para hacer un dxscoreboard , Saludos ! Gracias anticipado :D .

no use todas las funciones que usan el scoreboard que te viene petrerminado , hice uno desde 0 , solo con getPlayerName , getPlayerPing etc... no me sirvio pero gracias igualmente dxText , dxRec y todo eso ya sabes...

Link to comment

esto es una parte donde agrego todas las columnas con dxDrawText , pensaba que podria hacer un getPlayerKills y un getPlayersDeaths , pero que lastima hubiera estado bueno eso...

        
dxDrawText(getPlayerName(player), nombre, posX+posY*20) 
dxDrawText(getPlayerTeam(player) and getTeamName(getPlayerTeam(player)) or "None", team, posX+posY*20) 
dxDrawText(getPlayerMoney(player), dinero, posX+posY*20) 
dxDrawText(getPlayerPing(player), ping, posX+posY*20) 
  

Link to comment

puedes utlizar el codigo que te di

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

y para añadirlo a tu escoreboard

puedes utilizar esto como ejemplo

dxDrawText(getElementData(player, "Kills"), Kills, posX+posY*20)  
dxDrawText(getElementData(player, "Deaths"), Deaths, posX+posY*20) 
  

Link to comment

añado por si no quieres que se vea el color hexadecimal D:

  
     local r, g, b = getPlayerNametagColor ( player ) 
     dxDrawText(getPlayerName(player), Nombre, posX+posY*20, tocolor ( r,  g, b, 255), false,false,false,true) 
  

Link to comment
  • Recently Browsing   0 members

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