Auto spawn -
KinderClans - 03.09.2018
I managed to fix auto spawn, now it works but it doesn't set correct team by the skin a player has:
pawn Код:
ProcessSpawn(playerid)
{
new skin = Player[playerid][Skin];
switch (skin)
{
case 280, 284, 285, 286, 306, 307, 309: //Cop
{
gTeam[playerid] = TEAM_COP;
SetPlayerToTeamColour(playerid);
SetPlayerTeam(playerid,1);
new rand = random(sizeof(RandomCopSpawns));
SetSpawnInfo(playerid, GetPlayerTeam(playerid), Player[playerid][Skin], RandomCopSpawns[rand][0],RandomCopSpawns[rand][1],RandomCopSpawns[rand][2], 270.0000, 0, 0, 0, 0, 0, 0);
TogglePlayerSpectating(playerid, false);
}
}
gTeam[playerid] = TEAM_CIV;
SetPlayerToTeamColour(playerid);
SetPlayerTeam(playerid,0);
new rand = random(sizeof(RandomSpawnsLosSantos));
SetSpawnInfo(playerid, GetPlayerTeam(playerid), Player[playerid][Skin], RandomSpawnsLosSantos[rand][0],RandomSpawnsLosSantos[rand][1],RandomSpawnsLosSantos[rand][2], 270.0000, 0, 0, 0, 0, 0, 0);
TogglePlayerSpectating(playerid, false);
return 1;
}
I have skin id 285 which is cop skin, but i'm still in TEAM_CIV, when i should be TEAM_COP.
Somehow doesn't work. Even player colour isn't set. Why?
Re: Auto spawn -
Calisthenics - 03.09.2018
You set the team to TEAM_COP in the switch but after the switch you set the team to TEAM_CIV again. Remove that line.
Re: Auto spawn -
KinderClans - 03.09.2018
No. If you look better the code, i set the TEAM_COP JUST to some defined skin id's, other skins are set for TEAM_CIV.
Re: Auto spawn -
Calisthenics - 03.09.2018
Your code sets team to TEAM_CIV for all skins (even if the skin is cop, it sets to TEAM_COP and then TEAM_CIV again). If you want the other skins to be TEAM_CIV, then use
default: in the switch and set team there not after the switch.
Re: Auto spawn -
Shinja - 03.09.2018
As he said, you must use
default, its like
PHP код:
switch(x)
{
case y: //x=y
default: //x=anything else
}
//equivalent code:
if(x=y) //code
else //code
PHP код:
ProcessSpawn(playerid)
{
new skin = Player[playerid][Skin];
switch (skin)
{
case 280, 284, 285, 286, 306, 307, 309: //Cop
{
gTeam[playerid] = TEAM_COP;
SetPlayerToTeamColour(playerid);
SetPlayerTeam(playerid,1);
new rand = random(sizeof(RandomCopSpawns));
SetSpawnInfo(playerid, GetPlayerTeam(playerid), Player[playerid][Skin], RandomCopSpawns[rand][0],RandomCopSpawns[rand][1],RandomCopSpawns[rand][2], 270.0000, 0, 0, 0, 0, 0, 0);
TogglePlayerSpectating(playerid, false);
}
default:
{
gTeam[playerid] = TEAM_CIV;
SetPlayerToTeamColour(playerid);
SetPlayerTeam(playerid,0);
new rand = random(sizeof(RandomSpawnsLosSantos));
SetSpawnInfo(playerid, GetPlayerTeam(playerid), Player[playerid][Skin], RandomSpawnsLosSantos[rand][0],RandomSpawnsLosSantos[rand][1],RandomSpawnsLosSantos[rand][2], 270.0000, 0, 0, 0, 0, 0, 0);
TogglePlayerSpectating(playerid, false);
}
}
return 1;
}
Re: Auto spawn -
KinderClans - 04.09.2018
Bump.
Re: Auto spawn -
KinderClans - 05.09.2018
Fixed.