Javier Posted October 31, 2012 Share Posted October 31, 2012 Hola amigos , Soy nuevo aqui en la comunidad y estoy haciendo un script para que cada sierto tiempo le dè al player 10% de armadura al player. Bueno aclaro que no se mucho de lua function incremento () setPedArmor ( source, getPedArmor(source) + 10 ) setTimer ( incremento, 120000, 0 ) end addEventHandler ( "onPlayerDamage", getRootElement(), incremento ) no le dà al player la armadura , me pueden ayudar. Gracias Link to comment
Arsilex Posted October 31, 2012 Share Posted October 31, 2012 function incremento () for k, jugador in ipairs(getElementsByType("player")) do setPedArmor ( jugador, getPedArmor(jugador) + 10 ) setTimer ( incremento, 120000, 0 ) end end addEventHandler ( "onResourceStart", getRootElement(), incremento ) prueba eso Link to comment
Javier Posted October 31, 2012 Author Share Posted October 31, 2012 function incremento () for k, jugador in ipairs(getElementsByType("player")) do setPedArmor ( jugador, getPedArmor(jugador) + 10 ) setTimer ( incremento, 120000, 0 ) end end addEventHandler ( "onResourceStart", getRootElement(), incremento ) prueba eso No funciona. Link to comment
Renkon Posted October 31, 2012 Share Posted October 31, 2012 function f_incremento() for _, p, in ipairs(getElementsByType("player")) do setPedArmor ( p, getPedArmor(p) + 10) setTimer (f_incremento, 120000, 1) end end addEventHandler ( "onResourceStart", resourceRoot, f_incremento ) Link to comment
Javier Posted October 31, 2012 Author Share Posted October 31, 2012 function f_incremento() for _, p, in ipairs(getElementsByType("player")) do setPedArmor ( p, getPedArmor(p) + 10) setTimer (f_incremento, 120000, 1) end end addEventHandler ( "onResourceStart", resourceRoot, f_incremento ) Me dice error. Lo que Yo quiero es que por ejemplo -- (cuando pase esto entonces dar armadura al player cada sierto tiempo) Link to comment
Castillo Posted October 31, 2012 Share Posted October 31, 2012 Le queres dar + 10 de armadura a todos los jugadores cada 2 minutos, es eso? Link to comment
Javier Posted October 31, 2012 Author Share Posted October 31, 2012 Le queres dar + 10 de armadura a todos los jugadores cada 2 minutos, es eso? Nono. Por ejemplo cuando un Zombie toque al player , entonces dar armadura cada cierto tiempo, al player que le toco el zombie Link to comment
Castillo Posted October 31, 2012 Share Posted October 31, 2012 Usa: onPlayerDamage getElementType Link to comment
Arsilex Posted October 31, 2012 Share Posted October 31, 2012 function playerDamage_text ( attacker, weapon, bodypart, loss ) if isPedZombie( attacker) setPedArmor ( source , getPedArmor(source) + 10) end end addEventHandler ( "onPlayerDamage", getRootElement (), playerDamage_text ) prueba asi aver Link to comment
Javier Posted October 31, 2012 Author Share Posted October 31, 2012 (edited) Usa:onPlayerDamage getElementType Estuve bien un script en la comunidad y dice.. if (attackerweapon == 0) and getElementData(attacker,"zombie") == true then --Aqui seria dar armadura cada sierto tiempo. Yo intentè asi function incremento () if (attackerweapon == 0) and getElementData(attacker,"zombie") == true then setPedArmor ( source, getPedArmor(source) + 10 ) setTimer ( incremento, 120000, 0 ) end end addEventHandler ( "onPlayerDamage", getRootElement(), incremento ) Pero no le da la armadura Edited October 31, 2012 by Guest Link to comment
Castillo Posted October 31, 2012 Share Posted October 31, 2012 Verifica si el atacante es un "ped" con getElementType y luego si es un zombi con getElementData. Link to comment
Javier Posted October 31, 2012 Author Share Posted October 31, 2012 Verifica si el atacante es un "ped" con getElementType y luego si es un zombi con getElementData. Yo lo puse asi. Segun el script que vi en la comunidad. if (attackerweapon == 0) and getElementData(attacker,"zombie") == true then Link to comment
Arsilex Posted October 31, 2012 Share Posted October 31, 2012 function incremento ( attacker, weapon, bodypart, loss ) if getElementType ( attacker) == "ped"then if getElementData(attacker,"zombie") == true then setPedArmor ( source, getPedArmor(source) + 10 ) setTimer ( incremento, 120000, 0 ) end end addEventHandler ( "onPlayerDamage", getRootElement(), incremento ) Link to comment
Javier Posted October 31, 2012 Author Share Posted October 31, 2012 Pekio , tu script funciona . Pero solo le da 10 armadura cuando el zombie le pega. Yo quiero que vaya incrementando de a 10. Y me dice esto Bad argument @ 'getElementType' [Expected element at argument 1, got nil] Link to comment
Arsilex Posted October 31, 2012 Share Posted October 31, 2012 claro eso te dice por que al pasar el tiempo se ejecuta de nuevo y da error por que no hay attacker.. Link to comment
Javier Posted October 31, 2012 Author Share Posted October 31, 2012 claro eso te dice por que al pasar el tiempo se ejecuta de nuevo y da error por que no hay attacker.. Entonces. Lo ideal seria que una vez que el zombie lo toco, se vaya incrementando. Link to comment
Arsilex Posted October 31, 2012 Share Posted October 31, 2012 function incremento ( attacker, weapon, bodypart, loss ) if getElementType ( attacker) == "ped"then if getElementData(attacker,"zombie") == true then setPedArmor ( source, getPedArmor(source) + 10 ) setTimer ( function() setPedArmor ( source, getPedArmor(source) + 10 ) end, 120000, 0 ) end end addEventHandler ( "onPlayerDamage", getRootElement(), incremento ) no si si es asi pero pruebalo Link to comment
Javier Posted October 31, 2012 Author Share Posted October 31, 2012 Error. 'end' expected (to close 'function' at line 55) near '' Link to comment
Castillo Posted October 31, 2012 Share Posted October 31, 2012 playersTouched = { } function incremento ( attacker, weapon, bodypart, loss ) if ( attacker and getElementType ( attacker ) == "ped" and getElementData ( attacker, "zombie" ) ) then playersTouched [ source ] = true end end addEventHandler ( "onPlayerDamage", getRootElement(), incremento ) setTimer ( function ( ) for player, _ in pairs ( playersTouched ) do setPedArmor ( player, ( getPedArmor ( player ) + 10 ) ) end end ,120000, 0 ) Link to comment
Javier Posted October 31, 2012 Author Share Posted October 31, 2012 Lo prevo y te comento Solidsnake. Link to comment
Javier Posted October 31, 2012 Author Share Posted October 31, 2012 Solid Dice esto: lua:65: bad argument #1 to 'pairs' (table expected, got nil) Link to comment
Castillo Posted October 31, 2012 Share Posted October 31, 2012 Despues de que te toque un zombi? Link to comment
Javier Posted October 31, 2012 Author Share Posted October 31, 2012 Despues de que te toque un zombi? Si. Link to comment
Castillo Posted October 31, 2012 Share Posted October 31, 2012 No se, lo acabo de probar y funciona perfectamente. Link to comment
Javier Posted October 31, 2012 Author Share Posted October 31, 2012 No se, lo acabo de probar y funciona perfectamente. Ese mismo es que usaste? Link to comment
Recommended Posts