admin chat help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: admin chat help (
/showthread.php?tid=245813)
admin chat help -
tanush - 02.04.2011
When i do /achat FUAUJPAOGJ it will show to everyone that is connected to server, please help
pawn Код:
CMD:achat(playerid, params[])
{
if(PlayerData[playerid][AdminLevel] > 0)
{
new iName[MAX_PLAYER_NAME],iStr[128];
if(isnull(params)) return SendClientMessage(playerid,0xFF9900AA,"USAGE: /achat [text]");
GetPlayerName(playerid,iName,sizeof(iName));
for(new i = 0; i < 10; ++i)
{
if(PlayerData[playerid][AdminLevel] > 0 && IsPlayerConnected(i) && !IsPlayerNPC(i))
{
format(iStr,sizeof(iStr),"[ADMIN CHAT] %s: %s",iName,params);
SendClientMessage(i,0xFF9900AA,iStr);
}
}
}
else return 0;
return 1;
}
Re: admin chat help -
Marricio - 02.04.2011
pawn Код:
CMD:achat(playerid, params[])
{
if(PlayerData[playerid][AdminLevel] > 0)
{
new iName[MAX_PLAYER_NAME],iStr[128];
if(isnull(params)) return SendClientMessage(playerid,0xFF9900AA,"USAGE: /achat [text]");
GetPlayerName(playerid,iName,sizeof(iName));
for(new i = 0; i < MAX_PLAYERS; ++i) // i recommend using Foreach
{
if(PlayerData[i][AdminLevel] > 0 && IsPlayerConnected(i) && !IsPlayerNPC(i))
{
format(iStr,sizeof(iStr),"[ADMIN CHAT] %s: %s",iName,params);
SendClientMessage(i,0xFF9900AA,iStr);
}
}
}
else return 0;
return 1;
}
Re: admin chat help -
Joe Staff - 02.04.2011
pawn Код:
CMD:achat(playerid, params[])
{
if(PlayerData[playerid][AdminLevel] > 0)
{
if(isnull(params)) return SendClientMessage(playerid,0xFF9900AA,"USAGE: /achat [text]");
new iStr[128+MAX_PLAYER_NAME+15]; //Place variables after error check -- Use only 1 appropriately sized string instead of 2
GetPlayerName(playerid,iStr,24); //Switch iName with iStr
format(iStr,sizeof(iStr),"[ADMIN CHAT] %s: %s",iStr,params); //format string BEFORE loop -- replace iName with iStr
for(new i = 0; i < MAX_PLAYERS; ++i) //Change 10 to MAX_PLAYERS
{
if((PlayerData[i][AdminLevel] > 0) && IsPlayerConnected(i) && !IsPlayerNPC(i)) //Change playerid to i -- Enclose conditionals appropriately
{
SendClientMessage(i,0xFF9900AA,iStr);
}
}
}
else return 0;
return 1;
}