05.02.2011, 12:34
Hello, today I am going to show you how to make anything random. For example, random spawns or weather system.
So, first we need to make a new function, and tell the script that it will change randomally:
Then we need to make a switch/case:
An open bracket
Then we need to make, what it will actually do:
Then, another case ( we need four of them, since we put four up there^^ )
Next
And the final one
This was just example usage.
This will pick randomally, between 4 spawns
You can use it for anything, and if you want more than a single function in there:
After all, closing the switch bracket:
Thanks for viewing, comments are welcome!
So, first we need to make a new function, and tell the script that it will change randomally:
pawn Code:
new spawnpoint = random(4) // 4 = for 4 spawns, change the number to your max random thingies you'll do
pawn Code:
switch(spawnpoint)
pawn Code:
{
pawn Code:
case 0: SetPlayerPos(playerid, 0.0, 0.0, 0.0);
pawn Code:
case 1: SetPlayerPos(playerid, 2.0, 2.0, 2.0);
pawn Code:
case 2: SetPlayerPos(playerid, 3.0, 3.0, 3.0);
pawn Code:
case 3: SetPlayerPos(playerid, 4.0, 4.0, 4.0);
This will pick randomally, between 4 spawns
You can use it for anything, and if you want more than a single function in there:
pawn Code:
case 0:
{
SetPlayerPos(playerid, 0.0, 0.0, 0.0);
SendClientMessage(playerid, 0xAAAAAA, "Hi");
}
pawn Code:
}