Random team spawns!
#6

Quote:
Originally Posted by Dawkin
Посмотреть сообщение
new Float:RandomSpawnSWAT[6][3]
new Float:RandomSpawnSWAT[4][3]

Try it ? I dont know this will be work or not because I'm newbie too XD
It won't, the second dimension is 4 indexes (x, y, z, a). Furthermore, you don't really need to specify the size before declaring an array with initialization data. PAWN automatically determines the size it needs.

The error is in the logic where you check the team of the player.

The functions return 1 when the player is in that specific team (eg. FBI), however you compare them with the actual Team ID of the player:

Код:
if(gTeam[playerid] == Army(GetPlayerSkin(playerid)))
It should be

Код:
if(Army(GetPlayerSkin(playerid)))
So if that skin is an army skin it will return 1 and execute that part.

If you falsely compare it with the Team of the player, a player of team 0 cannot get any of these spawns.

You could either check the Team of a player, or the Skin. But don't compare these with each other because that doesn't make sense.


Код:
if(PoliceTeam(GetPlayerSkin(playerid)) || FBII(GetPlayerSkin(playerid)))
    {
        new RandomSpawnP = random(sizeof(RandomSpawnPolice));
        SetPlayerPos(playerid, RandomSpawnPolice[RandomSpawnP][0], RandomSpawnPolice[RandomSpawnP][1], RandomSpawnPolice[RandomSpawnP][2]);
        SetPlayerFacingAngle(playerid, RandomSpawnPolice[RandomSpawnP][3]);
    }
    if(CIA(GetPlayerSkin(playerid)))
    {
        new RandomSpawnC = random(sizeof(RandomSpawnCIA));
        SetPlayerPos(playerid, RandomSpawnCIA[RandomSpawnC][0], RandomSpawnCIA[RandomSpawnC][1], RandomSpawnCIA[RandomSpawnC][2]);
        SetPlayerFacingAngle(playerid, RandomSpawnCIA[RandomSpawnC][3]);
    }
    if(Army(GetPlayerSkin(playerid)))
    {
        new RandomSpawnA = random(sizeof(RandomSpawnArmy));
        SetPlayerPos(playerid, RandomSpawnArmy[RandomSpawnA][0], RandomSpawnArmy[RandomSpawnA][1], RandomSpawnArmy[RandomSpawnA][2]);
        SetPlayerFacingAngle(playerid, RandomSpawnArmy[RandomSpawnA][3]);
    }
    if(SWAT(GetPlayerSkin(playerid)))
    {
        new RandomSpawnS = random(sizeof(RandomSpawnSWAT));
        SetPlayerPos(playerid, RandomSpawnSWAT[RandomSpawnS][0], RandomSpawnSWAT[RandomSpawnS][1], RandomSpawnSWAT[RandomSpawnS][2]);
        SetPlayerFacingAngle(playerid, RandomSpawnSWAT[RandomSpawnS][3]);
    }
Also changed the FBI and Police check, you probably wanted to check if the team is Police or FBI?

You could however make this whole thing a bit better and easier. Instead of comparing each skin seperately, you could use ONE function to determine the team by skin and then get the player's Team ID and set their spawn accordingly.

eg.

Код:
#define TEAM_ARMY 1
#define TEAM_COPS 2
#define TEAM_SOMETHING 3

GetPlayerTeamBySkin(playerid)
{
switch(GetPlayerSkin(playerid)
{
case 289: return TEAM_ARMY; // Not the actual IDs, just examples
case 285: return TEAM_COPS;
case 260, 261, 262: return TEAM_SOMETHING;
}
return 0;
}
Which would be a lot easier to use than writing 8 functions for 8 team and copy-pasting the same code around everytime.
Reply


Messages In This Thread
Random team spawns! - by Thanks - 30.07.2018, 13:36
Re: Random team spawns! - by Thanks - 30.07.2018, 17:14
Re: Random team spawns! - by Dawkin - 30.07.2018, 17:15
Re: Random team spawns! - by Thanks - 30.07.2018, 17:17
Re: Random team spawns! - by Dawkin - 30.07.2018, 17:21
Re: Random team spawns! - by NaS - 30.07.2018, 17:55
Re: Random team spawns! - by Thanks - 30.07.2018, 19:16

Forum Jump:


Users browsing this thread: 3 Guest(s)