[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


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)