ID:2054721
 
(See the best response by Lummox JR.)
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?
You need to keep track of when the event happens. Once you've kept track of every time it happens, you can easily filter it every X time it happens.

mob
var
level = 1
proc
LevelUp()
level++
if(!(level%5))
//do something on every fifth level


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.
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?
Yep.
Best response
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

mob/proc/Achieve(item_type)
if(!achieved) achieved = new
++achieved[item_type]
// now react to the achievement

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.
ah awesome i was mostly just curious because i never thought of it until recently that i had 0 clue how to even code such a thing