[HELP] Restricting command to several teams
#1

Ok, I'm trying to restrict a command. First let me post the code then I'll explain a bit deeper.
pawn Код:
if(!strcmp(cmdtext, "/area51", true, 30))
    {
    if(gTeam[playerid] == TEAM_ARMY && gTeam[playerid] == TEAM_FBI && gTeam[playerid] == TEAM_SWAT) //check if the player is law enforcement
    {
            SetPlayerPos(playerid, -63.7372,1777.3805,17.2696);
            SendClientMessage(playerid, 0xFFFFFFFF, "Mission: Kill any terrorist you see, if any other law enforcement team attack you, kill them.");
    }
      else
      {
        SetPlayerPos(playerid, 3615.0876464844, 492.53094482422, 60.263984680176);
        SendClientMessage(playerid,0xFFFFFFFF,"Mission: Deffend the army base, don't let law enforcement set their foot inside."); //if no
        }
        return 1;
    }
As you can see I'm trying to make TEAM_ARMY, TEAM_FBI, TEAM_SWAT only being able to spawn at one location. And the rest of the teams (terrorists and civilians) should spawn at an other spot. The script compiles fine. But once I connect to my server and type /area51 I receive this: "Mission: Deffend the army base, don't let the law enforcement set their foot inside." and then I get teleported where to the civilians and terrorists should spawn.

Please don't say "search". Becuase I have, and still can't find what I'm looking for.

Thanks.
Reply
#2

change
Код:
if(gTeam[playerid] == TEAM_ARMY && gTeam[playerid] == TEAM_FBI && gTeam[playerid] == TEAM_SWAT)
to
Код:
if(gTeam[playerid] == TEAM_ARMY || gTeam[playerid] == TEAM_FBI || gTeam[playerid] == TEAM_SWAT)
and why do you need 30? 7 is enough ^^
Reply
#3

Tested some things, that's why I had 30. It works now, thank you.
Reply
#4

If you end up with a bunch of instances of this in your script:

if(gTeam[playerid] == TEAM_ARMY && gTeam[playerid] == TEAM_FBI && gTeam[playerid] == TEAM_SWAT)


You can combine them into one definition:

Код:
IsACop(playerid)
{
   if(gTeam[playerid] == TEAM_ARMY || gTeam[playerid] == TEAM_FBI || gTeam[playerid] == TEAM_SWAT) //check if the player is law enforcement
   {
      return 1;
   }
   return 0;
}
Because if(IsACop(playerid)) is alot more manageable and you can easily go back and edit the definition without retracing your steps 20 times throughout the script.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)