Narutimmy Posted January 11, 2013 Posted January 11, 2013 Hola bueno Asus iso este scrip para que cuando sus vidas lleguen a 0 sean banneados, el problema es que un user llego a las 0 y no fue banneado ni nada, el scrip tiene permisosde Admin. local g_root = getRootElement() addEventHandler( "onPlayerWasted", g_root, function(ammo, attacker, weapon, bodypart) if attacker then setElementData(source, "Vidas", getElementData(source, "Vidas")-1) setElementData(attacker, "Vidas", getElementData(attacker, "Vidas")+1) else setElementData(source, "Vidas", getElementData(source, "Vidas")-2) end end ) function Login(antes, ahora) if ahora then local PlayerVida = getAccountData(ahora, "Vidas.Vida") if PlayerVida == false then setElementData(source, "Vidas", 100) else setElementData(source, "Vidas", PlayerVida or 100) end Vida = getElementData(source, "Vidas") if Vida == 0 then banPlayer(source, false, false, true, getRootElement ( ), "Fuiste baneado por quedarte sin vidas." ) end end end addEventHandler("onPlayerLogin", getRootElement(), Login) function onPlayerQuit() local playerAccount = getPlayerAccount(source) if (playerAccount) then local PlayerVida = getElementData(source, "Vidas") setAccountData(playerAccount, "Vidas.Vida", PlayerVida) end end addEventHandler("onPlayerQuit", getRootElement(), onPlayerQuit) function loggedOut(thePreviousAccount) if (thePreviousAccount) then local PlayerVida = getElementData(source, "Vidas") setAccountData(thePreviousAccount, "Vidas.Vida", PlayerVida) setElementData(source, "Vidas", "Guest") end end addEventHandler("onPlayerLogout",getRootElement(),loggedOut) mtasa://66.85.14.178:22003 Ts3: thezombiworld.com:7777
Castillo Posted January 11, 2013 Posted January 11, 2013 Algun error en el debug? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Narutimmy Posted January 11, 2013 Author Posted January 11, 2013 Algun error en el debug? Ninguno, ademas asus no me dijo como establecer las vidas el se puseo 200 y luego 1 y asi para hacer pruebas, ocupo eso para aserlas. mtasa://66.85.14.178:22003 Ts3: thezombiworld.com:7777
Castillo Posted January 11, 2013 Posted January 11, 2013 Fijate si de verdad se esta ejecutando el codigo despues de: if Vida == 0 then San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Narutimmy Posted January 11, 2013 Author Posted January 11, 2013 Fijate si de verdad se esta ejecutando el codigo despues de: if Vida == 0 then lo que pasa es que creo se ejecuta la proxima vez que ases login, y quiero que sea en el momento de llegar a 0 Como puedo ponerme mas o menos vidas? mtasa://66.85.14.178:22003 Ts3: thezombiworld.com:7777
Narutimmy Posted January 11, 2013 Author Posted January 11, 2013 Y si lo pongo asi? addEventHandler( "onPlayerWasted", g_root, function(ammo, attacker, weapon, bodypart) if attacker then setElementData(source, "Vidas", getElementData(source, "Vidas")-1) setElementData(attacker, "Vidas", getElementData(attacker, "Vidas")+1) else setElementData(source, "Vidas", getElementData(source, "Vidas")-2) end Vida = getElementData(source, "Vidas") if Vida == 0 then banPlayer(source, false, false, true, getRootElement ( ), "Fuiste baneado por quedarte sin vidas." ) end end ) mtasa://66.85.14.178:22003 Ts3: thezombiworld.com:7777
Castillo Posted January 11, 2013 Posted January 11, 2013 Fijate si "Vida" es igual a 0. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Arsilex Posted January 11, 2013 Posted January 11, 2013 addEventHandler( "onPlayerWasted", g_root, function(ammo, attacker, weapon, bodypart) if attacker then setElementData(source, "Vidas", getElementData(source, "Vidas")-1) setElementData(attacker, "Vidas", getElementData(attacker, "Vidas")+1) else setElementData(source, "Vidas", getElementData(source, "Vidas")-2) end Vida = getElementData(source, "Vidas") if Vida ~= 0 then banPlayer(source, false, false, true, getRootElement ( ), "Fuiste baneado por quedarte sin vidas." ) end end )
Castillo Posted January 11, 2013 Posted January 11, 2013 Eso baneara al jugador si la vidas no son 0, busca que es "~=" en Lua. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Alexs Posted January 11, 2013 Posted January 11, 2013 (edited) addEventHandler( "onPlayerWasted", root, function(ammo, attacker, weapon, bodypart) if attacker then setElementData(source, "Vidas", getElementData(source, "Vidas")-1) setElementData(attacker, "Vidas", getElementData(attacker, "Vidas")+1) else setElementData(source, "Vidas", getElementData(source, "Vidas")-2) end Vida = getElementData(source, "Vidas") if Vida < 0 then banPlayer(source, false, false, true, getRootElement ( ), "Fuiste baneado por quedarte sin vidas." ) end end ) Quizá tenia una vida, murió sin 'attacker' y su vida quedo en -1, lo que es distinto a 0. PD: Recuerda tener definido desde antes su vida, sino getElementData( source, "Vidas") seria 'false'. Edited January 11, 2013 by Guest Developer @ MYVAL
Castillo Posted January 11, 2013 Posted January 11, 2013 ">" es mayor a, "<" es menor a. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Alexs Posted January 11, 2013 Posted January 11, 2013 Ups! error mio, ya lo corregí, hubiera sido catastrófico morir con eso puesto así.. Developer @ MYVAL
Castillo Posted January 11, 2013 Posted January 11, 2013 Deberia ser mejor: if Vida <= 0 then Asi verifica si las vidas son 0 o menores que 0. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Narutimmy Posted January 11, 2013 Author Posted January 11, 2013 Deberia ser mejor: if Vida <= 0 then Asi verifica si las vidas son 0 o menores que 0. aaa Gracias jeje vere que todo funcione bien. mtasa://66.85.14.178:22003 Ts3: thezombiworld.com:7777
Narutimmy Posted January 11, 2013 Author Posted January 11, 2013 Perfecto mtasa://66.85.14.178:22003 Ts3: thezombiworld.com:7777
Recommended Posts