PHP Code:
enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths,
pBanished,
pFaction,
pFacrank,
pFacleader,
pSkin
}
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("Faction",PlayerInfo[playerid][pFaction]);
INI_Int("Facrank",PlayerInfo[playerid][pFacrank]);
INI_Int("Facleader",PlayerInfo[playerid][pFacleader]);
INI_Int("Skin",PlayerInfo[playerid][pSkin]);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_WriteInt(File,"Faction",PlayerInfo[playerid][pFaction]);//saves the players faction id on disconnect
INI_WriteInt(File,"Facrank",PlayerInfo[playerid][pFacrank]);//saves the players faction rank on disconnect
INI_WriteInt(File,"Facleader",PlayerInfo[playerid][pFacleader]);//saves the players faction leadership status on disconnect
INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
INI_Close(File);
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_WriteInt(File,"Faction",0);
INI_WriteInt(File,"Facrank",0);
INI_WriteInt(File,"Facleader",0);
INI_WriteInt(File,"Skin",0);
INI_Close(File);
SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_WHITE"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_WHITE"You have successfully logged in!","Ok","");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
}
return 1;
}
}
}
return 1;
}
CMD:setskin(playerid, params[])
{
new userid, skinid;
if (sscanf(params, "ui", userid, skinid))
return SendClientMessage(playerid, COLOR_GRAD, "USAGE: /setskin [Playerid/PartOfName] [Skin ID]");
if (!IsPlayerConnected(userid))
return SendClientMessage(playerid, COLOR_GRAD, "That player is Offline!");
if (!(0 <= skinid <= 311))
return SendClientMessage(playerid, COLOR_GRAD, "Skin can't be below 0 or above 311");
SetPlayerSkin(userid, skinid);
pSkin[playerid] = skinid;
return 1;
}