10.10.2013, 10:05
(
Last edited by Kyance; 10/10/2013 at 01:31 PM.
)
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: https://sampforum.blast.hk/showthread.php?tid=91354
SSCANF: https://sampforum.blast.hk/showthread.php?tid=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
STARTING SCRIPTING
The base of the command.
It will trigger when a player types 'report'
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.
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.
This will send the report message, to the admins.
It will look like ->
[ADMIN] - PlayerName(playerid) has reported TargetName(TargetID)
[ADMIN] - Reason: reason here.
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:
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.youtube.com/watch?v=MlRjzEoFBaI[/ame]
FULL CODE
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: https://sampforum.blast.hk/showthread.php?tid=91354
SSCANF: https://sampforum.blast.hk/showthread.php?tid=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
pawn Code:
CMD:report(playerid, params[]) {
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]");
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));
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);
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;
}
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);
}
}
}
NOTE: The SendMessageToAdmins can be also used for admin chats.
Well, i hope that i some-what helped you.
PREVIEW.
[ame]www.youtube.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;
}