Jump to content

cancelEvent when stats are on max


DRW

Recommended Posts

Posted

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.

tJ5zeFm.gif

Proud owner and developer of ZNEXT: Aftermath.

Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience.

Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. 

Español, Pусский, Türk, عربى, Polski, Português

IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB

Posted
use return Instead of cancelEvent()

Not working.

tJ5zeFm.gif

Proud owner and developer of ZNEXT: Aftermath.

Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience.

Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. 

Español, Pусский, Türk, عربى, Polski, Português

IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB

Posted
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) 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
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

tJ5zeFm.gif

Proud owner and developer of ZNEXT: Aftermath.

Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience.

Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. 

Español, Pусский, Türk, عربى, Polski, Português

IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB

Posted
I did this, not working. You've done it way better, thank you so much, man :D

You are welcome

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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...