18.01.2013, 21:54
Quote:
I know how that works, but if you just looked to the SetPlayerPos you'd see what i meant, any one else can help?
|
Either use a switch statement with 'random()' as the top value and a set of cumulative numbers for the case values, like so:
pawn Code:
switch(3)
{
case 0:SetPlayerPos(playerid, 0.0, 10.0, 3.0);
case 1:SetPlayerPos(playerid, 10.0, 0.0, 3.0);
case 2:SetPlayerPos(playerid, -5.0, 0.0, 3.0);
}
pawn Code:
new Float:gSpawnPositions[3][3]=
{
{0.0, 10.0, 3.0},
{10.0, 0.0, 3.0},
{-5.0, 0.0, 3.0}
};
// On the timer function
new id = random(sizeof(gSpawnPositions)); // Pick a number between 0 and the highest cell in the array.
SetPlayerPos(playerid, gSpawnPositions[id][0], gSpawnPositions[id][1], gSpawnPositions[id][2]);
The first method is suitable for if you only use those coordinates once, the second method is good if you want to use the coordinates in multiple places in your script (if you define the array as a global)