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=0i<MAX_PLAYERSi++)
    {
        if (
pInfo[i][Admin] >= 1)
        {
            
SendClientMessage(icolormsg);
        }
    }
}
public 
OnPlayerText(playeridtext[])
{
    
    if(
text[0] == '@' && pInfo[i][Admin] >= 1)
    {
        new 
string[128];
        
format(pnamesizeof(string), "{47476B}(ADMIN CHAT) {FFFFFF}%s: %s"PlayerName[playerid], text[1]);
        
SendMessageToAdmins(-1string);
        return 
0;
    }
    return 
0;

Reply
#3

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

public 
OnPlayerText(playeridtext[])
{
    
    if(
text[0] == '@' && pInfo[i][Admin] >= 1)
    {
         new 
pname[128], string[120];
        
GetPlayerName(playeridpnamesizeof(pname));
        
format(stringsizeof(string), "{47476B}(ADMIN CHAT) {FFFFFF}%s: %s"pnametext[1]);
        
SendMessageToAdmins(-1string);
        return 
0;
    }
    return 
0;

This would work perfectly
Reply
#4

PHP код:
    if(text[0] == '@' && pInfo[playerid][Admin] < 1)
    {
        new 
str[128];
        
format(strsizeof(str), "{F781F3}(ADMIN CHAT) %s(%d): %s"PlayerName[playerid],playeridtext);
        foreach(new 
Player)
        {
            if(
pInfo[playerid][Admin] > 0)
            {
                
SendClientMessage(i, -1str);
            }
        }
        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=0i<MAX_PLAYERSi++)
    {
        if (
pInfo[i][Admin] >= 1)
        {
            
SendClientMessage(icolormsg);
        }
    }
}
public 
OnPlayerText(playeridtext[])
{
    
    if(
text[0] == '@' && pInfo[i][Admin] >= 1)
    {
         new 
pname[128], string[120];
        
GetPlayerName(playeridpnamesizeof(pname));
        
format(stringsizeof(string), "{47476B}(ADMIN CHAT) {FFFFFF}%s: %s"pnametext[1]);
        
SendMessageToAdmins(-1string);
        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(playeridtext[])
{
    new 
pText[144];
    
format(pTextsizeof (pText), "(%d) %s"playeridtext);
    
SendPlayerMessageToAll(playeridpText);
    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=0i<MAX_PLAYERSi++)
    {
        if (
pInfo[i][Admin] >= 1)
        {
            
SendClientMessage(icolormsg);
        }
    }
}
public 
OnPlayerText(playeridtext[])
{
    
    if(
text[0] == '@' && pInfo[i][Admin] >= 1)
    {
         new 
pname[128], string[120];
        
GetPlayerName(playeridpnamesizeof(pname));
        
format(stringsizeof(string), "{47476B}(ADMIN CHAT) {FFFFFF}%s: %s"pnametext[1]);
        
SendMessageToAdmins(-1string);
        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 Player) if(pInfo[i][Admin] >= 1SendClientMessage(icolormsg);
public 
OnPlayerText(playeridtext[])

    if(
text[0] == '@' && pInfo[i][Admin] >= 1)
    {
        
string[124];
        
GetPlayerName(stringstringMAX_PLAYER_NAME);
        
format(stringsizeof(string), "(ADMIN CHAT) {FFFFFF}%s: %s"stringtext[1]);
        
SendMessageToAdmins(0x47476BFFstring);
        return 
0;
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)