How would I do this?
#1

I want to have a command /cm for cops only. If a cop types /cm it will send a client message to all other police and no one else. If a regular player tries to type /cm then they get the an message. Thanks in advance for help!
Reply
#2

Use a loop to check if they are a cop and then send the message.

EXAMPLE:

pawn Код:
for(new i=0; i<MAX_PLAYERS; i++)
{
  if(gTeam[i] == TEAM_COP)
  {
    SendClientMessage(i,COLOR,cmdtext[4]);
  }
}
Reply
#3

Quote:
Originally Posted by Mikep
Use a loop to check if they are a cop and then send the message.

EXAMPLE:

pawn Код:
for(new i=0; i<MAX_PLAYERS; i++)
{
  if(gTeam[i] == TEAM_COP)
  {
    SendClientMessage(i,COLOR,cmdtext[4]);
  }
}
Ah thanks a lot mike!
Reply
#4

Quote:
Originally Posted by Mikep
Use a loop to check if they are a cop and then send the message.

EXAMPLE:

pawn Код:
for(new i=0; i<MAX_PLAYERS; i++)
{
  if(gTeam[i] == TEAM_COP)
  {
    SendClientMessage(i,COLOR,cmdtext[4]);
  }
}
why do most you guys use MAX_PLAYERS instead of GetMaxPlayers()?
Reply
#5

if you ask me that question, i can answer this in all ease;

why would we? we want a server that runs with max players without problems, I always assume that the target server will try to handle 200 players instead of the one configured.

in this case, it doesnt matter to the server in scripting if you have opened 200 slots, or standard 32,

basicly, its like a debug, if it runs without problems, then i can open all 200 slots without problems IF computer requirements are OK;

again, this is in my case;
Reply
#6

MAX_PLAYERS is a pre-defined value, which makes comparing two values simple. When you use the function GetMaxPlayers(), the value isn't known in advance, so every time the loop is called (200 times max), it has to execute the function and see if the condition (i < GetMaxPlayers()) is still true.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)