Need help with jobs.
#2

Use the 'random' function...

pawn Код:
cmd:startjob(playerid, params[])
{
    if(isplayerthis || isplayerthat) //Examples
    {
        new number = random(6); //We have 6 jobs to choose from, so that's what we use. (It is possible to get 0)
        switch(number) //Remember, you must have yournumber + 1 in the random slot. Example: We want 5 options, so we do random(6). We want 3 options, we enter random(4). etc.
        {
            case 0:
            {
                //Truck Driver
            }
            case 1:
            {
                //Taxi Driver
            }
            case 2:
            {
                //Medic
            }
            //etc. case 3, 4, 5...
        }
    }
    return 1;
}
This is merely an example, and most likely will not perform as expected or intended. I suggest you use the following functions to help you create what you are looking for:
https://sampwiki.blast.hk/wiki/Random
https://sampwiki.blast.hk/wiki/Control_Structures
Reply


Messages In This Thread
Need help with jobs. - by ThaCrypte - 21.07.2013, 13:19
Re: Need help with jobs. - by Threshold - 21.07.2013, 13:38
Re: Need help with jobs. - by ThaCrypte - 21.07.2013, 15:01
Re: Need help with jobs. - by arakuta - 21.07.2013, 15:06

Forum Jump:


Users browsing this thread: 1 Guest(s)