Random spawns to teams (+REP)
#1

I know how to add random spawns...I got the USA spawn point to work, but im getting some weird errors when I try to use the array under multiple teams.
Heres my code.

Quote:

new Float:RandomSpawns[][] =
{
{246.5136,1860.1316,14.0840,3.5120},//usa
{259.1712,1851.1980,8.7578,350.1835},//usa
{246.5136,1860.1316,14.0840,3.5120},//usa
{259.1712,1851.1980,8.7578,350.1835},//usa

{405.0340,2434.2354,16.5000,0.3332},//europe
{386.7775,2544.4758,16.5449,184.4533},//europe
{351.2219,2542.2969,16.7338,181.6332}//europe

{-384.8250,2206.1545,42.4235,279.4162},//taliban
{-384.8250,2206.1545,42.4235,279.4162},//taliban
{-418.3107,2228.7891,42.4297,4.9569},//taliban
{-431.3057,2241.0020,42.9834,179.7752},//taliban
{-377.2758,2242.6189,42.6185,104.5746},//taliban
{-375.8265,2260.4126,43.0619,92.9811},//taliban
};

public OnPlayerSpawn(playerid)
{
if (gTeam[playerid] == TEAM_USA)
{
new Random = random(sizeof(RandomSpawns));
SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1],RandomSpawns[Random][2], RandomSpawns[Random][3]);
}

// now when I try to continue my array on the other teams I get this error...
C:\Users\RAC\Desktop\only server\gamemodes\AW.pwn(18 : error 032: array index out of bounds (variable "RandomSpawns")

if (gTeam[playerid] == TEAM_=EUROPE)
{
?
}
if (gTeam[playerid] == TEAM_taliban)
{

}

Short,sweet, and to the point... Could some one please help me assign the array to the other teams?
Reply
#2

pawn Код:
SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1],RandomSpawns[Random][2], RandomSpawns[Random][3]);
}
You seem to have a lot of arguments under the SetPlayerPos. You should use random INSIDE SetPlayerPos
Reply
#3

use SetPlayerPos for the first 3, then for the angle use https://sampwiki.blast.hk/wiki/SetPlayerFacingAngle

EDIT: Also, you should use [13][4] on the spawn array
Reply
#4

Turns out.. I was doing everything right... Just looking at it the wrong way! Thanks for your help everyone!!!!!!!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)