[HELP] /report Dialog
#1

Can some one make a Report Dialog for me? I have tired it, but it was fail -,-.
Please help me.


]B4E[kengston
Reply
#2

/report that sends an message to the admins? What command base do you use? zcmd, dcmd or strcmp?
Reply
#3

I use strcmp. And yes, send the report only to the Admins.

Edit:
I already create an /report command but not in a Dialog.
Reply
#4

Can someone help me?? Please
Reply
#5

pawn Код:
if(strcmp(cmd, "/report", true) == 0)
    {
        if(!CanUseCmd(PlayerInfo[playerid][pID], cmd)) return SendClientMessage(playerid, COLOR_LIGHTRED, ">> You are not eligible to use this command, because of misuse!");
        if(IsPlayerConnected(playerid))
        {
            if(Ticket[playerid] > 0)
            {
                SendClientMessage(playerid, COLOR_GRAD1, ">> You already have an open ticket with an admin, type /answer to talk to him.");
                return 1;
            }
            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_GRAD1, ">> That's not the way, try: /report (message)");
                return 1;
            }
            SendClientMessage(playerid, COLOR_GRAD1, "Your report message has been sent to the admins online.");
            format(string, sizeof(string), "Report from [%d] %s: %s", playerid, sendername, (result));
            SendAdminMessage(COLOR_YELLOW2, string);
        }
        return 1;
    }
Assuming you got the colors defined and strtok() callback added.


Add this callback somewhere in your script.
pawn Код:
public SendAdminMessage(color, string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(PlayerInfo[i][pAdmin] >= 1)
            {
                SendClientMessage(i, color, string);
            }
        }
    }
return 1;
}
I know the command could be much easier and cleaner with sscanf.
Reply
#6

I don't use idx and cmd...Do you think it works with inputtext?
Reply
#7

Quote:
Originally Posted by ]B4E[kengston
Посмотреть сообщение
I don't use idx and cmd...Do you think it works with inputtext?
Yup should work.
Reply
#8

Should be something like this then:
pawn Код:
if(strcmp(cmd, "/report", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new sendername[MAX_PLAYER_NAME], string[256];
            GetPlayerName(playerid, sendername, sizeof(sendername));
            SendClientMessage(playerid, COLOR_GRAD1, "Your report message has been sent to the admins online.");
            format(string, sizeof(string), "Report from [%d] %s: %s", playerid, sendername, cmdtext);
            SendAdminMessage(COLOR_YELLOW2, string);
        }
        return 1;
    }
Reply
#9

Or you could just use ZCMD and sscanf.
pawn Код:
COMMAND:report(playerid, params[])
{
    new text[128], string[128], reportname[MAX_PLAYER_NAME];
    if(sscanf(params, "s[127]", text)) SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /report (message)");
    GetPlayerName(playerid, reportname, sizeof(reportname));
    format(string, sizeof(string), "Report from %s [%d]: %s ))", reportname, playerid, text);
    SendAdminMessage(0xFFF200, string);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)