SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 10/10/2013, 10:05 AM   #1
Kyance
Gangsta
 
Kyance's Avatar
 
Join Date: Mar 2013
Posts: 818
Reputation: 92
Default /report command.

WELCOME :]
So, today i will try to teach you, how to make an /report command!
First of all, you will need sscanf and zCMD
Links:
ZCMD: http://forum.sa-mp.com/showthread.php?t=91354
SSCANF: http://forum.sa-mp.com/showthread.php?t=120356
Getting started
Now, you need to set the zcmd's .ini file in pawno -> include
The sscanf file will have folders, just drag them in your folder, where you have the pawno etc.
You will also need to add sscanf in your server.cfg file (plugins sscanf)
Now, do #include <sscanf2> and #include <zcmd> under the <a_samp> include.
COLOR DEFINES
You will need these color defines.
Add them under your includes.
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_LIME 0x10F441AA
define / include check
This is how it looks for me
pawn Code:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_LIME 0x10F441AA
STARTING SCRIPTING
pawn Code:
CMD:report(playerid, params[]) {
The base of the command.
It will trigger when a player types 'report'

pawn Code:
new id;
    new reason[128];
    if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, COLOR_ORANGE, "[SERVER] - USAGE: /report [ID] [REASON]");
But if the player won't know how to type the command fully, this will show up.
new id; 'defines' the targets id, and new reason[128]; is a string for the reason.
pawn Code:
new string[150], sender[MAX_PLAYER_NAME], receiver[MAX_PLAYER_NAME];
    GetPlayerName(playerid, sender, sizeof(sender));
    GetPlayerName(id, receiver, sizeof(receiver));
These strings will 'get' the senders(playerids) name/id, and the receivers(id/target) name/id.
GetPlayerName playerid sender etc etc will get the players name / id.
GetPlayerName id receiver etc etc will get the targets name / id.
pawn Code:
format(string, sizeof(string), "[ADMIN] - %s(%d) has reported %s(%d)", sender, playerid, receiver, id);
    SendMessageToAdmins(string);
    format(string, sizeof(string), "[ADMIN] - Reason: %s", reason);
    SendMessageToAdmins(string);
This will send the report message, to the admins.
It will look like ->
[ADMIN] - PlayerName(playerid) has reported TargetName(TargetID)
[ADMIN] - Reason: reason here.
pawn Code:
SendClientMessage(playerid, COLOR_ORANGE, "Your report has been sent.");
    return 1;
}
And then the server will send a message to the player, saying that the report was sent.
SendMessageToAdmins
We need to make it, so the RCON Admins are actually able to see the report.
By that we will need to add this stock:

pawn Code:
stock SendMessageToAdmins(text[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerAdmin(i))
        {
            SendClientMessage(i, COLOR_LIME, text);
        }
    }
}
This will loop trough the players/rcon admins, and will send the report message"SendMessageToAdmins"
NOTE: The SendMessageToAdmins can be also used for admin chats.
Well, i hope that i some-what helped you.
PREVIEW.
[ame]www.*******.com/watch?v=MlRjzEoFBaI[/ame]
FULL CODE
pawn Code:
CMD:report(playerid, params[]) {
    new id;
    new reason[128];
    if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, COLOR_ORANGE, "[SERVER] - USAGE: /report [ID] [REASON]");
    new string[150], sender[MAX_PLAYER_NAME], receiver[MAX_PLAYER_NAME];
    GetPlayerName(playerid, sender, sizeof(sender));
    GetPlayerName(id, receiver, sizeof(receiver));
    format(string, sizeof(string), "[ADMIN] - %s(%d) has reported %s(%d)", sender, playerid, receiver, id);
    SendMessageToAdmins(string);
    format(string, sizeof(string), "[ADMIN] - Reason: %s", reason);
    SendMessageToAdmins(string);
    SendClientMessage(playerid, COLOR_ORANGE, "Your report has been sent.");
    return 1;
}

Last edited by Kyance; 10/10/2013 at 01:31 PM.
Kyance is offline   Reply With Quote
Old 10/10/2013, 10:31 AM   #2
DobbysGamertag
Gangsta
 
DobbysGamertag's Avatar
 
Join Date: Jan 2013
Location: England
Posts: 805
Reputation: 100
Default Re: /report command.

Not a bad tutorial


Off topic now. Why don't people stock the GetPlayerName function instead of having to get the player name each time.

