"Admin chat"
#1

So, i found this tutorial:
https://sampforum.blast.hk/showthread.php?tid=335123
And following it, i wanted to create an admin chat..
Well, it all worked greatly, till i added that stock and "SendMessageToAdmins(msg);"..
Script:
Код:
public OnPlayerText(playerid,text[])
{
	if(IsPlayerAdmin(playerid) && text[0] == '#')
    {
    	new msg[128], pName[MAX_PLAYER_NAME];
     	GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
      	format(msg, sizeof(msg), "[ADMIN CHAT] %s: %s", pName, text[1]);
      	SendMessageToAdmins(msg); //Due to this stock thing get an error, i think.
    }
	return 1;
}
Stock:

Код:
stock SendMessageToAdmins(text[])
{
    for(new i = 0, i < MAX_PLAYERS, i++)
    {
        if(IsPlayerAdmin(i))
        {
            SendClientMessage(i, -1, text);
        }
    }
}
When i compile it, i get this:

test.pwn(1999) : error 021: symbol already defined: "i"
test.pwn(1999) : warning 204: symbol is assigned a value that is never used: "i"
Line 1999:

for(new i = 0, i < MAX_PLAYERS, i++)
I have tried changing the 'names' removing other stuff.. but, ugh.. nothing worked.
Reply
#2

Код:
	if(PlayerInfo[playerid][power])
	{
		new iReason[ 128 ];
		if( sscanf ( params, "s", iReason))  return SCP(playerid, "[message]");
		format(iStr,sizeof(iStr),"{ [Admin] %s %s: %s }",AdminLevelName(playerid), RPName(playerid), iReason);
		PlayerLoop(qqq) if(PlayerInfo[qqq][power]) SendMessageToPlayer(qqq,COLOR_ADMINCHAT,iStr);
		format( iStr, sizeof(iStr), "7{ [ADMIN] %s %s: %s }",AdminLevelName(playerid), PlayerName(playerid), iReason);
		iEcho( iStr );
	}
Try this, if it helped you +rep

Reply
#3

I don't have.. those kind of plugins..
Im using sscanf2 and zcmd only..
Reply
#4

pawn Код:
stock SendMessageToAdmins(text[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerAdmin(i))
        {
            SendClientMessage(i, -1, text);
        }
    }
}
Reply
#5

Thanks Eires, compilings works.
In-Game too [well, currently].
Repped :]
EDIT: I get 2 messages when i type something..
For an example ->
Код:
[21:22:32] <Kyance> #lol
[21:22:35] Kyance is now on Admin-Duty!
[21:22:35] I suggest you to read /acmds.
[21:22:35] If you want more weapons, use /givegun.
[21:22:35] Just don't abuse your commands
[21:22:35] SERVER: You are logged in as admin.
[21:22:35] An admin spawned.
[21:22:36] [ADMIN CHAT] Kyance: lol
[21:22:36] <Kyance> #lol
Reply
#6

Np

The error was that you were using a comma instead of a semi colon while setting the parameters of the for loop.
I will mark the areas with '/*<*/'.
pawn Код:
stock SendMessageToAdmins(text[])
{
    for(new i = 0;/*<*/ i < MAX_PLAYERS;/*<*/ i++)
    {
        if(IsPlayerAdmin(i))
        {
            SendClientMessage(i, -1, text);
        }
    }
}
So beside the '0', and beside the 'MAX_PLAYERS'.
Reply
#7

Quote:
Originally Posted by Kyance
Посмотреть сообщение
Thanks Eires, compilings works.
In-Game too [well, currently].
Repped :]
EDIT: I get 2 messages when i type something..
For an example ->
Код:
[21:22:32] <Kyance> #lol
[21:22:35] Kyance is now on Admin-Duty!
[21:22:35] I suggest you to read /acmds.
[21:22:35] If you want more weapons, use /givegun.
[21:22:35] Just don't abuse your commands
[21:22:35] SERVER: You are logged in as admin.
[21:22:35] An admin spawned.
[21:22:36] [ADMIN CHAT] Kyance: lol
[21:22:36] <Kyance> #lol
Sorry, but /bumping this..
Reply
#8

Well that occurs because you're using OnPlayerText.

Most people would use a command for admin chat and that problem is disabled.
For example(using ZCMD and sscanf).
pawn Код:
CMD:achat(playerid,params[])
{
   if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"ERROR: You are not an administrator!");
   new msg[128], string[128],pName[MAX_PLAYER_NAME];
   if(sscanf(params,"s[128]",msg)) return SendClientMessage(playerid,-1,"USAGE: /achat [message]");
   GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
   format(string,sizeof(string),"[ADMIN CHAT] %s: %s",pName,msg);
   SendMessageToAdmins(string);
   return 1;
}
Reply
#9

Works, thanks again, Eires!
Reply
#10

Np
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)