SA-MP Forums Archive
Admin chat help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Admin chat help (/showthread.php?tid=479945)



Admin chat help - lulo356 - 08.12.2013

Well, i have a admin chat and this is only for Rcon admins, but how can i create it for Admins without rcon

Quote:

dcmd_a(playerid, cmdtext[]) {
#pragma unused cmdtext
new sendername[MAX_PLAYER_NAME];
new string[256], idx;
if (!IsPlayerAdmin(playerid)) SendClientMessage(playerid, COLOR_BLUE, "You're not an admin.");
else {
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_WHITE, "USAGE: /a <message>");
return 1;
}
format(string, sizeof(string), "[AdminChat]%s: %s", sendername, result);
SendAdminMessage(COLOR_WHITE,string);
return 1;
}
return 1;
}




Re: Admin chat help - Loot - 08.12.2013

There are literally TONS of scripts that has the feature you need!

Why don't you try and search up a bit and see how they were created?


Re: Admin chat help - Tayab - 08.12.2013

Right in place of !IsPlayerAdmin(playerid), add your admin check and you're done.


Re: Admin chat help - Raza2013 - 08.12.2013

Quote:
Originally Posted by lulo356
Посмотреть сообщение
Well, i have a admin chat and this is only for Rcon admins, but how can i create it for Admins without rcon
pawn Код:
dcmd_a(playerid, cmdtext[]) {
#pragma unused cmdtext
new sendername[MAX_PLAYER_NAME];
new string[256], idx;
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_WHITE, "USAGE: /a <message>");
return 1;
}
format(string, sizeof(string), "[AdminChat]%s: %s", sendername, result);
SendAdminMessage(COLOR_WHITE,string);
return 1;
}
return 1;
}
PS: Not Tested


Re: Admin chat help - newbie scripter - 08.12.2013

I prefer u to use sscanf.


Re: Admin chat help - gotwarzone - 08.12.2013

lulo356 better change to zcmd or ycmd processor.

On Topic:

Show us your /slap command or /kick command.


Re: Admin chat help - newbie scripter - 08.12.2013

1st of all u have to make an Enum
I will be using ZCMD and SSCANF
pawn Код:
// enum:
enum PlayerData
{
    AdminLvl
}
new pInfo [MAX_PLAYERS] [PlayerData];
// CMD:
CMD:achat(playerid, params[])
{
    new p2[128], Pna[32];
    if(pInfo[playerid] [Adminlvl] < 1) return 0;
    if( isnull (params)) return SendClientMessage(playerid, COLOR_RED, "/ac [msg]");
    GetPlayerName(playerid, Pna, 32);
    if (pInfo [playerid] [AdminLevel] >= 1 || IsPlayerAdmin(playerid))
    {
        for(new i = 0; i<MAX_PLAYERS; i++)
        {
            if (IsPlayerConnected(i))
            {
                if(pInfo [i] [Adminlvl] >= 1)
                {
                    format(p2, 128, "Admin %s (%d): %s", Pna, playerid, params);
                    SendClientMessage(i , -1, p2);
                }
            }
        }
    }  
    return 1;
}
If u want me to explain it, tell me


Re: Admin chat help - PrivatioBoni - 08.12.2013

@ newbie scripter.

Just one error I've seen on your script so far is that you've inconsistently used enum names, e.g. you switched between AdminLvl and AdminLevel. That is bound to cause error/s.


Re: Admin chat help - lulo356 - 08.12.2013

Quote:
Originally Posted by Raza2013
Посмотреть сообщение
pawn Код:
dcmd_a(playerid, cmdtext[]) {
#pragma unused cmdtext
new sendername[MAX_PLAYER_NAME];
new string[256], idx;
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_WHITE, "USAGE: /a <message>");
return 1;
}
format(string, sizeof(string), "[AdminChat]%s: %s", sendername, result);
SendAdminMessage(COLOR_WHITE,string);
return 1;
}
return 1;
}
PS: Not Tested

This one is working, only if you do /a [text] its not sending