[Tutorial] [Beginners Tutorial] Making a Suggest Command - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (
https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] [Beginners Tutorial] Making a Suggest Command (
/showthread.php?tid=450803)
[Beginners Tutorial] Making a Suggest Command -
Champ - 14.07.2013
Making a Suggest Command
Today, I am making a tutorial on how to create a /suggest command. Through this command, Players can send you suggestions directly from the server and all suggestions will be saved in a file.
Lets Start !
First Step
1st step is to creating a file in which all suggestion will be saved. To make a folder we have to define the location of the folder. So make a folder in script files.
pawn Код:
#define suggestPATH "Suggestions/SuggestLog.txt"
Explanation
The suggestPATH define that where the folder and the log is located. Before testing this system, you must create a file in the script files. You can change the folder name to whatever you want but the folder name should be correct and should match the suggestPATH.
Second Step
2nd step is to creating a command which will make players able to send their suggestions. And for this I am using Zcmd.
pawn Код:
COMMAND:suggest(playerid, params[])
{
new string[128],suggestion[128],pName[MAX_PLAYER_NAME];
new File:Log = fopen(suggestPATH, io_append);
new logData[128];
if(sscanf(params,"s[128]",suggestion)) return SendClientMessage(playerid, COLOR_WHITE,"USAGE: /suggest [suggestion]");
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
SendClientMessage(playerid, COLOR_LIGHTGREEN, "Your suggestion report has been saved in a file. Thankyou!");
format(logData, sizeof logData, "%s has sent a suggestion: %s \r\n",pName,suggestion);
fwrite(Log, logData);
fclose(Log);
format(string,sizeof string,"[Suggestion] - Your Suggestion has been sent..",);
SendClientMessage(playerid,COLOR_GREEN,string);
return 1;
}
Explanation
pawn Код:
new File:Log = fopen(suggestPATH, io_append);
This feature will open the suggestion log to save the suggestion of the player.
pawn Код:
if(sscanf(params,"s[128]",suggestion)) return SendClientMessage(playerid, COLOR_WHITE,"USAGE: /suggest [suggestion]");
This feature will tell the usage of command, if a player not use it perfectly.
pawn Код:
format(logData, sizeof logData, "%s has sent a suggestion: %s \r\n",pName,suggestion);
fwrite(Log, logData);
This is the format of the text. This format will be saved in the log with the player name and his suggestion. You can set it to your own but don't remove "%s" from the format.
After being sent of suggestion. This feature will close the log.
pawn Код:
format(string,sizeof string,"[Suggestion] - Your Suggestion has been sent..",);
SendClientMessage(playerid,COLOR_GREEN,string);
This message will noticfy the player that your suggestion has been sent.
______________________________________________
Hope you have enjoyed the tutorial.
Thank You,
Champ.
Re: [Beginners Tutorial] Making a Suggest Command -
SsHady - 14.07.2013
Awesome tutorial,
Nicely Explained
1+
Re: [Beginners Tutorial] Making a Suggest Command -
Champ - 14.07.2013
Thanks for you nice feedback. Sshady.
Re: [Beginners Tutorial] Making a Suggest Command -
Champ - 15.07.2013
No More feedbacks ??
Re: [Beginners Tutorial] Making a Suggest Command -
[D]ry[D]esert - 18.07.2013
pawn Код:
new string[128],suggestion,pName[MAX_PLAYER_NAME]; //You must put suggestion[128]
So it must be like this
pawn Код:
new string[128],suggestion[128],pName[MAX_PLAYER_NAME];
Re: [Beginners Tutorial] Making a Suggest Command -
Champ - 18.07.2013
[D]ry[D]esert
We are not using suggestion as a string.
We are using suggestion to show the text of the player.
Re: [Beginners Tutorial] Making a Suggest Command -
SuperViper - 18.07.2013
DryDesert is right. Did you even test this before writing a tutorial on it?
Re: [Beginners Tutorial] Making a Suggest Command -
Champ - 18.07.2013
SuperViper, I have tested this many times. It is working good.
Re: [Beginners Tutorial] Making a Suggest Command -
SwisherSweet - 18.07.2013
Champ he is right
Re: [Beginners Tutorial] Making a Suggest Command -
Champ - 18.07.2013
Thanks for noticing. Any other errors?