21.07.2013, 13:38
Use the 'random' function...
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
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;
}
https://sampwiki.blast.hk/wiki/Random
https://sampwiki.blast.hk/wiki/Control_Structures