This is really more a question of approach, but I\'m presenting it in php.
Suppose we had a list of four percentages that a give event will occur on iteration.
You can restructure the array in such a way that the events are stored with decreasing probability (for performance) and the value corresponding to an event is the probability of this particular event plus the value of a previous element (which means that the last element will always have the value 1.).
Then you just iterate over the array and return the event for which its value is greater than $rand.