Jump to content

[Duda]deaths y kills


Recommended Posts

Posted

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

My ingame nick is: #SilverY' / Seku.

560x95_FFFFFF_FF9900_000000_000000.png

**Entren al servidor**!! me encanto el servidor se los recomiendo ^^ , no es mio es de @TomasitoCaram

Posted

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 
) 

430x73_FFFFFF_FF9900_000000_000000.png
Posted
¿ 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...

My ingame nick is: #SilverY' / Seku.

560x95_FFFFFF_FF9900_000000_000000.png

**Entren al servidor**!! me encanto el servidor se los recomiendo ^^ , no es mio es de @TomasitoCaram

Posted

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) 
  

My ingame nick is: #SilverY' / Seku.

560x95_FFFFFF_FF9900_000000_000000.png

**Entren al servidor**!! me encanto el servidor se los recomiendo ^^ , no es mio es de @TomasitoCaram

Posted

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) 
  

430x73_FFFFFF_FF9900_000000_000000.png
Posted

gracias alex ^^ , otra duda como hago para obtener el color de los jugadores

My ingame nick is: #SilverY' / Seku.

560x95_FFFFFF_FF9900_000000_000000.png

**Entren al servidor**!! me encanto el servidor se los recomiendo ^^ , no es mio es de @TomasitoCaram

Posted
dxDrawText(getPlayerName(player), Nombre, posX+posY*20) 

lo tengo haci ¿como lo podria de poner ?

My ingame nick is: #SilverY' / Seku.

560x95_FFFFFF_FF9900_000000_000000.png

**Entren al servidor**!! me encanto el servidor se los recomiendo ^^ , no es mio es de @TomasitoCaram

Posted
[/lua]

lo tengo haci ¿como lo podria de poner ?

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

Currently developing for International Gaming Community - Join us!

Posted

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) 
  

430x73_FFFFFF_FF9900_000000_000000.png
Posted
y en que parte defines el color del texto ?

No es extremamente obligatorio definir el color en DX. Es un Argumento Secundario

Currently developing for International Gaming Community - Join us!

Posted

Gracias a todos ya funciono.

OFFTopic:

aca con tomi pal foro x3

10169430_1430773243840999_7302419828745052576_n.jpg

My ingame nick is: #SilverY' / Seku.

560x95_FFFFFF_FF9900_000000_000000.png

**Entren al servidor**!! me encanto el servidor se los recomiendo ^^ , no es mio es de @TomasitoCaram

Posted
Gracias a todos ya funciono.

OFFTopic:

aca con tomi pal foro x3

10169430_1430773243840999_7302419828745052576_n.jpg

De nada y pos, que secsi soy :roll:

Currently developing for International Gaming Community - Join us!

  • Recently Browsing   0 members

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