15.11.2016, 18:18
I have tried creating a dept radio system which includes two factions, but the problem is the following thing, the first faction which is the police one can use the command and receive messages from the other faction, but the second faction doesn't see what they type in the shared chat and can not receive any messages from the second faction. This is the code.
I ran out of any ideas on what could be the problem so if possible, help me out.
Edit 1: Seems like the third faction which is not even included here can see the chat too.
PHP код:
#define SendSplitMessageF(%1,%2,%3) SendSplitMessage(%1, %2, (format(sgstr, sizeof(sgstr), %3), sgstr))
new sgstr[256];
if(strcmp(cmd, "/dept", true) == 0 || strcmp(cmd, "/dr", true) == 0)
{
new length = strlen(cmdtext);
new name[24], string[256];
new DeptName[10];
GetPlayerName(playerid, name, sizeof(name));
while ((idx < length) && (cmdtext[idx] <= ' ')){idx++;}
new offset = idx,result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))){result[idx - offset] = cmdtext[idx];idx++;}
result[idx - offset] = EOS;
if(!strlen(result))return SendClientMessage(playerid, red, "USAGE: /dr [text]");
if(gTeam[playerid] == POLICE) DeptName = "SASP";
else if(gTeam[playerid] == AP) DeptName = "SACFD";
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(gTeam[i] == POLICE)
SendSplitMessageF(i, COLOR_ORANGE, "[%s] %s says: %s", DeptName, name, result);
continue;
}
if(gTeam[i] == AP)
{
SendSplitMessageF(i, COLOR_ORANGE, "[%s] %s says: %s", DeptName, name, result);
continue;
}
format(gstr, sizeof(gstr), "%s says (dept. radio): %s", name, result);
ProxDetector(15.0, playerid, gstr, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
return 1;
}
}
stock SendSplitMessage(playerid, color, msg[])
{
new ml = 115, result[160], len = strlen(msg), repeat;
if(len > ml)
{
repeat = (len / ml);
for(new i = 0; i <= repeat; i++)
{
result[0] = 0;
if(len - (i * ml) > ml)
{
strmid(result, msg, ml * i, ml * (i+1));
format(result, sizeof(result), "%s", result);
}
else
{
strmid(result, msg, ml * i, len);
format(result, sizeof(result), "%s", result);
}
SendClientMessage(playerid, color, result);
}
}
else
{
SendClientMessage(playerid, color, msg);
}
return true;
}
Edit 1: Seems like the third faction which is not even included here can see the chat too.