Help in Admin chat command
#1

Hello Guyz
How can i make Admin chat command
When i type @ [Text]
It goes to all admin(Who are online)
Not dcmd,zcmd
Reply
#2

pawn Код:
public OnPlayerText(playerid, text[]) // Since OnPlayerCommandText only recognises commands with the prefix of /, we need to use OnPlayerText.
{
    if(text[0] == '@' && IsPlayerAdmin(playerid)) // If the first character of the text string equals '@' AND is the person who sent the text an admin?
    {
        new
            TextOutput[128], SenderName[MAX_PLAYER_NAME]; // Creating a couple of variables to store the completed string & the player's name.
           
        text[0] = ' '; // Replacing the @ with space
        GetPlayerName(playerid, SenderName, sizeof(SenderName)); // Getting the player's name
       
        format(TextOutput, sizeof(TextOutput), "%s:%s", SenderName, text); // Formatting the output string, since text[0] is now a space, an example output would be 'James: Hello'
   
        for(new i; i < MAX_PLAYERS; i++) // Replace with foreach if you're using it.
        {
            if(IsPlayerAdmin(i)) SendClientMessage(i,0xFFFFFFFF,TextOutput); // Send the text if the i is an admin. (Will send to the sender aswell.)
        }
   
        return 0; // Don't send the message publicly.
    }
    return 1;
}
Untested, but I've explained how it works.
Reply
#3

Try it:

pawn Код:
if(!strcmp(cmdtext, "/chat", true, 4))
    {
        if(!cmdtext[4])return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /chat [text]");
        new str[128];
        GetPlayerName(playerid, str, sizeof(str));
        format(str, sizeof(str), "* %s %s", str, cmdtext[5]);
        SendClientMessageToAll(0xFFFF00AA, str);
        return 1;
    }
Reply
#4

Quote:
Originally Posted by Montis123
Посмотреть сообщение
Try it:

pawn Код:
Shiz
Please read about the problem before aimlessly copying and pasting code from your script.
Reply
#5

Not working
When i type @ any text
Every one can see
Reply
#6

Quote:
Originally Posted by BASITJALIL
Посмотреть сообщение
Not working
When i type @ any text
Every one can see
Are you using rcon or a variable that contains whether the player is an admin or not?

If you're using a custom admin function / variable, change IsPlayerAdmin to that.
Reply
#7

Sorry but i dont understand
Pm Me the Full Pawn code
If you can
Reply
#8

if(strcmp(cmd, "/admin", true) == 0 || strcmp(cmd, "/a", true) == 0)
{
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "Usage: (/a)dmin [admin chat]");
return 1;
}

new arank[64];
if(PlayerInfo[playerid][pAdmin] == 1) { arank = "Moderator"; }
else if(PlayerInfo[playerid][pAdmin] == 2) { arank = "Level 2 Admin"; }
else if(PlayerInfo[playerid][pAdmin] == 3) { arank = "Level 3 Admin"; }
else if(PlayerInfo[playerid][pAdmin] == 4) { arank = "Level 4 Admin"; }
else if(PlayerInfo[playerid][pAdmin] == 1337) { arank = "Head Admin"; }
else if(PlayerInfo[playerid][pAdmin] == 133 { arank = "Scripter"; }
else if(PlayerInfo[playerid][pAdmin] == 1339) { arank = "Co-Owner"; }
else if(PlayerInfo[playerid][pAdmin] == 1340) { arank = "Owner"; }
else { arank = "Moderator"; }

format(string, sizeof(string), "*** %s %s *** %s", arank, sendername, result);
if (PlayerInfo[playerid][pAdmin] >= 1)
{
SendAdminMessage(COLOR_YELLOW, string);
}
printf("Admin %s: %s", sendername, result);
}
return 1;
}
Reply
#9

Please use pawn tag's.

pawn Код:
if(strcmp(cmd, "/admin", true) == 0 || strcmp(cmd, "/a", true) == 0)
{
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "Usage: (/a)dmin [admin chat]");
return 1;
}

new arank[64];
if(PlayerInfo[playerid][pAdmin] == 1) { arank = "Moderator"; }
else if(PlayerInfo[playerid][pAdmin] == 2) { arank = "Level 2 Admin"; }
else if(PlayerInfo[playerid][pAdmin] == 3) { arank = "Level 3 Admin"; }
else if(PlayerInfo[playerid][pAdmin] == 4) { arank = "Level 4 Admin"; }
else if(PlayerInfo[playerid][pAdmin] == 1337) { arank = "Head Admin"; }
else if(PlayerInfo[playerid][pAdmin] == 133 { arank = "Scripter"; }
else if(PlayerInfo[playerid][pAdmin] == 1339) { arank = "Co-Owner"; }
else if(PlayerInfo[playerid][pAdmin] == 1340) { arank = "Owner"; }
else { arank = "Moderator"; }

format(string, sizeof(string), "*** %s %s *** %s", arank, sendername, result);
if (PlayerInfo[playerid][pAdmin] >= 1)
{
SendAdminMessage(COLOR_YELLOW, string);
}
printf("Admin %s: %s", sendername, result);
}
return 1;
}
So much more readable don't you think ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)