Jump to content

cancelEvent when stats are on max


DRW

Recommended Posts

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
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
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 :D

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...