Scripts / Increment a Variable by 1?

Author
Message
Nathan38
13
Years of Service
User Offline
Joined: 13th Feb 2011
Location:
Posted: 29th Jun 2016 12:14
Hi all,
Currently just having a mess around with a basic "level up" system, this is what I have currently:

if myPlayerCurrentXP >= 250 then
myPlayerLevel = myPlayerLevel + 1
PromptDuration("Congratulations, you have gained a level!" , 600)
end

when the player reaches 250 xp, the players level should be increased by 1, however, when this threshold has been hit, the PlayerLevel variable just keeps counting, forever instead of just increasing by just 1. Please can anyone help me with this?
cybernescence
GameGuru Master
11
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 29th Jun 2016 13:29
Reset the currentXP variable or the >= condition will always be true once reached and therefore always incrementing the player level score.
Nathan38
13
Years of Service
User Offline
Joined: 13th Feb 2011
Location:
Posted: 29th Jun 2016 13:37
Thanks very much @cybernescence! That solved it

Login to post a reply

Server time is: 2024-05-04 06:56:19
Your offset time is: 2024-05-04 06:56:19