12.10.2011, 14:37
I thought to add in my GM a command /suggest which writes on a text file (maybe in scriptfiles) all suggestions written by server users. Is it possible? How can I make it work?
forward SaveSuggestion(string[]); // forward our function
public SaveSuggestion(string[])
{
new entry[200]; // declare the variable entry with a 200 array size
format(entry, sizeof(entry), "%s\r\n",string); // format the entry. "%s" placeholder for strings
new File: hFile = fopen("Suggestions.log", io_append); // Declare, create and open our file, "Suggestions.log" wich will be located in scriptfiles
fwrite(hFile, entry); // Write in the file
fclose(hFile); // Close the fil
}
// ZCMD:
CMD:suggest(playerid, params[])
{
new string[ 128 ], name[ MAX_PLAYER_NAME ]; // Declare a string with a 128 array size and a variable "name" with array size "MAX_PLAYER_NAME"
// Wich holds the player maximum name. (24 char)
if(isnull(params)) return SendClientMessage(playerid, -1, "Syntax: /suggest [Suggestion]");// self-explinatory
GetPlayerName( playerid, name, MAX_PLAYER_NAME ); // we get the player name
format( string, sizeof( string ),"You suggested: %s", params); // we format our string
SendClientMessage(playerid, -1, string); // we send the player the message
format( string, sizeof( string ),"%s suggested %s", name, params); // we format our string for the log
SaveSuggestion(string); // we save in the log
return 1;
}