Please help me with this tiny bit of admin script?
#1

Hi, I have a common admin command that does this: you type /say and it sends a message to everyone, but it looks like its written from someone named "admin" (lol dont know how to describe it better hopefully you understand). Here it is:

http://samp.pastebin.com/m7cfd6cd6

But I would like to know this: say my username is Username and I'm an admin, how do I make it do that when i do /say [message], it sends a message to all from Admin Username, instead of just Admin.
Reply
#2

pawn Код:
if(strcmp(cmd, "/say", true) == 0) // Publicly says an admin message. Exact same as RCON's 'say' but in a red color.
    {
      if (AccountInfo[playerid][AdminLevel] >= 3 || IsPlayerAdmin(playerid))
    {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new result[128];
            result = bigstrtok(cmdtext, idx);
            if(!strlen(result))
            {
                SendClientMessage(playerid, ORANGE, "USAGE: /say [message]");
                SendClientMessage(playerid, ORANGE, "FUNCTION: Will broadcast an admin message.");
                return 1;
            }
            new AdminName[MAX_PLAYER_NAME];
            GetPlayerName(playerid,AdminName,sizeof(AdminName));
            format(string, sizeof(string), "* Admin %s: %s", AdminName,result);
            SendClientMessageToAll(LIGHTRED, string);
            printf("%s", string);
        }
        else SendClientMessage(playerid, RED, "You are not an admin with the required level.");
        return 1;
    }
Reply
#3

Thanks coole210. I am new to scripting so I dont know much. But when I compile that I get two "loose indentation" errors. I tried moving over the "new AdminName[MAX_PLAYER_NAME];" and "GetPlayerName(playerid,AdminName,sizeof(AdminName ));" lines because they look out of line..

it looks pretty simple, what you changed in the script. im guessing that "new adminname[MAX_PLAYER_NAME];" basically makes it so that when you write AdminName in the script, it replaces that with the admins name. (trying to learn as i go along)

thanks for the help
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)