admin chat doesn't work
#1

I don't know why, it just doesn't work, it sends this message on global chat

"@ t"

and everyone can see it.

Код:
	if(text[0] == '@' && pInfo[playerid][Admin] < 1)
    {
        foreach(new i : Player)
 		{
	        new str[128];
	        format(str, sizeof(str), "{F781F3}(ADMIN CHAT) %s(%d): %s", PlayerName[playerid],playerid, str);
	        SendMessageToAdmins(str);
	        if(pInfo[playerid][Admin] > 0)
          {
   		        SendClientMessage(i, 0x66CC66FF, str);
          }
	    }
    }
    return 0;
}
Reply
#2

PHP код:
stock SendMessageToAdmins(color, const msg[])
{
    for (new 
i=0; i<MAX_PLAYERS; i++)
    {
        if (
pInfo[i][Admin] >= 1)
        {
            
SendClientMessage(i, color, msg);
        }
    }
}
public 
OnPlayerText(playerid, text[])
{
    
    if(
text[0] == '@' && pInfo[i][Admin] >= 1)
    {
        new 
string[128];
        
format(pname, sizeof(string), "{47476B}(ADMIN CHAT) {FFFFFF}%s: %s", PlayerName[playerid], text[1]);
        
SendMessageToAdmins(-1, string);
        return 
0;
    }
    return 
0;
} 
Reply
#3

PHP код:
stock SendMessageToAdmins(color, const msg[])
{
    for (new 
i=0; i<MAX_PLAYERS; i++)
    {
        if (
pInfo[i][Admin] >= 1)
        {
            
SendClientMessage(i, color, msg);
        }
    }
}

public 
OnPlayerText(playerid, text[])
{
    
    if(
text[0] == '@' && pInfo[i][Admin] >= 1)
    {
         new 
pname[128], string[120];
        
GetPlayerName(playerid, pname, sizeof(pname));
        
format(string, sizeof(string), "{47476B}(ADMIN CHAT) {FFFFFF}%s: %s", pname, text[1]);
        
SendMessageToAdmins(-1, string);
        return 
0;
    }
    return 
0;
} 
This would work perfectly
Reply
#4

PHP код:
    if(text[0] == '@' && pInfo[playerid][Admin] < 1)
    {
        new 
str[128];
        
format(str, sizeof(str), "{F781F3}(ADMIN CHAT) %s(%d): %s", PlayerName[playerid],playerid, text);
        foreach(new 
i : Player)
        {
            if(
pInfo[playerid][Admin] > 0)
            {
                
SendClientMessage(i, -1, str);
            }
        }
        return 
1;
    } 
Edit: I recommend you to use ZCMD it's much easy to make commands
Reply
#5

Quote:
Originally Posted by BulletRaja
Посмотреть сообщение
PHP код:
stock SendMessageToAdmins(color, const msg[])
{
    for (new 
i=0; i<MAX_PLAYERS; i++)
    {
        if (
pInfo[i][Admin] >= 1)
        {
            
SendClientMessage(i, color, msg);
        }
    }
}
public 
OnPlayerText(playerid, text[])
{
    
    if(
text[0] == '@' && pInfo[i][Admin] >= 1)
    {
         new 
pname[128], string[120];
        
GetPlayerName(playerid, pname, sizeof(pname));
        
format(string, sizeof(string), "{47476B}(ADMIN CHAT) {FFFFFF}%s: %s", pname, text[1]);
        
SendMessageToAdmins(-1, string);
        return 
0;
    }
    return 
0;
} 
This would work perfectly
Why copying the code i already posted? LOL
Reply
#6

Quote:
Originally Posted by RxErT
Посмотреть сообщение
Why copying the code i already posted? LOL
check it i edited it
Reply
#7

Now he can't send messages normally at all. so use return 1 at the end of callback.
Reply
#8

Quote:
Originally Posted by AroseKhanNiazi
Посмотреть сообщение
Now he can't send messages normally at all. so use return 1 at the end of callback.
Nice joke;

PHP код:
public OnPlayerText(playerid, text[])
{
    new 
pText[144];
    
format(pText, sizeof (pText), "(%d) %s", playerid, text);
    
SendPlayerMessageToAll(playerid, pText);
    return 
0; // ignore the default text and send the custom one
} 
https://sampwiki.blast.hk/wiki/OnPlayerText
Reply
#9

Quote:
Originally Posted by BulletRaja
Посмотреть сообщение
check it i edited it
You do realize that pname only needs to be 32 or some shit, not 128... Bad editing...
Reply
#10

Quote:
Originally Posted by BulletRaja
Посмотреть сообщение
PHP код:
stock SendMessageToAdmins(color, const msg[])
{
    for (new 
i=0; i<MAX_PLAYERS; i++)
    {
        if (
pInfo[i][Admin] >= 1)
        {
            
SendClientMessage(i, color, msg);
        }
    }
}
public 
OnPlayerText(playerid, text[])
{
    
    if(
text[0] == '@' && pInfo[i][Admin] >= 1)
    {
         new 
pname[128], string[120];
        
GetPlayerName(playerid, pname, sizeof(pname));
        
format(string, sizeof(string), "{47476B}(ADMIN CHAT) {FFFFFF}%s: %s", pname, text[1]);
        
SendMessageToAdmins(-1, string);
        return 
0;
    }
    return 
0;
} 
This would work perfectly
He is using foreach, so it would be better if the script was for foreach. You don't need an extra pname.
One thing I learned from your code is, that this text[1] using with %s will print whole string after that spot so thanks for this

PHP код:
SendMessageToAdmins(color, const msg[]) foreach(new i : Player) if(pInfo[i][Admin] >= 1) SendClientMessage(i, color, msg);
public 
OnPlayerText(playerid, text[])
{ 
    if(
text[0] == '@' && pInfo[i][Admin] >= 1)
    {
        
string[124];
        
GetPlayerName(string, string, MAX_PLAYER_NAME);
        
format(string, sizeof(string), "(ADMIN CHAT) {FFFFFF}%s: %s", string, text[1]);
        
SendMessageToAdmins(0x47476BFF, string);
        return 
0;
    }
    return 
1;
} 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)