Help SendPlayerCommandToAdmins
#1

So,
I want admins can see command of player ..
How made it ?
help please
Reply
#2

under your command
pawn Код:
new pname[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, pname, sizeof(pname));

for(new i; i<MAX_PLAYERS; i++)
{
    if(IsPlayerAdmin)
    {    
        format(str, sizeof(str), "%s used [COMMAND HERE]", pname);
        SendClientMessage(i, -1, str);
    }
}
or just make a stock out of it.
Reply
#3

Need put it near under the commands ?
Reply
#4

yes
e.g.
pawn Код:
CMD:me(playerid, params)
{
    new pname[MAX_PLAYER_NAME], str[128];
    GetPlayerName(playerid, pname, sizeof(pname));
    if(sscanf(params, "s[128]", params) return SendClientMessage(playerid, -1, "Usage: /me [text]")
    format(str, sizeof(str), "%s %s", pname, params);
    SendClientMessageToAll(-1, str);

    for(new i; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerAdmin)// P.S. it will send the message only to rcon admins, if you want to send it to regular admins, replace or add your Admin variable
        {    
            format(str, sizeof(str), "%s used /me", pname);
            SendClientMessage(i, -1, str);
        }
    }

    return 1;
}
p.s. i made all of that here, may contain errors.
Reply
#5

You should give him rep for helping you, lonako.
Reply
#6

pawn Код:
forward PlayerActionMessage(playerid,Float:radius,message[]);


forward CMDLog(string[]);
public CMDLog(string[])
{
    new mtext[20];
    new year, month,day;
    getdate(year, month, day);
    if(month == 1) { mtext = "January"; }
    else if(month == 2) { mtext = "February"; }
    else if(month == 3) { mtext = "March"; }
    else if(month == 4) { mtext = "April"; }
    else if(month == 5) { mtext = "May"; }
    else if(month == 6) { mtext = "June"; }
    else if(month == 7) { mtext = "July"; }
    else if(month == 8) { mtext = "August"; }
    else if(month == 9) { mtext = "September"; }
    else if(month == 10) { mtext = "October"; }
    else if(month == 11) { mtext = "November"; }
    else if(month == 12) { mtext = "December"; }
    new hour,minuite,second;
    gettime(hour,minuite,second);
    FixHour(hour);
    hour = shifthour;
    new entry[256];
    format(entry, sizeof(entry), "[%d %s %d:%d] %s\r\n",day, mtext, hour, minuite, string);
    new File:hFile;
    hFile = fopen("CMD.log", io_append);
    fwrite(hFile, entry);
    fclose(hFile);
}


public PlayerActionMessage(playerid,Float:radius,message[])
{
    new string[128];
    format(string, sizeof(string), "%s %s", GetPlayerNameEx(playerid), message);
    ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    return 1;
}




    if(strcmp(cmd, "/me", true) == 0)
    {
        GetPlayerName(playerid, sendername, sizeof(sendername));
        GiveNameSpace(sendername);
        new length = strlen(cmdtext);
        while ((idx < length) && (cmdtext[idx] <= ' ')) {
            idx++;
        }
        new offset = idx;
        new result[128];
        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) {
            result[idx - offset] = cmdtext[idx];
            idx++;
        }
        result[idx - offset] = EOS;
        if(!strlen(result)) {
            SendClientMessage(playerid, COLOR_PINK, "[USAGE]: /me [action]");
            return 1;
        }
        format(string, sizeof(string), "* %s %s", sendername, result);
        PlayerActionMessage(playerid,20.0,result);
        CMDLog(result);
        return 1;
    }
Try that.

EDIT:

Quote:
Originally Posted by RTR12
Посмотреть сообщение
You should give him rep for helping you, lonako.
Not every helping thing is about reputation, you know, I don't understand why people care about rep so much.
Reply
#7

I put it :
PHP код:
format(string,sizeof(string),"%s [ID: %d]: %s",GetName(playerid), playeridcmdtext);
for(new 
iMAX_PLAYERSi++) if(IsPlayerAdmin(i)) SendClientMessage(i,-1,string); 
and this work just to admin rcon ,
how I do not even from rcon admins , see that?
its my command from the mode :
PHP код:
    if(strcmp(cmd"/Say"true) == || strcmp(cmd"/S"true) == 0)
    {
        if(
GetAdminLevel(playerid) < && !IsPlayerAdmin(playerid) && GetAdminSpay(playerid) < && GetTempAdminLevel(playerid) < 2) return SendClientMessage(playeridWhite"шоъ дагойп щмк роелд");
        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++;
        }
        if(!
strlen(result)) return SendClientMessage(playeridWhite"/Say(S) [Text] :цешъ дщйоещ");
        
format(stringsizeof(string),"*Admin: %s%s",(result));
        
SendClientMessageToAll(Color_Redstring);
        return 
1;
    } 
Reply
#8

I didn't get your question.
Reply
#9

OK OK OK
See
PHP код:
format(string,sizeof(string),"%s [ID: %d]: %s",GetName(playerid), playeridcmdtext);
for(new 
iMAX_PLAYERSi++) if(GetAdminLevel(playerid) < && !IsPlayerAdmin(playerid) && GetAdminSpay(playerid) < && GetTempAdminLevel(playerid) < 2)
SendClientMessage(playerid,-1,string); 
Why it doesn't work !?!?
Reply
#10

learn the difference between "&&"(and) and "||" (or)
pawn Код:
for(new i; i < MAX_PLAYERS; i++) if(GetAdminLevel(playerid) < 2 ||!IsPlayerAdmin(playerid) || GetAdminSpay(playerid) < 2 || GetTempAdminLevel(playerid) < 2)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)