Chaky Posted July 13, 2014 Share Posted July 13, 2014 como agrego funciones a un scoreboard para server resident tengo este solo me muetra los zombie kills exports.scoreboard:addScoreboardColumn('Zombie kills') addEvent("onZombieWasted",true) addEventHandler("onZombieWasted",root, function (killer) givePlayerMoney(killer,50) addPlayerZombieKills(killer) end) function addPlayerZombieKills(killer) local account = getPlayerAccount(killer) if isGuestAccount(account) then return end local zombieKills = getAccountData(account,"Zombie kills") if not zombieKills then setAccountData(account,"Zombie kills",0) end setAccountData(account,"Zombie kills",tonumber(zombieKills)+1) end addEventHandler("onPlayerLogin",root, function () local account = getPlayerAccount(source) if isGuestAccount(account) then return end local zombieKills = getAccountData(account,"Zombie kills") if zombieKills then setElementData(source,"Zombie kills",tostring(zombieKills)) else setElementData(source,"Zombie kills",0) end end) Link to comment
UserToDelete Posted July 13, 2014 Share Posted July 13, 2014 exports.scoreboard:addScoreboardColumn('Zombie kills') --Añade una columna a scoreboard addEvent("onZombieWasted",true) --Esto nose que carajo es addEventHandler("onZombieWasted",root, --Esto nose que carajo es function (killer) givePlayerMoney(killer,50) --da dinero al que mato un zombie addPlayerZombieKills(killer) -- Llama a funcion end) function addPlayerZombieKills(killer) --function local account = getPlayerAccount(killer) --cuenta de el asesino if isGuestAccount(account) then return end --Si no esta logeado mandarlo al carajo local zombieKills = getAccountData(account,"Zombie kills") -- Check si tiene kills if not zombieKills then setAccountData(account,"Zombie kills",0) end --Si no tiene, le pone 0 setAccountData(account,"Zombie kills",tonumber(zombieKills)+1) --Al matar un zombie le suma 1 end addEventHandler("onPlayerLogin",root, --evento function () --function local account = getPlayerAccount(source) --obtener cuenta de jugador if isGuestAccount(account) then return end --si es guest mandarlo a la miierda local zombieKills = getAccountData(account,"Zombie kills") --coger cuantas bajar tiene de la cuenta if zombieKills then --si existe... setElementData(source,"Zombie kills",tostring(zombieKills)) --ponerle las que tiene else --sino setElementData(source,"Zombie kills",0) --ponerle 0 end end) No le veo la complicacion.. Es una cosa muy simple y quizas basicas: Manejo de Data en ElementsManejo de cuentas Mas complicado era lo de scoreboard, ya que no viene en la wiki Link to comment
Chaky Posted July 13, 2014 Author Share Posted July 13, 2014 exports.scoreboard:addScoreboardColumn('Zombie kills') --Añade una columna a scoreboard addEvent("onZombieWasted",true) --Esto nose que carajo es addEventHandler("onZombieWasted",root, --Esto nose que carajo es function (killer) givePlayerMoney(killer,50) --da dinero al que mato un zombie addPlayerZombieKills(killer) -- Llama a funcion end) function addPlayerZombieKills(killer) --function local account = getPlayerAccount(killer) --cuenta de el asesino if isGuestAccount(account) then return end --Si no esta logeado mandarlo al carajo local zombieKills = getAccountData(account,"Zombie kills") -- Check si tiene kills if not zombieKills then setAccountData(account,"Zombie kills",0) end --Si no tiene, le pone 0 setAccountData(account,"Zombie kills",tonumber(zombieKills)+1) --Al matar un zombie le suma 1 end addEventHandler("onPlayerLogin",root, --evento function () --function local account = getPlayerAccount(source) --obtener cuenta de jugador if isGuestAccount(account) then return end --si es guest mandarlo a la miierda local zombieKills = getAccountData(account,"Zombie kills") --coger cuantas bajar tiene de la cuenta if zombieKills then --si existe... setElementData(source,"Zombie kills",tostring(zombieKills)) --ponerle las que tiene else --sino setElementData(source,"Zombie kills",0) --ponerle 0 end end) No le veo la complicacion.. Es una cosa muy simple y quizas basicas: Manejo de Data en ElementsManejo de cuentas Mas complicado era lo de scoreboard, ya que no viene en la wiki pero yo tamien quiero agregar que salga el dinero horas jugadas FPS Link to comment
UserToDelete Posted July 13, 2014 Share Posted July 13, 2014 Vuelvo a decir, tienes la wiki para eso. Repito: para hacer un server tu, debes aprender scripting La del dinero: exports.scoreboard:addScoreboardColumn('Dinero') function moneyInScoreboard () for indexFromPlayersInNumber,players in ipairs (getElementsByType("player")) do dineroQueTienen = getPlayerMoney(players) setElementData(players,"Dinero",tonumber(dineroQueTienen)) --no estoy seguro de esta parte end end setTimer(moneyInScoreboard,10000,0) La de las horas esta por ahi desperdigada por el foro, aun asi, te dejo la que me pasaron a mi, esta modificada por el foro, por eso la publico. (sino los cojones la iva a publicar) exports.scoreboard:addScoreboardColumn('Online') local t = { } function checkValues( source,arg1,arg2) if (arg2 >= 60) then t[ source ][ 'min' ] = tonumber( t[ source ][ 'min' ] or 0 ) + 1 t[ source ][ 'sec' ] = 0 end if (arg1 >= 60) then t[ source ][ 'min' ] = 0 t[ source ][ 'hour' ] = tonumber( t[ source ][ 'hour' ] or 0 ) + 1 end return arg1, arg2 end setTimer( function( ) for _, v in pairs( getElementsByType( "player" ) ) do if (not t[ v ]) then t[ v ] = { ["hour"] = 0, ["min"] = 0, ["sec"] = 0 } end t[ v ][ 'sec' ] = tonumber( t[ v ][ 'sec' ] or 0 ) + 1 local min,sec = checkValues ( v, t[ v ][ 'min' ] or 0, t[ v ][ 'sec' ] or 0 ) local hour = tonumber( t[ v ][ 'hour' ] or 0 ) setElementData( v, "Online", (tostring( hour )..'H '..tostring( min )..'M ') ) end end, 1000, 0 ) function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local sValue = getElementData( source,'Online' ) local hour = tonumber( t[ source ][ 'hour' ] or 0 ) local min = tonumber( t[ source ][ 'min' ] or 0 ) local sec = tonumber( t[ source ][ 'sec' ] or 0 ) setAccountData ( playeraccount, "Online-hour", tostring(hour) ) setAccountData ( playeraccount, "Online-min", tostring(min) ) setAccountData ( playeraccount, "Online-sec", tostring(sec) ) setAccountData ( playeraccount, "Online", tostring(sValue) ) end t[ source ] = nil end function onPlayerLogin (_, playeraccount ) if ( playeraccount ) then local time = getAccountData ( playeraccount, "Online" ) local hou = getAccountData ( playeraccount, "Online-hour") local min = getAccountData ( playeraccount, "Online-min") local sec = getAccountData ( playeraccount, "Online-sec") if ( time ) then setElementData ( source, "Online", time ) t[ source ]["hour"] = tonumber(hou) t[ source ]["min"] = tonumber(min) t[ source ]["sec"] = tonumber(sec) else setElementData ( source, "Online",0 ) setAccountData ( playeraccount, "Online",0 ) end end end addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) addEventHandler ( "onPlayerLogin", root, onPlayerLogin ) FPS: https://community.multitheftauto.com/index.php?p=resources&s=details&id=450 Link to comment
Chaky Posted July 14, 2014 Author Share Posted July 14, 2014 Vuelvo a decir, tienes la wiki para eso.Repito: para hacer un server tu, debes aprender scripting La del dinero: exports.scoreboard:addScoreboardColumn('Dinero') function moneyInScoreboard () for indexFromPlayersInNumber,players in ipairs (getElementsByType("player")) do dineroQueTienen = getPlayerMoney(players) setElementData(players,"Dinero",tonumber(dineroQueTienen)) --no estoy seguro de esta parte end end setTimer(moneyInScoreboard,10000,0) La de las horas esta por ahi desperdigada por el foro, aun asi, te dejo la que me pasaron a mi, esta modificada por el foro, por eso la publico. (sino los cojones la iva a publicar) exports.scoreboard:addScoreboardColumn('Online') local t = { } function checkValues( source,arg1,arg2) if (arg2 >= 60) then t[ source ][ 'min' ] = tonumber( t[ source ][ 'min' ] or 0 ) + 1 t[ source ][ 'sec' ] = 0 end if (arg1 >= 60) then t[ source ][ 'min' ] = 0 t[ source ][ 'hour' ] = tonumber( t[ source ][ 'hour' ] or 0 ) + 1 end return arg1, arg2 end setTimer( function( ) for _, v in pairs( getElementsByType( "player" ) ) do if (not t[ v ]) then t[ v ] = { ["hour"] = 0, ["min"] = 0, ["sec"] = 0 } end t[ v ][ 'sec' ] = tonumber( t[ v ][ 'sec' ] or 0 ) + 1 local min,sec = checkValues ( v, t[ v ][ 'min' ] or 0, t[ v ][ 'sec' ] or 0 ) local hour = tonumber( t[ v ][ 'hour' ] or 0 ) setElementData( v, "Online", (tostring( hour )..'H '..tostring( min )..'M ') ) end end, 1000, 0 ) function onPlayerQuit ( ) local playeraccount = getPlayerAccount ( source ) if ( playeraccount ) and not isGuestAccount ( playeraccount ) then local sValue = getElementData( source,'Online' ) local hour = tonumber( t[ source ][ 'hour' ] or 0 ) local min = tonumber( t[ source ][ 'min' ] or 0 ) local sec = tonumber( t[ source ][ 'sec' ] or 0 ) setAccountData ( playeraccount, "Online-hour", tostring(hour) ) setAccountData ( playeraccount, "Online-min", tostring(min) ) setAccountData ( playeraccount, "Online-sec", tostring(sec) ) setAccountData ( playeraccount, "Online", tostring(sValue) ) end t[ source ] = nil end function onPlayerLogin (_, playeraccount ) if ( playeraccount ) then local time = getAccountData ( playeraccount, "Online" ) local hou = getAccountData ( playeraccount, "Online-hour") local min = getAccountData ( playeraccount, "Online-min") local sec = getAccountData ( playeraccount, "Online-sec") if ( time ) then setElementData ( source, "Online", time ) t[ source ]["hour"] = tonumber(hou) t[ source ]["min"] = tonumber(min) t[ source ]["sec"] = tonumber(sec) else setElementData ( source, "Online",0 ) setAccountData ( playeraccount, "Online",0 ) end end end addEventHandler ( "onPlayerQuit", root, onPlayerQuit ) addEventHandler ( "onPlayerLogin", root, onPlayerLogin ) FPS: https://community.multitheftauto.com/index.php?p=resources&s=details&id=450 la segunda de las horas de juego me tira error alguna idea ya intente y no anda :c Link to comment
alex17 Posted July 14, 2014 Share Posted July 14, 2014 Estos resources que buscas no son muy complejos y si no me equivoco estan en la comunidad si te esforzaras un poco podrias hacerlo vos mismo de todas maneras revisa este post para el script de las horas. viewtopic.php?f=145&t=75095 Link to comment
Recommended Posts