KiffShark Posted November 17, 2012 Posted November 17, 2012 (edited) Hi everybody! I've done a shoppanel and in a button that simulates something like adrenaline I want that it give +1 health every second the button works ok with client.. gui... everything.. function setsalud4 works ok, (but setTimer I guess) because of the console give me error in elements at function setsalud5 (marked with --HERE).. nil value... every second and in the game I don't receive +1/s so maybe timer runs good and the problem is setsalud5 function setsalud5 () local Health5 = getElementHealth(source) --HERE setElementHealth ( source, Health5 + 1 ) -- HERE end addEventHandler ( "salud5", getRootElement(), setsalud5 ) addEvent( "salud4", true ) function setsalud4 (player) local PlayerMoney = getPlayerMoney(source) if ( PlayerMoney >= 5000) then setElementHealth ( source, 500 ) setPedStat(source, 22, 999) setPedStat(source, 23, 999) setPedStat(source, 24, 999) setPedStat(source, 225, 999) --bucear takePlayerMoney(source,5000) outputChatBox ( "*Has comprado virus Génesis por $5000*", source, 255, 0, 0 ) outputChatBox ( "*El virus te da +salud, +fuerza, +resistencia +resistencia de buceo. Durante 1 sesión*", source, 255, 0, 0 ) setTimer ( setsalud5, 1000, 0 ) else outputChatBox("*No tienes suficiente dinero*", source, 255, 0, 0, true) end end addEventHandler ( "salud4", getRootElement(), setsalud4 ) Some Idea? Edited November 20, 2012 by Guest https://www.youtube.com/PinkSharkGaming
manve1 Posted November 17, 2012 Posted November 17, 2012 --Server-side addEvent( "salud4", true ) function setsalud4 (player) local PlayerMoney = getPlayerMoney(source) if ( PlayerMoney >= 5000) then setElementHealth ( source, 500 ) ; setPedStat(source, 22, 999); setPedStat(source, 23, 999); setPedStat(source, 24, 999); setPedStat(source, 225, 999); --bucear takePlayerMoney(source,5000); setTimer ( function() local Health5 = getElementHealth(source) setElementHealth ( source, Health5 + 1 ) end, 1000, 0 ); outputChatBox ( "*Has comprado virus Génesis por $5000*", source, 255, 0, 0 ) ; outputChatBox ( "*El virus te da +salud, +fuerza, +resistencia +resistencia de buceo. Durante 1 sesión*", source, 255, 0, 0 ) ; else outputChatBox("*No tienes suficiente dinero*", source, 255, 0, 0, true) end end addEventHandler ( "salud4", getRootElement(), setsalud4 ) try this, not tested, tell me if works or if it doesn't Looking for tutorials or information? check out: www.simpleask.co.uk
KiffShark Posted November 17, 2012 Author Posted November 17, 2012 hi! thanks for answer!! console give me error at: local Health5 = getElementHealth(source) setElementHealth ( source, Health5 + 1 ) [2012-11-17 14:43:33] WARNING: itemshop\s_items.lua:87: Bad argument @ 'getElementHealth' [Expected element at argument 1, got nil][2012-11-17 14:43:33] ERROR: unzipped\itemshop\s_items.lua:88: attempt to perform arithmetic on local 'Health5' (a boolean value) the same https://www.youtube.com/PinkSharkGaming
Castillo Posted November 17, 2012 Posted November 17, 2012 function setsalud4 ( ) local PlayerMoney = getPlayerMoney ( source ) if ( PlayerMoney >= 5000) then setElementHealth ( source, 500 ) setPedStat ( source, 22, 999 ) setPedStat ( source, 23, 999 ) setPedStat ( source, 24, 999 ) setPedStat ( source, 225, 999 ) --bucear takePlayerMoney ( source, 5000 ) outputChatBox ( "*Has comprado virus Génesis por $5000*", source, 255, 0, 0 ) outputChatBox ( "*El virus te da +salud, +fuerza, +resistencia +resistencia de buceo. Durante 1 sesión*", source, 255, 0, 0 ) setTimer ( function ( thePlayer ) if ( isElement ( thePlayer ) ) then setElementHealth ( thePlayer, getElementHealth ( thePlayer ) + 1 ) end end ,1000, 0, source ) else outputChatBox ( "*No tienes suficiente dinero*", source, 255, 0, 0, true ) end end addEvent ( "salud4", true ) addEventHandler ( "salud4", getRootElement(), setsalud4 ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Renkon Posted November 17, 2012 Posted November 17, 2012 //es: Como estas triggeando la llamada a la función?, si es con triggerServerEvent(evento, ELSOURCE) ? I believe your problem is that you are triggering the event with wrong source.
KiffShark Posted November 17, 2012 Author Posted November 17, 2012 That works SolidSnake! Thanks everybody! /Gracias!! https://www.youtube.com/PinkSharkGaming
Castillo Posted November 17, 2012 Posted November 17, 2012 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now