[Tutorial] Report System. [Not an Edit Like LukeStephen's.]
#1

Alright, I just now decided to make this, because I found out that, the Luke guy's report system WAS FAKE!
So.. Now to the Tutorial...

Alright. Make sure you have this at the top of your script:
pawn Code:
#include <a_samp>
#include <zcmd>
#include <DubColors>
Now. I will include references for zcmd and DubColors at the bottom.

Now we have to start the basic of the command.
pawn Code:
/*
There are multiple way's to use zcmd. I like using this way the most.*/

CMD:report(playerid, params[])
{
}
// BUT you can also use this:
COMMAND:report(playerid, params[])
{
}
Now, we start the Command.

First, we have to add our New's, all we need for this is this:
pawn Code:
new string[128];
The command should now look something like this:
pawn Code:
CMD:report(playerid, params[])
{
    new string[128];
}
Now. We have to check if it is blank or not.

pawn Code:
if(!isnull(params))
The command now looks like:
pawn Code:
CMD:report(playerid, params[])
{
    new string[128];
    if(!isnull(params))
}
The !isnull initiate's that we ARE using it.

Now We start the report. If you want it to show proof that you are reporting, go ahead and add this:
pawn Code:
SendClientMessage(playerid, COLOR_YELLOW, "Your report was sent to the Admin Teams:");
format(string, sizeof(string), "%s", params);
SendClientMessage(playerid, COLOR_YELLOW, string);
And tab it to perfection. But, also make sure you added the correct {'s.

The command will now look something like this:

pawn Code:
CMD:report(playerid, params[])
{
    new string[128];
    if(!isnull(params))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Your report was sent to the Admin Teams:");
        format(string, sizeof(string), "%s", params);
        SendClientMessage(playerid, COLOR_YELLOW, string);
}
Let's Continue!

Now we have to make it send to the Admins. It is set to send to Rcon Admin's. GO ahead and edit it if you have enum's and other sence for In-Game Admins.

So, now we have to add this:
pawn Code:
for(new i=0; i<MAX_PLAYERS; i++)
It sets the letter "i" as EVERY player. But... We aren't even closed to finished yet! We must now add another {.

Now, we will add the variable to send to in-game rcon admins.
pawn Code:
if(IsPlayerAdmin(playerid))
{
Now, we have added another {. The command now looks like:
pawn Code:
CMD:report(playerid, params[])
{
    new string[128];
    if(!isnull(params))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Your report was sent to the Admin Teams:");
        format(string, sizeof(string), "%s", params);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerAdmin(playerid))
            {
Now I won't show you what it looks like until we have finished it.

Now we format it to send to the Admins.
pawn Code:
format(string, sizeof(string), "Report from %s[%d]: %s", PlayerName(playerid), playerid, params);
SendClientMessage(i, COLOR_ORANGE, string);
}
Now we close 3 brackets ( }'s ).
Now we make it show the usage, we have to add a "else".
pawn Code:
else
{
    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /Report [Text]");
}
Now we add a return, meaning the command will return, and not show up as not a command.
pawn Code:
return 1;
Then, finally, the closing bracket! ( } ).
The command is now complete, and looks like this:
pawn Code:
CMD:report(playerid, params[])
{
    new string[128];
    if(!isnull(params))
    {
        SendClientMessage(playerid, COLOR_YELLOW, "Your report was sent to the Admin Teams:");
        format(string, sizeof(string), "%s", params); // Proof to the reporter, that the command worked.
        SendClientMessage(playerid, COLOR_YELLOW, string);
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(IsPlayerAdmin(playerid))
            {
                format(string, sizeof(string), "Report from %s[%d]: %s", PlayerName(playerid), playerid, params);
                SendClientMessage(i, COLOR_ORANGE, string); // Send's the format to the online Rcon'ly Logged in Admins.
            }
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /Report [Text]"); // Show's the player the Usage.
    }
    return 1;
}
You may have noticed that to show your own name, I had "PlayerName(playerid)", well I made a stock for that. It is this:
pawn Code:
stock PlayerName(playerid)
{
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    return Name;
}
And now to those reference's that I promised. Well..

ZCMD: https://sampforum.blast.hk/showthread.php?tid=91354
DubColors: https://sampforum.blast.hk/showthread.php?tid=353068

I hope I helped you. Oh and, with the for(new i=0; i<MAX_PLAYERS; i++), you can replace it with foreach(Player, i), if you use foreach.

Hope I helped you with my Tutorial. This is my first tutorial, but I can script. And let me tell you, this is NOT an Edit. I just recently made this. Don't let anyone tell you other wise.
Reply
#2

You don't need sscanf for one parameter. That's what isnull() is for.
Reply
#3

Quote:
Originally Posted by VincentDunn
View Post
You don't need sscanf for one parameter. That's what isnull() is for.
I knew that before, I just wasn't thinking. Changed to that now.
Reply
#4

bump
Reply
#5

Not to hijack the thread, but look how easier it is to make a /report command:
pawn Code:
CMD:report(playerid, params[])
{
    new string[128], reason[128], reportid;
    if(sscanf(params, "is", reportid, reason)) return SendClientMessage(playerid, COLOR_RED, "|- [Error] /report [id] [text] -|");
    format(string, sizeof(string), "REPORT: Player %s(%d) has reported %s(%d) for: %s", GetName(playerid), playerid, GetName(reportid), reportid, reason);
    SendMessageToAdmins(COLOR_YELLOW, string);

    SendClientMessage(playerid, COLOR_YELLOW, "Your report has been sent to all online Administrators");
    return 1;
}
P.S ^ is a proper /report command, yours is more of an "/assistance" command.

EDIT: Nevermind, I forgot I used a stock ¬_¬
Reply
#6

Quote:
Originally Posted by Windows32
View Post
EDIT: your wasting alot of code. this isnt even needed
Code:
for(new i=0; i<MAX_PLAYERS; i++)
Yes he does, as the script needs to find out to whom it should send the report. (AKA: Who the admins are.)
Furthermore, your code is not a proper command, as you just magically invent a new function (SendMessageToAdmins) without any explanation, or any code for the function. Thus, your code wouldn't even work.
Reply
#7

Your title will really make people want to read this -_-
Reply
#8

Quote:
Originally Posted by Windows32
View Post
Not to hijack the thread, but look how easier it is to make a /report command:
pawn Code:
CMD:report(playerid, params[])
{
    new string[128], reason[128], reportid;
    if(sscanf(params, "is", reportid, reason)) return SendClientMessage(playerid, COLOR_RED, "|- [Error] /report [id] [text] -|");
    format(string, sizeof(string), "REPORT: Player %s(%d) has reported %s(%d) for: %s", GetName(playerid), playerid, GetName(reportid), reportid, reason);
    SendMessageToAdmins(COLOR_YELLOW, string);

    SendClientMessage(playerid, COLOR_YELLOW, "Your report has been sent to all online Administrators");
    return 1;
}
P.S ^ is a proper /report command, yours is more of an "/assistance" command.

EDIT: Nevermind, I forgot I used a stock ¬_¬
Your first post, I don't use this /report, I just gave this report to people who need a BASIC report. Other's who just want to learn how to make a command like this would copy+paste this, and edit it to their enum PlayerInfo, or however they have it. They could also make a "SendAdminMessage" if they wanted. And the for(new i=0; i<MAX_PLAYERS>; i++), I use foreach(Player, i), but other people might not, and they might use that. I just used the basic "a_samp" function's, zcmd, and my DubColors.
Reply
#9

Quote:
Originally Posted by VincentDunn
View Post
You don't need sscanf for one parameter. That's what isnull() is for.
Or he can remove the isnull, and sscanf will assign the variables
Reply
#10

Why?
WHY ME
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)