14.07.2013, 18:44
(
Последний раз редактировалось Champ; 18.07.2013 в 18:21.
)
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.
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.
Explanation
This feature will open the suggestion log to save the suggestion of the player.
This feature will tell the usage of command, if a player not use it perfectly.
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.
This message will noticfy the player that your suggestion has been sent.
______________________________________________
Hope you have enjoyed the tutorial.
Thank You,
Champ.
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"
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;
}
pawn Код:
new File:Log = fopen(suggestPATH, io_append);
pawn Код:
if(sscanf(params,"s[128]",suggestion)) return SendClientMessage(playerid, COLOR_WHITE,"USAGE: /suggest [suggestion]");
pawn Код:
format(logData, sizeof logData, "%s has sent a suggestion: %s \r\n",pName,suggestion);
fwrite(Log, logData);
pawn Код:
fclose(Log);
pawn Код:
format(string,sizeof string,"[Suggestion] - Your Suggestion has been sent..",);
SendClientMessage(playerid,COLOR_GREEN,string);
______________________________________________
Hope you have enjoyed the tutorial.
Thank You,
Champ.