15.03.2013, 17:38
So, the weapons save into the user file, but they don't get loaded upon user login
^ That saves the weapons alright...
When the user joins, with valid weapons and ammos saved in their file, the user has no weapons, upon exiting, all weapons/ammos are set to 0 in the user's file. All of the other things work (password, isbanned, money, skin, etc). Why isn't the weapons being applied on login?
pawn Код:
enum cVars
{
Name[128],
Password[128],
Faction[128],
Banned,
Reason[128],
IsJailed,
JReason[128],
Vehicle,
Vehicle_Color1,
Vehicle_Color2,
NewbMute,
NewbMutes,
TimesBanned,
TimesKicked,
OOCmute,
OOCmutes,
Admin,
Skin,
Money,
Float: LastX,
Float: LastY,
Float: LastZ,
Float: LastA,
Interior,
Weaponslot1,
Weaponslot1_ammo,
Weaponslot2,
Weaponslot2_ammo,
Weaponslot3,
Weaponslot3_ammo,
Weaponslot4,
Weaponslot4_ammo,
Weaponslot5,
Weaponslot5_ammo,
Weaponslot6,
Weaponslot6_ammo,
Weaponslot7,
Weaponslot7_ammo,
Weaponslot8,
Weaponslot8_ammo,
Weaponslot9,
Weaponslot9_ammo,
Weaponslot10,
Weaponslot10_ammo,
Weaponslot11,
Weaponslot11_ammo,
Weaponslot12,
Weaponslot12_ammo,
Weaponslot13,
Weaponslot13_ammo,
}
forward LoadPlayer_info ( playerid, name[], value[] );
public LoadPlayer_info ( playerid, name[], value[] )
{
INI_String("name", pInfo[playerid][Name], 128);
INI_String("password", pInfo[playerid][Password], 128);
INI_String("faction", pInfo[playerid][Faction], 128);
INI_Int("admin", pInfo[playerid][Admin]);
INI_Int("banned", pInfo[playerid][Banned]);
INI_String("reason", pInfo[playerid][Reason], 128);
INI_Int("IsJailed", pInfo[playerid][IsJailed]);
INI_String("jreason", pInfo[playerid][JReason], 128);
INI_Int("vehicle", pInfo[playerid][Vehicle]);
INI_Int("vehicle_color1", pInfo[playerid][Vehicle_Color1]);
INI_Int("vehicle_color2", pInfo[playerid][Vehicle_Color2]);
INI_Int("TimesBanned", pInfo[playerid][TimesBanned]);
INI_Int("TimesKicked", pInfo[playerid][TimesKicked]);
INI_Int("NewbMute", pInfo[playerid][NewbMute]);
INI_Int("NewbMutes", pInfo[playerid][NewbMutes]);
INI_Int("OOCmute", pInfo[playerid][OOCmute]);
INI_Int("OOCmutes", pInfo[playerid][OOCmutes]);
INI_Int("money", pInfo[playerid][Money]);
INI_Int("skin", pInfo[playerid][Skin]);
INI_Float("locx", pInfo[playerid][LastX]);
INI_Float("locy", pInfo[playerid][LastY]);
INI_Float("locz", pInfo[playerid][LastZ]);
INI_Float("locr", pInfo[playerid][LastA]);
INI_Int("interior", pInfo[playerid][Interior]);
INI_Int("weaponslot1", pInfo[playerid][Weaponslot1]);
INI_Int("weaponslot1_ammo", pInfo[playerid][Weaponslot1_ammo]);
INI_Int("weaponslot2", pInfo[playerid][Weaponslot2]);
INI_Int("weaponslot2_ammo", pInfo[playerid][Weaponslot2_ammo]);
INI_Int("weaponslot3", pInfo[playerid][Weaponslot3]);
INI_Int("weaponslot3_ammo", pInfo[playerid][Weaponslot3_ammo]);
INI_Int("weaponslot4", pInfo[playerid][Weaponslot4]);
INI_Int("weaponslot4_ammo", pInfo[playerid][Weaponslot4_ammo]);
INI_Int("weaponslot5", pInfo[playerid][Weaponslot5]);
INI_Int("weaponslot5_ammo", pInfo[playerid][Weaponslot5_ammo]);
INI_Int("weaponslot6", pInfo[playerid][Weaponslot6]);
INI_Int("weaponslot6_ammo", pInfo[playerid][Weaponslot6_ammo]);
INI_Int("weaponslot7", pInfo[playerid][Weaponslot7]);
INI_Int("weaponslot7_ammo", pInfo[playerid][Weaponslot7_ammo]);
INI_Int("weaponslot8", pInfo[playerid][Weaponslot8]);
INI_Int("weaponslot8_ammo", pInfo[playerid][Weaponslot8_ammo]);
INI_Int("weaponslot9", pInfo[playerid][Weaponslot9]);
INI_Int("weaponslot9_ammo", pInfo[playerid][Weaponslot9_ammo]);
INI_Int("weaponslot10", pInfo[playerid][Weaponslot10]);
INI_Int("weaponslot10_ammo", pInfo[playerid][Weaponslot10_ammo]);
INI_Int("weaponslot11", pInfo[playerid][Weaponslot11]);
INI_Int("weaponslot11_ammo", pInfo[playerid][Weaponslot11_ammo]);
INI_Int("weaponslot12", pInfo[playerid][Weaponslot12]);
INI_Int("weaponslot12_ammo", pInfo[playerid][Weaponslot12_ammo]);
INI_Int("weaponslot13", pInfo[playerid][Weaponslot13]);
INI_Int("weaponslot13_ammo", pInfo[playerid][Weaponslot13_ammo]);
return true;
}
stock ResetpInfo(pid)
{
pInfo[pid][Admin] = 0;
pInfo[pid][Faction] = 0;
pInfo[pid][Money] = 0;
pInfo[pid][Skin] = 0;
pInfo[pid][LastX] = 0.0;
pInfo[pid][LastY] = 0.0;
pInfo[pid][LastZ] = 0.0;
pInfo[pid][LastA] = 0.0;
pInfo[pid][Banned] = 0;
pInfo[pid][Reason] = 0;
pInfo[pid][IsJailed] = 0;
pInfo[pid][JReason] = 0;
pInfo[pid][Vehicle] = 0;
pInfo[pid][Vehicle_Color1] = 0;
pInfo[pid][Vehicle_Color2] = 0;
pInfo[pid][TimesBanned] = 0;
pInfo[pid][TimesKicked] = 0;
pInfo[pid][NewbMute] = 0;
pInfo[pid][NewbMutes] = 0;
pInfo[pid][OOCmute] = 0;
pInfo[pid][OOCmutes] = 0;
pInfo[pid][Interior] = 0;
pInfo[pid][Weaponslot1] = 0;
pInfo[pid][Weaponslot1_ammo] = 0;
pInfo[pid][Weaponslot2] = 0;
pInfo[pid][Weaponslot2_ammo] = 0;
pInfo[pid][Weaponslot3] = 0;
pInfo[pid][Weaponslot3_ammo] = 0;
pInfo[pid][Weaponslot4] = 0;
pInfo[pid][Weaponslot4_ammo] = 0;
pInfo[pid][Weaponslot5] = 0;
pInfo[pid][Weaponslot5_ammo] = 0;
pInfo[pid][Weaponslot6] = 0;
pInfo[pid][Weaponslot6_ammo] = 0;
pInfo[pid][Weaponslot7] = 0;
pInfo[pid][Weaponslot7_ammo] = 0;
pInfo[pid][Weaponslot8] = 0;
pInfo[pid][Weaponslot8_ammo] = 0;
pInfo[pid][Weaponslot9] = 0;
pInfo[pid][Weaponslot9_ammo] = 0;
pInfo[pid][Weaponslot10] = 0;
pInfo[pid][Weaponslot10_ammo] = 0;
pInfo[pid][Weaponslot11] = 0;
pInfo[pid][Weaponslot11_ammo] = 0;
pInfo[pid][Weaponslot12] = 0;
pInfo[pid][Weaponslot12_ammo] = 0;
pInfo[pid][Weaponslot13] = 0;
pInfo[pid][Weaponslot13_ammo] = 0;
return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid)
{
//OTHER CODE
for (new i = 0; i < 13; i++)
{
new weaponslot[128];
new weaponslot_ammo[128];
format(weaponslot, sizeof(weaponslot), "weaponslot%i", i);
format(weaponslot_ammo, sizeof(weaponslot_ammo), "weaponslot%i_ammo", i);
GetPlayerWeaponData(playerid, i, weapons[playerid][i][0], weapons[playerid][i][1]);
INI_WriteInt(myFile, weaponslot, weapons[playerid][i][0]);
INI_WriteInt(myFile, weaponslot_ammo, weapons[playerid][i][1]);
}
//OTHER CODE
}
pawn Код:
//part of loading variables when user logs in
GivePlayerWeapon(playerid, pInfo[playerid][Weaponslot1], pInfo[playerid][Weaponslot1_ammo]);
GivePlayerWeapon(playerid, pInfo[playerid][Weaponslot2], pInfo[playerid][Weaponslot2_ammo]);
GivePlayerWeapon(playerid, pInfo[playerid][Weaponslot3], pInfo[playerid][Weaponslot3_ammo]);
GivePlayerWeapon(playerid, pInfo[playerid][Weaponslot4], pInfo[playerid][Weaponslot4_ammo]);
GivePlayerWeapon(playerid, pInfo[playerid][Weaponslot5], pInfo[playerid][Weaponslot5_ammo]);
GivePlayerWeapon(playerid, pInfo[playerid][Weaponslot6], pInfo[playerid][Weaponslot6_ammo]);
GivePlayerWeapon(playerid, pInfo[playerid][Weaponslot7], pInfo[playerid][Weaponslot7_ammo]);
GivePlayerWeapon(playerid, pInfo[playerid][Weaponslot8], pInfo[playerid][Weaponslot8_ammo]);
GivePlayerWeapon(playerid, pInfo[playerid][Weaponslot9], pInfo[playerid][Weaponslot9_ammo]);
GivePlayerWeapon(playerid, pInfo[playerid][Weaponslot10], pInfo[playerid][Weaponslot10_ammo]);
GivePlayerWeapon(playerid, pInfo[playerid][Weaponslot11], pInfo[playerid][Weaponslot11_ammo]);
GivePlayerWeapon(playerid, pInfo[playerid][Weaponslot12], pInfo[playerid][Weaponslot12_ammo]);
GivePlayerWeapon(playerid, pInfo[playerid][Weaponslot12], pInfo[playerid][Weaponslot13_ammo]);