like say i want something to happen everytime i level 5 times or i get 5 items how do i code it so it activates for every x amount i achieve?
so if i wanted it to be like every 3 or 7 levels it'd just be if(!(level%3)) or if(!(level%7) right?
|
If you're planning on doing this for gathering/earning X items, and that's going to cover a lot of items, then I would suggest something where you don't need a separate var for each one.
An example might be: mob/var/list/achieved Levels I'd probably handle on their own, but something like a bonus you get for every 5 items you collect would fit more into this scheme. Ideally you'll probably also want some other lists to keep track of how many of each item you want and what reward you get, so that you don't have to make Achieve() use switch() or a bunch of if/else statements. |
Look up the modulus/modulo (%) operator. It returns the remainder of a division operation.
So:
13%2 = 1 because 13/2 = 6.5; round(6.5)*2 = 12; 13-12 = 1
13%5 = 3 because 13/5 = 2.6; round(2.6)*5 = 10; 13-10 = 3
What we're doing is checking if there is no remainder, meaning the if statement will be true if level is 5,10,15,20,25, etc.