pawn Код:
CMD:resetstats(playerid, params[])
{
new name[MAX_PLAYER_NAME];
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "Only Administrators can use this command."); //I wasn't sure if your Admin variable was in a separate enum, or whether you didn't have one at all
if(sscanf(params,"s[24]",name)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: {FFFFFF}/resetstats [Player Name]");
new string[150];
format(string, sizeof(string), UserPath, name);
if(!fexist(string)) return SendClientMessage(playerid, 0xFF0000FF, "This username does not exist in the database. Check your spelling, and capitals.");
new User[3];
User[0] = pInfo[playerid][DPoints];
User[1] = pInfo[playerid][DKills];
User[2] = pInfo[playerid][DDeaths];
INI_ParseFile(string, "LoadStats_%s", false, true, playerid);
new INI:file = INI_Open(string);
//INI_SetTag(file, "taghere"); //Replace 'taghere' with your own tag, if you're using one.
INI_WriteInt(file, "Points", pInfo[playerid][DPoints]); //Change 'Points' to whatever your file variable is
INI_WriteInt(file, "Kills", pInfo[playerid][DKills]); //Change 'Kills' to whatever your file variable is
INI_WriteInt(file, "Deaths", pInfo[playerid][DDeaths]); //Change 'Deaths' to whatever your file variable is
INI_Close(file);
pInfo[playerid][DPoints] = User[0];
pInfo[playerid][DKills] = User[1];
pInfo[playerid][DDeaths] = User[2];
SaveStats(playerid);
new playername[24];
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
format(string, sizeof(string), "Administrator %s has reset %s's statistics.", playername, name);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i)) //foreach is the better option
{
if(IsPlayerAdmin(i))
{
SendClientMessage(i, 0xFFFF00FF, string);
}
}
}
return 1;
}
forward LoadStats_data(playerid, name[], value[]); //Replace 'data' with whatever your tag is
public LoadStats_data(playerid, name[], value[])
{
INI_Int("Points", pInfo[playerid][DPoints]); //Change 'Points' to whatever your file variable is
INI_Int("Kills", pInfo[playerid][DKills]); //Change 'Kills' to whatever your file variable is
INI_Int("Death", pInfo[playerid][DDeaths]); //Change 'Deaths' to whatever your file variable is
return 1;
}
stock SaveStats(playerid)
{
new name[24];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
new string[150];
format(string, sizeof(string), UserPath, name);
if(!fexist(string)) return 1;
new INI:file = INI_Open(string);
INI_WriteInt(file, "Points", pInfo[playerid][DPoints]); //Change 'Points' to whatever your file variable is
INI_WriteInt(file, "Kills", pInfo[playerid][DKills]); //Change 'Kills' to whatever your file variable is
INI_WriteInt(file, "Deaths", pInfo[playerid][DDeaths]); //Change 'Deaths' to whatever your file variable is
INI_Close(file);
return 1;
}
Remember to replace your variables with your own, this is an example using the information you provided, so it may or may not work for you if you don't replace the variables.
EDIT: Like antonio said below, you can use MySQL I guess, but I've never used MySQL so I wouldn't be able to tell you.