Admin chat
#1

Hello all. I have this in my script when writing # in front of your chat example: #Hello.

This is the admin chat at my script. But Im wondering is there any possibility of changing this to /a instead?

Here is the code:

pawn Код:
if(text[0] == '#' && (PlayerInfo[playerid][pAdmin] >= 1))
    {
        GetPlayerName(playerid,sendername,sizeof(sendername));

        new arank[24];
        if(PlayerInfo[playerid][pAdmin] == 1) { arank = "Trial Administrator"; }
        else if(PlayerInfo[playerid][pAdmin] == 2) { arank = "Normal Administrator"; }
        else if(PlayerInfo[playerid][pAdmin] == 3) { arank = "Senior Administrator"; }
        else if(PlayerInfo[playerid][pAdmin] == 4) { arank = "Lead Administrator"; }
        else if(PlayerInfo[playerid][pAdmin] == 5) { arank = "Head Administrator"; }
        else if(PlayerInfo[playerid][pAdmin] == 6) { arank = "Head of Admins"; }
        else if(PlayerInfo[playerid][pAdmin] == 1337) { arank = "Scripter"; }
        else if(PlayerInfo[playerid][pAdmin] == 1338) { arank = "Server Owner"; }
        else { arank = "Unknown"; }

        format(string, sizeof(string), "[%s] %s (%d): %s", arank, sendername, playerid, text[1]);
        SendAdminMessage(COLOR_LIGHTRED, string);
       
        printf("%s %s: %s",arank, sendername, text[1]);

        format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s %s: %s",arank,d,m,y,h,mi,s,sendername, text[1]);
        AdminChatLog(string);
        return 0;
    }
Reply
#2

Using ZCMD, sscanf :

pawn Код:
CMD:a(playerid, params[])
{
    new Text[80];
    if (sscanf(params, "s", Text[80])) return SendClientMessage(playerid, COLOR_LIGHTRED, "Usage : /a <text>");
    else if(PlayerInfo[playerid][pAdmin] >= 1) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to be an admin in order to use this command!");
    else
    {
        new pName[MAX_PLAYER_NAME];
        new string[128];
        GetPlayerName(playerid, pName, sizeof(pName));
        new h, mi, s, d, m, y;
        gettime(h, mi, s);
        getdate(y, m, d);

        new arank[24];
        if(PlayerInfo[playerid][pAdmin] == 1) { arank = "Trial Administrator"; }
        else if(PlayerInfo[playerid][pAdmin] == 2) { arank = "Normal Administrator"; }
        else if(PlayerInfo[playerid][pAdmin] == 3) { arank = "Senior Administrator"; }
        else if(PlayerInfo[playerid][pAdmin] == 4) { arank = "Lead Administrator"; }
        else if(PlayerInfo[playerid][pAdmin] == 5) { arank = "Head Administrator"; }
        else if(PlayerInfo[playerid][pAdmin] == 6) { arank = "Head of Admins"; }
        else if(PlayerInfo[playerid][pAdmin] == 1337) { arank = "Scripter"; }
        else if(PlayerInfo[playerid][pAdmin] == 1338) { arank = "Server Owner"; }
        else { arank = "Unknown"; }

        format(string, sizeof(string), "[%s] %s (%d): %s", arank, pName, playerid, Text);
        SendAdminMessage(COLOR_LIGHTRED, string);

        printf("%s %s: %s",arank, pName, Text);

        format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s %s: %s", d, m, y, h, mi, s, arank, pName, Text);
        AdminChatLog(string);
    }
    return 1;
}
Reply
#3

#define d
#define m
#define y
#define h
#define mi
#define s

Like this, good sir?
Reply
#4

Quote:
Originally Posted by Fell
Посмотреть сообщение
#define d
#define m
#define y
#define h
#define mi
#define s

Like this, good sir?
What? First of all, tell us what is that supposed to do:

pawn Код:
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s %s: %s",arank,d,m,y,h,mi,s,sendername, text[1]);
I guess, it's timestamp, so you can use /timestamp command or just use gettime and getdate function to store current time a date. Then you can display it in message. Your macro's doesn't makes sense.
Reply
#5

