04.05.2014, 23:31
Hello everyone.
I'm simply trying to save a players weapon data and load it when they log in. Once they successfully log in I'm looking to give them the weapons which save as integers (same with ammo.)
Before I show you the code, I'd like to say that I've only included 7 weapon saves instead of the full 12. I'm using this primarily for testing purposes.
I'm simply trying to save a players weapon data and load it when they log in. Once they successfully log in I'm looking to give them the weapons which save as integers (same with ammo.)
Before I show you the code, I'd like to say that I've only included 7 weapon saves instead of the full 12. I'm using this primarily for testing purposes.
pawn Код:
enum PlayerInfo
{
pMoney,
pScore,
pAdmin,
pVip,
pPass,
pTeam,
pSkin,
pKills,
pDeaths,
pWanted,
pHitAmount,
Float:px,
Float:py,
Float:pz,
Float:pa,
Float:pHealth,
Float:pArmour,
pWeapon1,
pWeapon1a,
pWeapon2,
pWeapon2a,
pWeapon3,
pWeapon3a,
pWeapon4,
pWeapon4a,
pWeapon5,
pWeapon5a,
pWeapon6,
pWeapon6a,
pWeapon7,
pWeapon7a
};
stock SaveAccount(playerid)
{
new INI:file = INI_Open(UserPath(playerid));
GetPlayerPos(playerid, pInfo[playerid][px], pInfo[playerid][py], pInfo[playerid][pz]);
GetPlayerFacingAngle(playerid, pInfo[playerid][pa]);
GetPlayerHealth(playerid, pInfo[playerid][pHealth]);
GetPlayerArmour(playerid, pInfo[playerid][pArmour]);
GetPlayerWeaponData(playerid, 1, pInfo[playerid][pWeapon1], pInfo[playerid][pWeapon1a]);
GetPlayerWeaponData(playerid, 2, pInfo[playerid][pWeapon2], pInfo[playerid][pWeapon2a]);
GetPlayerWeaponData(playerid, 3, pInfo[playerid][pWeapon3], pInfo[playerid][pWeapon3a]);
GetPlayerWeaponData(playerid, 4, pInfo[playerid][pWeapon4], pInfo[playerid][pWeapon4a]);
GetPlayerWeaponData(playerid, 5, pInfo[playerid][pWeapon5], pInfo[playerid][pWeapon5a]);
GetPlayerWeaponData(playerid, 6, pInfo[playerid][pWeapon6], pInfo[playerid][pWeapon6a]);
GetPlayerWeaponData(playerid, 7, pInfo[playerid][pWeapon7], pInfo[playerid][pWeapon7a]);
INI_SetTag(file, "Player Data");
INI_WriteInt(file, "Money", GetPlayerMoney(playerid));
INI_WriteInt(file, "Score", GetPlayerScore(playerid));
INI_WriteInt(file, "Admin", pInfo[playerid][pAdmin]);
INI_WriteInt(file, "Vip", pInfo[playerid][pVip]);
INI_WriteInt(file, "Team", pInfo[playerid][pTeam]);
INI_WriteInt(file, "Skin", GetPlayerSkin(playerid));
INI_WriteInt(file, "Kills", pInfo[playerid][pKills]);
INI_WriteInt(file, "Deaths", pInfo[playerid][pDeaths]);
INI_WriteInt(file, "Wanted", GetPlayerWantedLevel(playerid));
INI_WriteInt(file, "HitAmount", pInfo[playerid][pHitAmount]);
INI_WriteFloat(file, "px", pInfo[playerid][px]);
INI_WriteFloat(file, "py", pInfo[playerid][py]);
INI_WriteFloat(file, "pz", pInfo[playerid][pz]);
INI_WriteFloat(file, "pa", pInfo[playerid][pa]);
INI_WriteFloat(file, "Health", pInfo[playerid][pHealth]);
INI_WriteFloat(file, "Armour", pInfo[playerid][pArmour]);
INI_WriteInt(file, "Weapon1", pInfo[playerid][pWeapon1]);
INI_WriteInt(file, "Weapon1a", pInfo[playerid][pWeapon1a]);
INI_WriteInt(file, "Weapon2", pInfo[playerid][pWeapon2]);
INI_WriteInt(file, "Weapon2a", pInfo[playerid][pWeapon2a]);
INI_WriteInt(file, "Weapon3", pInfo[playerid][pWeapon3]);
INI_WriteInt(file, "Weapon3a", pInfo[playerid][pWeapon3a]);
INI_WriteInt(file, "Weapon4", pInfo[playerid][pWeapon4]);
INI_WriteInt(file, "Weapon4a", pInfo[playerid][pWeapon4a]);
INI_WriteInt(file, "Weapon5", pInfo[playerid][pWeapon5]);
INI_WriteInt(file, "Weapon5a", pInfo[playerid][pWeapon5a]);
INI_WriteInt(file, "Weapon6", pInfo[playerid][pWeapon6]);
INI_WriteInt(file, "Weapon6a", pInfo[playerid][pWeapon6a]);
INI_WriteInt(file, "Weapon7", pInfo[playerid][pWeapon7]);
INI_WriteInt(file, "Weapon7a", pInfo[playerid][pWeapon7a]);
INI_Close(file);
return 1;
}
public LoadAccount_data(playerid, name[], value[])
{
INI_Int("Password", pInfo[playerid][pPass]);
INI_Int("Money", pInfo[playerid][pMoney]);
INI_Int("Score", pInfo[playerid][pScore]);
INI_Int("Admin", pInfo[playerid][pAdmin]);
INI_Int("Vip", pInfo[playerid][pVip]);
INI_Int("Team", pInfo[playerid][pTeam]);
INI_Int("Skin", pInfo[playerid][pSkin]);
INI_Int("Kills", pInfo[playerid][pKills]);
INI_Int("Deaths", pInfo[playerid][pDeaths]);
INI_Int("Wanted", pInfo[playerid][pWanted]);
INI_Int("HitAmount", pInfo[playerid][pHitAmount]);
INI_Float("px", pInfo[playerid][px]);
INI_Float("py", pInfo[playerid][py]);
INI_Float("pz", pInfo[playerid][pz]);
INI_Float("pa",pInfo[playerid][pa]);
INI_Float("Armour", pInfo[playerid][pArmour]);
INI_Float("Health", pInfo[playerid][pHealth]);
INI_Int("Weapon1", pInfo[playerid][pWeapon1]);
INI_Int("Weapon1a", pInfo[playerid][pWeapon1a]);
INI_Int("Weapon2", pInfo[playerid][pWeapon2]);
INI_Int("Weapon2a", pInfo[playerid][pWeapon2a]);
INI_Int("Weapon3", pInfo[playerid][pWeapon3]);
INI_Int("Weapon3a", pInfo[playerid][pWeapon3a]);
INI_Int("Weapon4", pInfo[playerid][pWeapon4]);
INI_Int("Weapon4a", pInfo[playerid][pWeapon4a]);
INI_Int("Weapon5", pInfo[playerid][pWeapon5]);
INI_Int("Weapon5a", pInfo[playerid][pWeapon5a]);
INI_Int("Weapon6", pInfo[playerid][pWeapon6]);
INI_Int("Weapon6a", pInfo[playerid][pWeapon6a]);
INI_Int("Weapon7", pInfo[playerid][pWeapon7]);
INI_Int("Weapon7a", pInfo[playerid][pWeapon7a]);
return 1;
}
//For the login dialog.
if(udb_hash(inputtext) == pInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadAccount_data", .bExtra = true, .extra = playerid);
SetPlayerScore(playerid, pInfo[playerid][pScore]);
SetPlayerSkin(playerid, pInfo[playerid][pSkin]);
GivePlayerMoney(playerid, pInfo[playerid][pMoney]);
SetPlayerHealth(playerid, pInfo[playerid][pHealth]);
SetPlayerArmour(playerid, pInfo[playerid][pArmour]);
GivePlayerWeapon(playerid, pInfo[playerid][pWeapon1], pInfo[playerid][pWeapon1a]);
GivePlayerWeapon(playerid, pInfo[playerid][pWeapon2], pInfo[playerid][pWeapon2a]);
GivePlayerWeapon(playerid, pInfo[playerid][pWeapon3], pInfo[playerid][pWeapon3a]);
GivePlayerWeapon(playerid, pInfo[playerid][pWeapon4], pInfo[playerid][pWeapon4a]);
GivePlayerWeapon(playerid, pInfo[playerid][pWeapon5], pInfo[playerid][pWeapon5a]);
GivePlayerWeapon(playerid, pInfo[playerid][pWeapon6], pInfo[playerid][pWeapon6a]);
GivePlayerWeapon(playerid, pInfo[playerid][pWeapon7], pInfo[playerid][pWeapon7a]);
PlayerSpawned[playerid] = true;
}