03.05.2012, 21:50
Assuming you just want to write to a file, you don't need MySQL for something so simple.
pawn Код:
CMD:rate(playerid, params[])
{
new
rate, // The amount they will rate
name[24], // The player's name
string[128] // The string we will format
;
if(sscanf(params, "d", rate)) // if they didn't type a number
{
// Then tell the player how to use the command
return SendClientMessage(playerid, -1, "USAGE: /rate [amount]");
}
if(rate > 5 || rate < 0)
{
// If the number they typed was less than 0 or more than 5
// then it sends a message saying so.
return SendClientMessage(playerid, -1, "Don't go below 0 or 5");
}
else // If they typed a number in between zero and five.
{
new File:rating = fopen("ratings.txt", io_append); // Open the file for writing.
GetPlayerName(playerid, name, 24); // Get the name and store it into 'name'
format(string, 127, "User %s rated the server %d stars.", name, rate); // format the string
fwrite(rating, string); // Write the string above.
fclose(rating); // close the file
}
return 1;
}