Anyways,

Im having these errors:

pawn Код:
C:\Users\Administrator\Desktop\All Server Files\Infinity Gaming LSRP Server\RP\gamemodes\larp.pwn(17221) : warning 219: local variable "a" shadows a variable at a preceding level
C:\Users\Administrator\Desktop\All Server Files\Infinity Gaming LSRP Server\RP\gamemodes\larp.pwn(33549) : warning 219: local variable "a" shadows a variable at a preceding level
C:\Users\Administrator\Desktop\All Server Files\Infinity Gaming LSRP Server\RP\gamemodes\larp.pwn(43588) : warning 219: local variable "a" shadows a variable at a preceding level
C:\Users\Administrator\Desktop\All Server Files\Infinity Gaming LSRP Server\RP\gamemodes\larp.pwn(73537) : error 017: undefined symbol "a"
C:\Users\Administrator\Desktop\All Server Files\Infinity Gaming LSRP Server\RP\gamemodes\larp.pwn(73539) : warning 219: local variable "Text" shadows a variable at a preceding level
C:\Users\Administrator\Desktop\All Server Files\Infinity Gaming LSRP Server\RP\gamemodes\larp.pwn(73540) : error 017: undefined symbol "params"
C:\Users\Administrator\Desktop\All Server Files\Infinity Gaming LSRP Server\RP\gamemodes\larp.pwn(73545) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Users\Administrator\Desktop\All Server Files\Infinity Gaming LSRP Server\RP\gamemodes\larp.pwn(73569) : warning 225: unreachable code
C:\Users\Administrator\Desktop\All Server Files\Infinity Gaming LSRP Server\RP\gamemodes\larp.pwn(73537) : warning 203: symbol is never used: "CMD"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.
Reply
#6

Recheck my post Fell.

Also i said it requires sscanf + zcmd, and for the other warnings it means that those names are already defined, change them.
Reply
#7

However, you should (can) use there switch, to optimaze your code.

From:
pawn Код:
if(PlayerInfo[playerid][pAdmin] == 1) {  }
        else if(PlayerInfo[playerid][pAdmin] == 2) { arank = "Normal Administrator"; }
        else if(PlayerInfo[playerid][pAdmin] == 3) { arank = "Senior Administrator"; }
        else if(PlayerInfo[playerid][pAdmin] == 4) { arank = "Lead Administrator"; }
        else if(PlayerInfo[playerid][pAdmin] == 5) { arank = "Head Administrator"; }
        else if(PlayerInfo[playerid][pAdmin] == 6) { arank = "Head of Admins"; }
        else if(PlayerInfo[playerid][pAdmin] == 1337) { arank = "Scripter"; }
        else if(PlayerInfo[playerid][pAdmin] == 1338) { arank = "Server Owner"; }
        else { arank = "Unknown"; }
To:
pawn Код:
switch(PlayerInfo[playerid][pAdmin])
        {
            case 1:arank = "Trial Administrator";
            case 2:arank = "Normal Administrator";
            case 3:arank = "Senior Administrator";
            case 4:arank = "Lead Administrator";
            case 5:arank = "Head Administrator";
            case 6:arank = "Head of Admins";
            case 1337:arank = "Scripter";
            case 1338:arank = "Server Owner";
            default:arank = "Unknown / Player";
        }
Reply
#8

Could you pleasel link me to a correct instalattion file for ZCMD or a thread here at SA-MP forums? I've ******d it but I couldn't find anything smooth to be honest. Would appreciate all the help!
Reply
#9

Quote:
Originally Posted by Fell
Посмотреть сообщение
Could you pleasel link me to a correct instalattion file for ZCMD or a thread here at SA-MP forums? I've ******d it but I couldn't find anything smooth to be honest. Would appreciate all the help!
You're serious now?

Reply
#10

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
You're serious now?

The pastebin on that one didn't work that's why I asked if you had one. Sorry if I caused any trouble.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)