03.05.2012, 21:31
I made a simple rate system so simple but I want to create a txt so when people /rate it will put the name of the one who rated the server like.
Mark_Smith /rate *****
dini?
Mark_Smith /rate *****
dini?
I made a simple rate system so simple but I want to create a txt so when people /rate it will put the name of the one who rated the server like.
Mark_Smith /rate ***** dini? |
I would use MySQL as my whole server is MySQL, anyway if you've already made the command and are thinking to save the player names with their rate number is to use the file base saving system like Dini, Yini, etc and if database system it could be MySQL, SQLite etc
-FalconX |
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;
}
Assuming you just want to write to a file, you don't need MySQL for something so simple.
pawn Код:
|