
enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths,
pNextVariable,
pVariableForSavingFactionRank,
pVariableForSavingFactionEtc
}
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
INI_Int("FactionRank",PlayerInfo[playerid][pVariableForSavingFactionRank]);
INI_Int("FactionEtc",PlayerInfo[playerid][pVariableForSavingFactionEtc]);
return 1;
}
INI_WriteInt(File,"FactionRank",0); //or any other value instead of 0
INI_WriteInt(File,"FactionEtc",0); //or any other value instead of 0
PlayerInfo[playerid][pVariableForSavingFactionEtc] = SOME_VARIABLE_ASSIGNED;
|
You start by adding variables you want to save in the enum:
Код:
enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths,
pNextVariable,
pVariableForSavingFactionRank,
pVariableForSavingFactionEtc
}
Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Password",PlayerInfo[playerid][pPass]);
INI_Int("Cash",PlayerInfo[playerid][pCash]);
INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
INI_Int("Kills",PlayerInfo[playerid][pKills]);
INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
INI_Int("FactionRank",PlayerInfo[playerid][pVariableForSavingFactionRank]);
INI_Int("FactionEtc",PlayerInfo[playerid][pVariableForSavingFactionEtc]);
return 1;
}
Код:
INI_WriteInt(File,"FactionRank",0); //or any other value instead of 0
INI_WriteInt(File,"FactionEtc",0); //or any other value instead of 0
Код:
PlayerInfo[playerid][pVariableForSavingFactionEtc] = SOME_VARIABLE_ASSIGNED; |
CMD:money(playerid, params[])
{
if(IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_ADM, "* [AdmCMD]: You have recived 100,000$!");
GivePlayerMoney(playerid, 100000);
new INI:file = INI_Open(UserPath(playerid));
INI_SetTag(file,"PlayerInfo");
INI_WriteInt(file, "Money", PlayerInfo[playerid][Money]);
INI_Close(file);
}
else SendClientMessage(playerid, COLOR_SYS, "* [SYSTEM]: You are not an admin!");
return 1;
}
//stats cmds
CMD:stats(playerid, params[])
{
new money = PlayerInfo[playerid][Money];
new deaths = PlayerInfo[playerid][Deaths];
new kills = PlayerInfo[playerid][Kills];
new score = PlayerInfo[playerid][Score];
new admin = PlayerInfo[playerid][AdminLevel];
new string[128];
format(string, sizeof(string), "[General] - [Money: %d] | [Deaths: %d] | [Kills: %d] | [Score: %d] | [Admin Level: %d]", money, deaths, kills, score, admin);
SendClientMessage(playerid, COLOR_GREEN, string);
return 1;
}