An admin chat? ґ+REPP
#1

Hello guys, I tried to make an admin chat but I failed, please help me with making one!
Reply
#2

Код:
CMD:ac(playerid, params[])
{
new string[128];
if(sscanf(params, "s[80]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ac [text]");
if(!pInfo[playerid][miniadmin]) return SendClientMessage(playerid, COLOR_GREY, "Admins only!");
new name[24];
GetPlayerName(playerid, name, sizeof(name));
format(string,sizeof(string), "Admin %s: %s",name,params);
foreach(Player, i)
{
     if(pInfo[i][miniadmin])
     {
           SendClientMessage(i, COLOR_RED, string);
      }
}
return 1;
}
Reply
#3

pawn Код:
CMD:a(playerid, params[])
{
    if(*/ admin variable here */)
    {
        new text[124], string[124], pname[MAX_PLAYER_NAME];
        if(sscanf(params, "s[124]", text)) return SendClientMessage(playerid, -1, "/a [text]");
        GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
        format(string, sizeof(string),"%s: %s", pname, text);
        SendAdminMessage(-1, string);
    }
    else return SendClientMessage(playerid, -1, "You're not an admin")
    return 1;
}

SendAdminMessage(color, const string[])
{
    foreach(Player, i)
    {
        if(*/ admin variable here */)
        {
            SendClientMessage(i, color, string);
        }
    }
    return 1;
}
Reply
#4

The chat aren't showing up ;/
Reply
#5

pawn Код:
CMD:achat(playerid, params[])
{
    new p2[128], Pna[32];
    if(PlayerData [playerid] [ALevel] >= 1)
{
    if( isnull (params)) return SendClientMessage(playerid, COLOR_RED, "/ac [msg]");
    GetPlayerName(playerid, Pna, 32);
        for(new i = 0; i<MAX_PLAYERS; i++)
        {
            if (IsPlayerConnected(i))
            {
                if(PlayerData[i] [ALevel] >= 1) // change ALevel to the one u store ur data
                {
                    format(p2, 128, "Admin %s (%d): %s", Pna, playerid, params);
                    SendClientMessage(i , COLOR_KHAKI, p2);  // change color_khaki to the color u want.
                }
            }
        }
    }
    else
   {
        return 0;
    }
    return 1;
}
Here is my code but u need to store admin level. it doesn't have msg showing he isnt an admin, etc. Add it

Quote:
Originally Posted by Loot
Посмотреть сообщение
pawn Код:
if(sscanf(params, "s[124]", text)) return SendClientMessage(playerid, -1, "/a [text]");
this kind of cmds doesn't need sscanf
Reply
#6

Show me your command.
Reply
#7

I'd recommend to make an admin chat with quick strings. Suche as

Код:
#Hello, what's up?
!What's going on?
@Heya
Here's a code for this. Post this script below OnPlayerText

pawn Код:
if(text[0] == '#') // You can change the character example to '!' or '@'
{
    new string[128], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    strdel(text, 0, 1);
    format(string, sizeof(string), "[ADMIN CHAT] %s [%d]: %s", pName, playerid, text);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && PlayerData[i][ALevel] > 0) // Player is connected and he's an admin
        {
            SendClientMessage(i, -1, string);
        }
    }
}
Reply
#8

Here's a code
pawn Код:
if(text[0] == '@' && AdminLevel[playerid] >= 1)
{
new name[24]; GetPlayerName(playerid,name,24);
format(string,256,"<Admin Chat> %s(%d): {AFAFAF}%s",name,playerid,text[1]);
MessageToAdmins(COLOR_WHITE,string);
return 0;
}
pawn Код:
stock MessageToAdmins(color,const string[])
{
    for(new i = 0; i <= MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) == 1)
        {
            if (AdminLevel[i] >= 1)
            {
                SendClientMessage(i, color, string);
            }
        }
    }
    return 1;
}
Change the variable "AdminLevel" that i gave u to the variable u have
Reply
#9

I figured it out, thanks, reppin you all.
Reply
#10

dcmd_ad(playerid,params[])
{
new string[128];
if(!strlen(params))
{
SendClientMessage(playerid,COLOR_ERROR,"USAGE: /ad (Message)");
return 1;
}
if(IsSpawned[playerid] == 0)
{
SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
return 1;
}
format(string,sizeof(string),"4[ADMIN CHAT] %s(%d): %s",PlayerName(playerid),playerid,params);
IRC_GroupSay(gGroupAdminID,IRC_ADMINCHANNEL,string );
for(new i=0; i<MAX_PLAYERS; i++)
{
if(AdminLevel[i] >= 1)
{
format(string,sizeof(string),"[ADMIN CHAT] %s(%d): %s",PlayerName(playerid),playerid,params);
SendClientMessage(i,COLOR_ADMIN,string);
}
}
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)