SendClientMessageToAllCops [rep+] -
Chriham3 - 27.10.2011
Hello. I want to do a system that I can write for example: "SendClientMessageToAllCops(COLOR_RED, "The bank in Las Venturas has been robbed - get there immediatly");"
The definition of cops in my server is:
.
I'd really appreciate some help
I'll rep for anyone who helps me.
Re: SendClientMessageToAllCops [rep+] -
grand.Theft.Otto - 27.10.2011
I use something similar:
pawn Код:
// bottom of script
stock FindTeam(playerid)
{
new Team = GetPVarInt(playerid,"Team");
return Team;
}
// bottom of script
forward MessageToCops(color,const string[]);
public MessageToCops(color,const string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
new Team = FindTeam(i);
if(IsPlayerConnected(i))
{
if(Team == TEAM_COPS)
{
SendClientMessage(i,color,string);
}
}
}
return 1;
}
Then for your message when the robber robs the bank, for example:
pawn Код:
new string[128], name[24]; // name will be the robbers name
GetPlayerName(playerid,name,24);
format(string,128,"Attention All Units! The Bank In Las Venturas Has Been Robbed By %s!",name);
MessageToCops(your_color,string);
Re: SendClientMessageToAllCops [rep+] -
Biesmen - 27.10.2011
You could use the following:
pawn Код:
stock SendClientMessageToAllCops(color[], message[])
{
for(new i=0; i < MAX_PLAYERS; i++)
{
if(GetPlayerTeam(i) == TEAM_COPS)
{
SendClientMessage(i, color, message);
}
}
return 1;
}
Then you can use this line:
pawn Код:
SendClientMessageToAllCops(COLOR_RED, "The bank in Las Venturas has been robbed - get there immediatly");
I have to say, my stock is better than the one above mine, because for his 'system' you'll have to set a variable for the players, with my stock you don't have to do anything except what you already did, setting the players to a team. (SetPlayerTeam)
Re: SendClientMessageToAllCops [rep+] -
Chriham3 - 27.10.2011
I got C:\Users\Chuck Norris\Desktop\samp\gamemodes\Scratch.pwn(32) : error 035: argument type mismatch (argument 2)
Argument 2 = color
Re: SendClientMessageToAllCops [rep+] -
[MWR]Blood - 27.10.2011
pawn Код:
stock SendClientMessageToAllCops(color, const message[])
{
for(new i=0; i < MAX_PLAYERS; i++)
{
if(GetPlayerTeam(i) == TEAM_COPS)
{
SendClientMessage(i, color, message);
}
}
return 1;
}
Re: SendClientMessageToAllCops [rep+] -
.:Kaos:. - 27.10.2011
Why use loops? "foreach" is so much more efficient. Simply replace
Код:
for(new i=0; i < MAX_PLAYERS; i++)
with,
If you don't know, you can find
foreach here. Or the direct download for it
here..
Re: SendClientMessageToAllCops [rep+] -
Biesmen - 28.10.2011
Quote:
Originally Posted by [MWR]Blood
pawn Код:
stock SendClientMessageToAllCops(color, const message[]) { for(new i=0; i < MAX_PLAYERS; i++) { if(GetPlayerTeam(i) == TEAM_COPS) { SendClientMessage(i, color, message); } } return 1; }
|
I think someone here doesn't know what const is and that colors are strings.
Re: SendClientMessageToAllCops [rep+] -
Wesley221 - 28.10.2011
Actually a color is an integer

Try to use it with color[], and then with color, you will see you get an error (Probably a tag mismatch not sure about that though)
Re: SendClientMessageToAllCops [rep+] -
SloProKiller - 28.10.2011
Quote:
Originally Posted by Wesley221
Actually a color is an integer 
Try to use it with color[], and then with color, you will see you get an error (Probably a tag mismatch not sure about that though)
|
Actually it's a hexadecimal number, not an integer.