DRW Posted May 8, 2015 Share Posted May 8, 2015 I'm making a kind of a stat upgrade system, I made an event that is supposed to give you 20 stat points to the Colt45 for example, cancel the event and output a chat message when you have the weapon stat upgraded to the max. The script gives 20 stat points and works perfectly: addEvent("addstat1",true) addEventHandler ("addstat1", root,function () setPedStat (source, 69, (getPedStat (source, 69)+20)) outputChatBox ("Has mejorado 2 puntos de Colt 45.",source,255,255,255) end) but when I try to cancel event when on max stats: addEvent("addstat1",true) addEventHandler ("addstat1", root,function () if getPedStat (source,69,1000) then outputChatBox ("NO PUEDES MEJORAR.",source,255,255,255) cancelEvent() else setPedStat (source, 69, (getPedStat (source, 69)+20)) outputChatBox ("Has mejorado 2 puntos de Colt 45.",source,255,255,255) end end) This one is not working. Link to comment
Walid Posted May 8, 2015 Share Posted May 8, 2015 use return Instead of cancelEvent() Link to comment
DRW Posted May 8, 2015 Author Share Posted May 8, 2015 use return Instead of cancelEvent() Not working. Link to comment
Walid Posted May 8, 2015 Share Posted May 8, 2015 use return Instead of cancelEvent() Not working. :3 i pretty sure that u didn't try it by yourself addEvent("addstat1",true) addEventHandler ("addstat1", root, function () local weaponState = getPedStat (source,69) if tonumber (weaponState) >= 1000 then outputChatBox ("NO PUEDES MEJORAR.",source,255,255,255) return end setPedStat (source, 69, tonumber(weaponState)+20) outputChatBox ("Has mejorado 2 puntos de Colt 45.",source,255,255,255) end) Link to comment
DRW Posted May 8, 2015 Author Share Posted May 8, 2015 use return Instead of cancelEvent() Not working. :3 i pretty sure that u didn't try it by yourself addEvent("addstat1",true) addEventHandler ("addstat1", root, function () local weaponState = getPedStat (source,69) if tonumber (weaponState) >= 1000 then outputChatBox ("NO PUEDES MEJORAR.",source,255,255,255) return end setPedStat (source, 69, tonumber(weaponState)+20) outputChatBox ("Has mejorado 2 puntos de Colt 45.",source,255,255,255) end) addEvent("addstat1",true) addEventHandler ("addstat1", root,function () if not (getPedStat (source,69,1000)) then setPedStat (source, 69, (getPedStat (source, 69)+20)) outputChatBox ("Has mejorado 2 puntos de Colt 45.",source,255,255,255) else outputChatBox ("NO PUEDES MEJORAR.",source,255,255,255) return end end) I did this, not working. You've done it way better, thank you so much, man Link to comment
Walid Posted May 8, 2015 Share Posted May 8, 2015 I did this, not working. You've done it way better, thank you so much, man You are welcome Link to comment
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