Spawn -
JaKe Elite - 28.09.2017
PHP Code:
enum ENUM_GAME
{
gameID,
gameName[20],
gameType
};
enum ENUM_SPAWN
{
spawn_gameID,
spawn_gameTeam,
Float:spawn_X,
Float:spawn_Y,
Float:spawn_Z,
Float:spawn_A,
}
////////////////////////////////////////////////////////////////////////////////
new GameInfo[][ENUM_GAME] = {
{0, "de_dust", GAME_BOMBING}
};
new SpawnInfo[][ENUM_SPAWN] =
{
// De_Dust
{0, TEAM_TERRORIST, 7748.2246, -2561.8672, 18.4057, 254.3921},
{0, TEAM_TERRORIST, 7745.2607, -2572.0278, 18.4135, 308.5993},
{0, TEAM_TERRORIST, 7741.2280, -2566.7903, 18.4135, 268.4923},
{0, TEAM_TERRORIST, 7741.3320, -2558.5928, 18.4081, 245.6188},
{0, TEAM_COUNTER, 7692.6514, -2643.5911, 18.4302, 270.4191},
{0, TEAM_COUNTER, 7692.4092, -2656.4092, 18.3768, 269.4791},
{0, TEAM_COUNTER, 7701.4702, -2659.5520, 18.3846, 311.1528},
{0, TEAM_COUNTER, 7706.7485, -2653.4817, 18.3768, 287.0259}
};
new game_id = 0; // de_dust
// OnGameModeInit
game_id = random(sizeof(GameInfo));
So I have an array here, I would like to determine and set the players position according on the array. Like for EG, The map is de_dust and the only positions that will be randomized are those arrays/records which is set for that game only.
How can I do that?
Re: Spawn -
jlalt - 28.09.2017
You can use a way where you define the kinds and add a parameter called kind in your ENUM_SPAWN,
example:
PHP Code:
#define TEAM_DUST 1
#define TEAM_... 2
...
then
PHP Code:
enum ENUM_SPAWN
{
spawn_KInD,
spawn_gameID,
spawn_gameTeam,
Float:spawn_X,
Float:spawn_Y,
Float:spawn_Z,
Float:spawn_A,
}
and later
PHP Code:
new SpawnInfo[][ENUM_SPAWN] =
{
// De_Dust
{TEAM_DUST, 0, TEAM_TERRORIST, 7748.2246, -2561.8672, 18.4057, 254.3921},
....
{TEAM_..., 0, TEAM_TERRORIST, 7748.2246, -2561.8672, 18.4057, 254.3921},
....
};
and later will be able to get spawn area kind by an if statement, ex:
PHP Code:
if(SpawnInfo[x][spawn_KInD] == TEAM_DUST) // this spawn area belongs to dust!
{
}
Re: Spawn -
JaKe Elite - 28.09.2017
Yeah, but the problem is how can I randomize a spawn point for a specific game depending it on the game_id variable?
Re: Spawn -
Misiur - 28.09.2017
Something like
pawn Code:
new onlyCurrentGameSpawns[sizeof(SpawnInfo)], count;
for (new i = 0; i != sizeof SpawnInfo; ++i) {
if (SpawnInfo[i][spawn_gameID] == gameid) {
onlyCurrentGameSpawns[count++] = i;
}
}
new index = onlyCurrentGameSpawns[random(count)];
Re: Spawn -
JaKe Elite - 28.09.2017
Will try this out, thanks!
Re: Spawn -
JaKe Elite - 28.09.2017
PHP Code:
stock Initiate_Spawn(playerid)
{
new count, index, onlyCurrentGameSpawns[sizeof(SpawnInfo)];
for(new i; i != sizeof(SpawnInfo); ++i)
{
if (SpawnInfo[i][spawn_gameID] == game_id) {
onlyCurrentGameSpawns[count++] = i;
}
}
index = onlyCurrentGameSpawns[random(count)];
if(gTeam[playerid] == TEAM_TERRORIST)
{
SetPlayerPos(playerid, SpawnInfo[index][spawn_X], SpawnInfo[index][spawn_Y], SpawnInfo[index][spawn_Z]);
SetPlayerFacingAngle(playerid, SpawnInfo[index][spawn_A]);
/*foreach(new x : g_Terrorist)
{
SetPlayerMarkerForPlayer(playerid, x, 0xFF6347FF);
}
if(server_bomber == INVALID_PLAYER_ID && !IsPlayerConnected(server_bomber))
{
server_bomber = Iter_Random(g_Terrorist);
ShowPlayerObjective(playerid, 0x33AA33FF, "You are chosen to handle the C4 Bomb.", 5000);
printf("%s has been chosen to handle the C4 bomb.", GetName(server_bomber));
}
Server_AssignBomber();*/
}
else
{
SetPlayerPos(playerid, SpawnInfo[index][spawn_X], SpawnInfo[index][spawn_Y], SpawnInfo[index][spawn_Z]);
SetPlayerFacingAngle(playerid, SpawnInfo[index][spawn_A]);
foreach(new x : g_Counter)
{
SetPlayerMarkerForPlayer(playerid, x, 0x00CCFFFF);
}
}
return 1;
}
Will this work?