Police radio -
stix - 02.11.2012
Can someone tell me how to do so when a cop uses the police radio people around him will see the message except him so he hasn't to see it twice ?
I use proxdetector but it sends also to the cop so he receives the message twice
Re: Police radio -
vIBIENNYx - 02.11.2012
Show me the code that you have now, and I'll do it for you.
Re: Police radio -
simstosh - 02.11.2012
You can do a "RadioCopSenderMessage[playerid]" or something like that to define if he sends the message or not, and put inside a "always running" timer to set to 0 after send the message via ProxDetector.
Respuesta: Police radio -
stix - 02.11.2012
pawn Код:
if(strcmp(cmd, "/ra", true) == 0 || strcmp(cmd, "/pr", true) == 0)
{
new string[128];
if(PlayerData[playerid][LSPDRank] < 1) return SendClientMessage(playerid, GRAY, "You must be a Trainee / Agent Trainee or higher to use this command !");
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[128];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(PlayerData[playerid][Radio] == 0) return SendClientMessage(playerid, GRAY, "You do not have a police radio !");
{
if(PlayerData[playerid][Duty] == 0) return SendClientMessage(playerid,GRAY, "You are not on police duty ! ");
{
if(!strlen(result)) return SendClientMessage(playerid, GRAY, "Function: (/ra)dio [ text ]");
{
if(PlayerData[playerid][Frequency] == 0) return 1;
{
new tmp[192];
GetPlayerName(playerid, tmp, sizeof(tmp));
for(new i = 0; i < MAX_PLAYERS; i++)
if(PlayerData[i][LSPDRank] == 1 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Trainee %s : %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 2 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Academy Cadet %s : %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 3 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Police Cadet %s : %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 4 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Police Officer %s : %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 5 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Senior Lead Officer %s : %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 6 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Sergeant %s %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 7 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Lieutenant %s : %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 8 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Captain %s : %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 9 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Police Commander %s : %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 10 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Co-Chief %s : %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 11 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
format(string, sizeof(string), "[LSPD Radio] Police Chief %s : %s , over.", tmp, result);
for(new i = 0; i < MAX_PLAYERS; i++)
SendClientMessage(i,GRAY,string);
for(new i = 0; i < MAX_PLAYERS; i++)
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
}
}
}
}
}
Re: Police radio -
Eric - 02.11.2012
Easiest way is to get the players coordinates (that uses the radio command), and create loop through all of the players. Check how close they are to the players coordinates (IsPlayerInRangeOfPoint(x, 5.0, PosX, PosY, PosZ), and also check if x == playerid. If it does, return. Else, SendClientMessage(x, GRAY, "* %s", radioString);
Obviously you need to tweak the above functions to match your variables.
Re: Police radio -
Eric - 02.11.2012
pawn Код:
if(strcmp(cmd, "/ra", true) == 0 || strcmp(cmd, "/pr", true) == 0)
{
new string[128];
if(PlayerData[playerid][LSPDRank] < 1) return SendClientMessage(playerid, GRAY, "You must be a Trainee / Agent Trainee or higher to use this command !");
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[128];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(PlayerData[playerid][Radio] == 0) return SendClientMessage(playerid, GRAY, "You do not have a police radio !");
{
if(PlayerData[playerid][Duty] == 0) return SendClientMessage(playerid,GRAY, "You are not on police duty ! ");
{
if(!strlen(result)) return SendClientMessage(playerid, GRAY, "Function: (/ra)dio [ text ]");
{
if(PlayerData[playerid][Frequency] == 0) return 1;
{
new tmp[192],
Float: PosFloat[3];
GetPlayerPos(playerid, PosFloat[1], PosFloat[2], PosFloat[3]);
GetPlayerName(playerid, tmp, sizeof(tmp));
for(new i = 0; i < MAX_PLAYERS; i++)
if(IsPlayerInRangeOfPoint(i, 5.0, PosFloat[1], PosFloat[2], PosFloat[3]) && i != playerid) {
SendClientMessage(i, GRAY, "%s: %s, over.", tmp, result);
}
if(PlayerData[i][LSPDRank] == 1 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Trainee %s : %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 2 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Academy Cadet %s : %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 3 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Police Cadet %s : %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 4 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Police Officer %s : %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 5 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Senior Lead Officer %s : %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 6 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Sergeant %s %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 7 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Lieutenant %s : %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 8 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Captain %s : %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 9 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Police Commander %s : %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 10 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
{
format(string, sizeof(string), "[LSPD Radio] Co-Chief %s : %s , over.", tmp, result);
SendClientMessage(i,GRAY,string);
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
else if(PlayerData[i][LSPDRank] == 11 && PlayerData[i][Frequency] == 1 && PlayerData[i][Radio] == 1)
format(string, sizeof(string), "[LSPD Radio] Police Chief %s : %s , over.", tmp, result);
for(new i = 0; i < MAX_PLAYERS; i++)
SendClientMessage(i,GRAY,string);
for(new i = 0; i < MAX_PLAYERS; i++)
ProxDetector(4.0, i, string, GRAY, GRAY, GRAY, GRAY, GRAY);
return 1;
}
}
}
}
}
}
Try that.
Respuesta: Police radio -
stix - 02.11.2012
Can't i just use get distance between players ?
Re: Respuesta: Police radio -
Eric - 02.11.2012
Quote:
Originally Posted by stix
Can't i just use get distance between players ?
|
You could, but those both have the exact same results.