aka Blue Posted April 20, 2016 Posted April 20, 2016 Estoy intentando hacer un timer para todos los jugadores. Lo que quiero hacer es que el timer sea cada minuto y cuente las horas jugadas de un jugador dentro del servidor y al tener el jugador x minutos, realice una función. El problema que tengo es que, sí, cuenta los minutos pero al llegar a tal minuto, no realiza la función: Aquí el código. setTimer ( function ( ), for k, v in ipairs ( getElementsByType ( 'player' ) ) do local minutosEnArea = getElementData ( v, "minutosEnCasino" ) or 0 if minutosEnArea then setElementData ( v, "minutosEnCasino", minutosEnArea + 1 ) end if minutosEnArea == 40 then setElementPosition ( v, fueraX, fueraY, fueraZ ) outputChatBox ( "Te han echado del casino, has estado demasiado tiempo.", v, 255, 0, 0 ) end end end, 10000, 0 )
-Rex- Posted April 20, 2016 Posted April 20, 2016 setTimer ( function ( ), for k, v in ipairs ( getElementsByType ( 'player' ) ) do local minutosEnArea = getElementData ( v, "minutosEnCasino" ) or 0 setElementData ( v, "minutosEnCasino", minutosEnArea + 1 ) outputChatBox( minutosEnArea ) if minutosEnArea >= 40 then setElementPosition ( v, fueraX, fueraY, fueraZ ) outputChatBox ( "Te han echado del casino, has estado demasiado tiempo.", v, 255, 0, 0 ) end end end, 60000, 0 ) Te movi algunas cosas pero, Verifica con el outputChatBox y checa si realmente esta contando los minutos como quieres. Leal es quien te ama y respeta tus sentimientos Paid Scripter, Contact me: https://www.facebook.com/rexscripting/ Estoy retirado.
aka Blue Posted April 20, 2016 Author Posted April 20, 2016 He dicho que los minutos los cuenta bien, lo que pasa es que tengo una comprobación ahí y es que si el tiempo es igual o mayor a 40, le echa del casino, pero no lo hace.
Tomas Posted April 20, 2016 Posted April 20, 2016 if tonumber(minutosEnArea) >= 40 then Currently developing for International Gaming Community - Join us!
aka Blue Posted April 20, 2016 Author Posted April 20, 2016 Gracias @Tomas, ya funciona. Ahora lo que no me va bien es el comprobador del tiempo que lleva dentro. addCommandHandler ( "minutos", function ( player ) if isLoggedIn ( player ) then local minutos = getElementData ( player, "minutos" ) outputChatBox ( "Llevas "..tonumber ( minutos ).." en el casino.", 0, 255, 0 ) end end ) Me da el error: Bad argument @ outputChatBox [ expected element at argument 2, got number '0' ]
Enargy, Posted April 20, 2016 Posted April 20, 2016 Te faltó el 'player' en el outputChatBox. - Inactivo.
aka Blue Posted April 20, 2016 Author Posted April 20, 2016 Dios, que error más tonto, gracias a todos
aka Blue Posted April 21, 2016 Author Posted April 21, 2016 Revivo. Sigo teniendo el mismo problema, no ejecuta el outputChatBox al tener dos minutos. addCommandHandler ( "minutosencasino", function ( player ) if isLoggedIn ( player ) then local minutos = getElementData ( player, "minutosCasino" ) outputChatBox ( "Llevas "..tonumber ( minutos ).." jugados en el casino.", player, 0, 255, 0 ) end end ) setTimer ( function ( ) for k, player in ipairs ( getElementsByType ( 'player' ) ) do if isLoggedIn ( player ) then local minutosDentro = getElementData ( player, "minutosCasino" ) setElementData ( player, "minutosCasino", minutosDentro + 1 ) if tonumber ( minutosDentro ) >= 2 then outputChatBox ( "¡A LA PUTA CALLE!" ) end end end end, 60000, 0 )
-Rex- Posted April 21, 2016 Posted April 21, 2016 addCommandHandler ( "minutosencasino", function ( player ) --if isLoggedIn ( player ) then local minutos = getElementData ( player, "minutosCasino" ) outputChatBox ( "Llevas "..tonumber ( minutos ).." jugados en el casino.", player, 0, 255, 0 ) --end end ) setTimer ( function ( ) for k, player in ipairs ( getElementsByType ( 'player' ) ) do -- if isLoggedIn ( player ) then local minutosDentro = getElementData ( player, "minutosCasino" ) or 0 setElementData ( player, "minutosCasino", minutosDentro + 1 ) outputChatBox( tostring( type( minutosDentro) ) ) if tonumber ( minutosDentro ) >= 2 then outputChatBox ( "¡A LA PUTA CALLE!" ) end --end end end, 1000, 0 ) No se tu pero a mi me funciona, Checa esa funcion isLoggedIn por si sea la que te este fallando. Leal es quien te ama y respeta tus sentimientos Paid Scripter, Contact me: https://www.facebook.com/rexscripting/ Estoy retirado.
aka Blue Posted April 21, 2016 Author Posted April 21, 2016 No pensé que sea ese el problema, voy a intentar a ver, ahora escribo.
Recommended Posts