pawn Code:
stock Name(playerid)
{
    new n[MAX_PLAYER_NAME];
    GetPlayerName(playerid,n,sizeof(n));
    return n;
}
DobbysGamertag is offline   Reply With Quote
Old 10/10/2013, 10:37 AM   #3
qazwsx
Huge Clucker
 
qazwsx's Avatar
 
Join Date: Jun 2013
Location: Semarang,Indonesia
Posts: 409
Reputation: 55
Default Re: /report command.

Nice tutorial
will be usefull for newbies
__________________
Ive left SAMP Scripting. I wont keep the update of my gamemodes. I might come back someday later, but didnt think about to come back to scripting ATM. However, I'd always come around to forums, chcking stuffs happened, and responds to thoose who have give their feedback on my gamemode.

-Regard
qazwsx
qazwsx is offline   Reply With Quote
Old 10/10/2013, 10:37 AM   #4
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,866
Reputation: 1394
Default Re: /report command.

Quote:
Originally Posted by DobbysGamertag View Post
Not a bad tutorial


Off topic now. Why don't people stock the GetPlayerName function instead of having to get the player name each time.

pawn Code:
stock Name(playerid)
{
    new n[MAX_PLAYER_NAME];
    GetPlayerName(playerid,n,sizeof(n));
    return n;
}

Then it'll become:
pawn Code:
CMD:report(playerid,params[])
{
    new pid,reason[60],string[124];
    if(sscanf(params,"us[60]",pid,reason))return SendClientMessage(playerid,COLOR_ORANGE,"[SERVER] - USAGE /report [id][reason]");
    format(string,124,"[ADMIN] %s (%d) has reported %s (%d)",Name(playerid),playerid,Name(pid),pid);
    SendMessageToAdmins(string);
    format(string,124,"[ADMIN]  - Reason: %s",reason);
    SendMessageToAdmin(string);
    SendClientMessage(playerid,COLOR_ORANGE,"Your report has been sent");
    return 1;
}

Wrote it quick so im not sure if it'll compile without errors. But you get the idea?
Honestly, your method is worse. Do you want to know why?

Let's say in a command you need to show 4 messages with the playerid's name. By using his method, he would call GetPlayerName only 1 time and your stock would call GetPlayerName 4 times. I hope you get what I mean.

The best way is to get the name ONLY 1 time on connect and use it later on.

pawn Code:
new
    Name[ MAX_PLAYERS ][ MAX_PLAYER_NAME ]
;

// OnPlayerConnect:
GetPlayerName( playerid, Name[ playerid ], MAX_PLAYER_NAME );

// Everywhere else:
format(string,124,"[ADMIN] %s (%d) has reported %s (%d)",Name[playerid],playerid,Name[pid],pid);
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System
Konstantinos is offline   Reply With Quote
Old 10/10/2013, 07:55 PM   #5
efrim123
Huge Clucker
 
Join Date: Jul 2013
Posts: 200
Reputation: -9
Default Re: /report command.

WOW!!!
Kyance very nice tutorial

mate add me on skype i want to talk with you i just want to talk with you like old days
Skype:efrim142
__________________
Currect Project:Los Santos Cops and Robbers
it wont be released unless i wont need that script anymore
wich means if update my script like for the first time
i will give the older version only once!!!


My Work:
Team DeathMatch Gamemode
http://forum.sa-mp.com/showthread.php?t=459332
Weapon system tutorial
http://forum.sa-mp.com/showthread.php?t=459412
Gunpack for cops and robbers:
http://forum.sa-mp.com/showthread.php?t=466487
Admin and Regular player system filter script:
http://forum.sa-mp.com/showthread.ph...67#post2728467
efrim123 is offline   Reply With Quote
Old 11/10/2013, 02:40 PM   #6
Kyance
Gangsta
 
Kyance's Avatar
 
Join Date: Mar 2013
Posts: 818
Reputation: 92
Default Re: /report command.

Quote:
Originally Posted by efrim123 View Post
WOW!!!
Kyance very nice tutorial

mate add me on skype i want to talk with you i just want to talk with you like old days
Skype:efrim142
Friend request sent, also, thanks everyone.
Kyance is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
/report command help damian123 Scripting Help 10 29/08/2013 05:04 PM
[Help]: /report command! Areax Scripting Help 6 28/05/2013 02:59 PM
/report (Command Unknown, Short command) Why? Dokins Scripting Help 5 08/12/2011 01:34 PM
Report command bartje01 Help Archive 5 11/06/2011 10:19 PM
report command Face9000 Help Archive 6 17/12/2010 04:10 PM


All times are GMT. The time now is 08:54 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.