enum PInfo
{
pAdmin,
pVip,
pVehicle,
pDeaths,
pKills,
pMoney
}
//=====[STOCK1]=====//
stock USER_FILE(playerid)
{
new str[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(str, sizeof(str), USER_FILE_PATH, pName);
return str;
}
//=====[STOCK2]=====//
stock Load_Player_Stats(playerid)
{
PlayerInfo[playerid][pAdmin] = DOF2_GetInt(USER_FILE(playerid), "AdminLevel");
PlayerInfo[playerid][pVip] = DOF2_GetInt(USER_FILE(playerid), "VipLevel");
PlayerInfo[playerid][pVehicle] = DOF2_GetInt(USER_FILE(playerid), "Vehicle");
PlayerInfo[playerid][pDeaths] = DOF2_GetInt(USER_FILE(playerid), "Deaths");
PlayerInfo[playerid][pKills] = DOF2_GetInt(USER_FILE(playerid), "Kills");
PlayerInfo[playerid][pMoney] = DOF2_GetInt(USER_FILE(playerid), "Money");
GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
}
public OnPlayerConnect(playerid)
{
if(DOF2_FileExists(USER_FILE(playerid)))
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login",
"Type your password here to login !", #Login, #Quit);
}else{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Welcome ! Please register !",
"Type your password here to register!", #Register, #Quit);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
DOF2_SetInt(USER_FILE(playerid), "AdminLevel", PlayerInfo[playerid][pAdmin] );
DOF2_SetInt(USER_FILE(playerid), "VipLevel", PlayerInfo[playerid][pVip] );
DOF2_SetInt(USER_FILE(playerid), "Vehicle", PlayerInfo[playerid][pVehicle] );
DOF2_SetInt(USER_FILE(playerid), "Deaths", PlayerInfo[playerid][pDeaths] );
DOF2_SetInt(USER_FILE(playerid), "Kills", PlayerInfo[playerid][pKills] );
DOF2_SetInt(USER_FILE(playerid), "Money", PlayerInfo[playerid][pMoney] );
DOF2_SaveFile();
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_LOGIN, DIALOG_STYLE_INPUT,"Login",
"You have entered an invalid password ! \nType your password here to login !", #Register, #Quit);
DOF2_CreateFile(USER_FILE(playerid), inputtext);
DOF2_SetInt(USER_FILE(playerid), "AdminLevel", 0 );
DOF2_SetInt(USER_FILE(playerid), "VipLevel", 0 );
DOF2_SetInt(USER_FILE(playerid), "Vehicle", 0 );
DOF2_SetInt(USER_FILE(playerid), "Deaths", 0 );
DOF2_SetInt(USER_FILE(playerid), "Kills", 0 );
DOF2_SetInt(USER_FILE(playerid), "Money", 5000 );
DOF2_SaveFile();
SpawnPlayer(playerid);
GivePlayerMoney(playerid,5000);
}
}
case DIALOG_LOGIN:
{
if(!response) return Kick(playerid);
if(response)
{
if(DOF2_CheckLogin(USER_FILE(playerid), inputtext))
{
Load_Player_Stats(playerid);
}else{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login",
"You have entered an incorrect password. \nType your password below to login", #Login, #Quit);
}
return 1;
}
}
}
return 1;
}
new PlayerInfo[MAX_PLAYERS][pInfo];
enum pInfo
{
pAdmin,
pVip,
pVehicle,
pDeaths,
pKills,
pMoney
}
new PlayerInfo[MAX_PLAYERS][pInfo];
if(killerid != INVALID_PLAYER_ID)
{
PlayerInfo[playerid][pKills]++;
}
PlayerInfo[playerid][pDeaths]++;
Wait... I am stupid... money can be obtained only by jobs/commands/score etc.
So this means I will have to add PlayerInfo[playerid][pMoney] + 500 (example) to everything that gives money I just realised. I am dumb... you can lock this... |