Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

[Tutorial] /helpme system

$
0
0
Helpme system - for beginners


What is this?
This is a simple & short tutorial which shows you how to create a helpme system.

What is helpme?
This is a command used in a lot of servers, basically you can make a question which will go to the admins and they
can help you with that.

What do you need to download to make this command?
You need to download a few includes which you can find it down there
ZCMD: http://www.solidfiles.com/d/d20f/
foreach: https://github.com/karimcambridge/SAMP-foreach
sscanf: https://github.com/maddinat0r/sscanf/releases


Okay let's start.

Step I:
You need to add a few includes at the top of your script
Code:

#include <a_samp>
#include <zcmd>
#include <foreach>
#include <sscanf>

Also create the pInfo enum which will be used later.
Code:

enum pInfo
{
        pAdmin
}
new PlayerInfo[MAX_PLAYERS][pInfo];

Step II:
You need to define a few colors.
Code:

#define COLOR_ORANGE 0xFF9900AA
#define COLOR_GREY 0xAFAFAFAA

Step III
Now you need to create the command.
Code:

CMD:helpme(playerid, params[])
{
        return 1;
}

Great! after you have done that, you need to create some strings.

Code:

CMD:helpme(playerid, params[])
{
        new text[60], new string[128], new string2[128];
}

the "text" is whatever the player types when he uses the command, example /helpme [text here], the "string" is used to send the message to admins, and the "string2" shows the player what he typed.

If you went this far, we will continue to Step IV

Step IV
Now we need to create a syntax message.
Code:

CMD:helpme(playerid, params[])
{
        new text[60], string[128], string2[128];
        if(sscanf(params,"s[60]",text)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /helpme [text]");
        return 1;
}

This sends a syntax message to player telling them how to use the command.

Let's continue to the Step V
Step V
We need to send the text to the admins now, we need to create "SendAdminMessage"
Code:

forward SendAdminMessage(color, string[]);
public SendAdminMessage(color, string[])
{
        foreach(Player, i)
        {
            if(PlayerInfo[i][pAdmin] >= 1) // The string will go to the player only if he's a level 1 or higher admin.
            {
                SendClientMessage(i, color, string);
            }
        }
}


Step VI
After you have created the "SendAdminMessage", you need to send the text that the player typed to the admins now.
Code:

CMD:helpme(playerid, params[])
{
        new text[60], string[128], string2[128];
        if(sscanf(params,"s[60]",text)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /helpme [text]");
        format(string, sizeof(string), "{ffa600}HELPME: {AFAFAF}%s has asked the question (%s)", GetName(playerid), text); //This is the message that the admins will see
        SendAdminMessage(COLOR_ORANGE, string);
        return 1;
}

But for that to work, you need to create a stock "GetName"

Code:

stock GetName( playerid )
{
        new szName[24];
        GetPlayerName( playerid, szName, 24); // This will get the player's name and will send it to the admins
        return szName;
}

Step VII
Now the text is sent to the administrators, but we need to send the message to the player too.
Code:

CMD:helpme(playerid, params[])
{
        new text[60], string[128], string2[128];
        if(sscanf(params,"s[60]",text)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /helpme [text]");
        format(string, sizeof(string), "{ffa600}HELPME: {AFAFAF}%s has asked the question (%s)", GetPlayerNameEx(playerid), text);
        SendAdminMessage(COLOR_ORANGE, string);
        format(string2, sizeof(string), "Your question, {8b0000}%s {AFAFAF}has been sent to the administrators, please wait for a response", text); //This is what the text will display to the player
        SendClientMessage(playerid, COLOR_GREY, string2); //This will send the text to the player
        return 1;
}

And that's all, I hope this will help you and please note that this is for beginners, other people can use it too, it's simple and short.


Pastebin (full script): https://pastebin.com/b7TFbch6
If you find any mistakes don't hesistate to tell me!

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>