alias:tchat("t");
CMD:tchat(playerid,params[])
{
new Testerstring[257];
if(pInfo[playerid][Tester] >= 1 || pInfo[playerid][pAdminLevel] >= 1)
{
if(!strlen(params))
{
SendClientMessage(playerid, -1, ""COL_RED"TesterCmd: /tchat [Text]");
return 1;
}
format(Testerstring, sizeof(Testerstring), ""COL_GREEN"[Tester Chat] %s %s[%d]: %s",GetTesterName(playerid),PlayerName(playerid), playerid, params);
SendMessageToAllTesters(Testerstring, -1);
}
if(pInfo[playerid][pAdminLevel] >= 1)
{
if(!strlen(params))
{
SendClientMessage(playerid, -1, ""COL_RED"TesterCmd: /tchat [Mesaj]");
return 1;
}
format(Testerstring, sizeof(Testerstring), ""COL_GREEN"[Tester Chat] %s %s[%d]: %s",GetAdminName(playerid),PlayerName(playerid), playerid, params);
SendMessageToAllTesters(Testerstring, -1);
}
else {
SendClientMessage(playerid,-1,""COL_RED"EROARE: You are not admin or tester!");
}
return 1;
}
if(pInfo[playerid][pAdminLevel] >= 1) { if(!strlen(params)) { SendClientMessage(playerid, -1, ""COL_RED"TesterCmd: /tchat [Mesaj]"); return 1; } format(Testerstring, sizeof(Testerstring), ""COL_GREEN"[Tester Chat] %s %s[%d]: %s",GetAdminName(playerid),PlayerName(playerid), playerid, params); SendMessageToAllTesters(Testerstring, -1); }
SendMessageToAllTesters(color, string2[]) { foreach(Player, i) { if(pInfo[playerid][Tester] >= 1 || pInfo[playerid][pAdminLevel] >= 1) { SendClientMessage(i, color, string2); } } return 1; } CMD:tchat(playerid, params[]) { if(pInfo[playerid][Tester] >= 1 || pInfo[playerid][pAdminLevel] >= 1) { new msg[128]; new Testerstring[257]; if(!sscanf(params, "s[128]", msg)) { format(Testerstring, sizeof(Testerstring), ""COL_GREEN"[Tester Chat] %s %s[%d]: %s",GetTesterName(playerid),PlayerName(playerid), playerid, params); SendMessageToAllTesters(Testerstring, -1); } else { SendClientMessage(playerid, -1, ""COL_RED"TesterCmd: /tchat [Text]"); } } else SendClientMessage(playerid,-1,""COL_RED"EROARE: You are not admin or tester!"); return 1; }
CMD:tchat(playerid,params[])
{
if(pInfo[playerid][pAdminLevel] < 1 && pInfo[playerid][Tester] < 1) return SendClientMessage(playerid, -1, ""COL_RED"EROARE: You are not admin or tester!");
if(!strlen(params)) return SendClientMessage(playerid, -1, ""COL_RED"TesterCmd: /tchat [Text]");
new Testerstring[144];
format(Testerstring, sizeof(Testerstring), ""COL_GREEN"[Tester Chat] %s %s[%d]: %s",
(pInfo[playerid][pAdminLevel]) ? (GetAdminName(playerid)) : (GetTesterName(playerid)), PlayerName(playerid), playerid, params);
SendMessageToAllTesters(Testerstring, -1);
return 1;
}
If player is not helper but admin, the statement will be true because of OR. Change it to AND. |
There is `isnull` macro, it is better checking first or second character than all of them (strlen). |
PHP код:
In your original code, you had two statements that queried whether the player was an admin, so if an admin was to use the command it would result in the message being sent twice. You should use 'return' to break the code to prevent it from continuing when you've achieved the result you want. |
PHP код:
In your original code, you had two statements that queried whether the player was an admin, so if an admin was to use the command it would result in the message being sent twice. You should use 'return' to break the code to prevent it from continuing when you've achieved the result you want. |
stock SendMessageToAllTesters(message[], color)
{
foreach(Player, i)
{
if(pInfo[i][Tester] >= 1 || pInfo[i][pAdminLevel] >=1)
{
SendClientMessage(i, color, message);
}
}
return 1;
}
if(pInfo[playerid][pAdminLevel] < 1 || pInfo[playerid][Tester] < 1) return SendClientMessage(playerid, -1, ""COL_RED"EROARE: You are not admin or tester!");
if(pInfo[playerid][pAdminLevel] < 1 && pInfo[playerid][Tester] < 1) return SendClientMessage(playerid, -1, ""COL_RED"EROARE: You are not admin or tester!");
SendMessageToAllTesters(string2[], color) { foreach(Player, i) { if(pInfo[i][Tester] < 1 || pInfo[i][pAdminLevel] < 1) { SendClientMessage(i, color, string2); } } } CMD:tchat(playerid, params[]) { if(pInfo[playerid][Tester] == 0) if(pInfo[playerid][pAdminLevel] == 0) return SendClientMessage(playerid,-1,""COL_RED"EROARE: You are not admin or tester!"); new msg[128]; new Testerstring[257]; if(sscanf(params, "s[128]", msg)) return SendClientMessage(playerid, -1, ""COL_RED"TesterCmd: /tchat [Text]"); format(Testerstring, sizeof(Testerstring), ""COL_GREEN"[Tester Chat] %s %s[%d]: %s",GetTesterName(playerid),PlayerName(playerid), playerid, msg); SendMessageToAllTesters(Testerstring, -1); return 1; }
SendTesterMessage(message[]) { for(new i; i < MAX_PLAYERS; i++) { if(PlayerData[i][pAdmin] > 0 || PlayerData[i][pTester] > 0) { SendClientMessage(i, -1, message); } } } CMD:tchat(playerid, params[]) { if(PlayerData[playerid][pAdmin] == 0 && PlayerData[playerid][pTester] == 0) return SendClientMessage(playerid, -1, "You are not an admin/tester."); if(isnull(params)) return SendClientMessage(playerid, -1, "CMD: /tchat [text]"); new testerMsg[128], pName[MAX_PLAYER_NAME+1]; GetPlayerName(playerid, pName, sizeof(pName)); format(testerMsg, sizeof(testerMsg), "[Tester Chat] %s: %s", pName, params); SendTesterMessage(testerMsg); return 1; }
if(PlayerData[playerid][pAdmin] > 0) format(testerMsg, sizeof(testerMsg), "[Tester Chat] %s %s: %s", GetAdminRank(playerid), pName, params); else format(testerMsg, sizeof(testerMsg), "[Tester Chat] %s %s: %s", GetTesterRank(playerid), pName, params);