08.03.2014, 20:52
Well, I have another issue now.
I started coding a weapon saving system so when the user logs off it should save his weapon and return it to him when he logs back in, the only problem with that, its not doing that.
This is the enum for the inventory, right now, just containing the weapons and ammo, but will be expanded when I fix this.
Those are the stocks for saving and providing the user with their weapons, those stocks are called appropriately:
Those are the calls for the Weapon system, to Save and Give the weapons out, respectively.
I just cant figure out why the weapons aren't saving and being given out to the player, the only error I get is yini saying it cant find the player profile, but it can normally find it, I think thats something to do with the stock.
I'm pretty sure its something to do with the variables I'm using, also, credits for the Weapon stocks goto another user on the forums, I just changed them, it appears, for the worse of things lol.
Any help would be appreciated,
Thanks,
Zonoya.
I started coding a weapon saving system so when the user logs off it should save his weapon and return it to him when he logs back in, the only problem with that, its not doing that.
Код:
enum pInv { iWeapons[13], iWeaponammo[13] } new PlayerInv[MAX_PLAYERS][pInv][14];
Код:
stock SavePlayerWeapons(playerid) { for(new x; x < 13; x++) { new weaponid = PlayerInv[playerid][iWeapons][x]; new ammo = PlayerInv[playerid][iWeaponammo][x]; GetPlayerWeaponData(playerid, x, weaponid, ammo); new INI:File = INI_Open(UserPath(playerid)); INI_WriteInt(File,"Weapons",PlayerInv[playerid][iWeapons][13]); INI_WriteInt(File,"Weapon_Ammo",PlayerInv[playerid][iWeaponammo][13]); INI_Close(File); } return 0; } stock GivePlayerSavedWeapons(playerid) { for(new x; x < 13; x++) { SetPlayerArmedWeapon(playerid, 0); new weaponid = PlayerInv[playerid][iWeapons][x]; new ammo = PlayerInv[playerid][iWeaponammo][x]; GivePlayerWeapon(playerid, weaponid, ammo); } return 0; }
Код:
public OnPlayerDisconnect(playerid, reason) { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"Player Statistics"); INI_WriteInt(File,"Cash",GetPlayerMoney(playerid)); INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdminLevel]); INI_WriteInt(File,"Score",GetPlayerScore(playerid)); INI_SetTag(File,"Player Inventory"); INI_WriteInt(File,"Job_Certificate",PlayerInfo[playerid][pJobCert]); SavePlayerWeapons(playerid); INI_Close(File); VGod[playerid] = 0; return 1; } public OnPlayerSpawn(playerid) { SetPlayerInterior(playerid,0); TogglePlayerClock(playerid,1); SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL, 0); SetPlayerSkillLevel(playerid, WEAPONSKILL_PISTOL_SILENCED, 0 if(GetPlayerTeam(playerid) == Cops) { SetPlayerColor(playerid, CopsColor); SetPlayerPos(playerid, 2267.9407,2448.7957,3.5313); PlayerTextDrawHide(playerid, Textdraw0); PlayerTextDrawHide(playerid, Textdraw1); PlayerTextDrawHide(playerid, Textdraw2); PlayerTextDrawHide(playerid, Textdraw3); PlayerTextDrawHide(playerid, Textdraw4); GivePlayerSavedWeapons(playerid); } else if(GetPlayerTeam(playerid) == Robbers) { SetPlayerColor(playerid, RobbersColor); SetPlayerRandomRobbersSpawn(playerid); PlayerTextDrawHide(playerid, Textdraw0); PlayerTextDrawHide(playerid, Textdraw1); PlayerTextDrawHide(playerid, Textdraw2); PlayerTextDrawHide(playerid, Textdraw3); PlayerTextDrawHide(playerid, Textdraw4); GivePlayerSavedWeapons(playerid); } else if(GetPlayerTeam(playerid) == BaitCar) { SetPlayerColor(playerid, BaitCarColor); SetPlayerPos(playerid, 2267.9407,2448.7957,3.5313); PlayerTextDrawShow(playerid, Textdraw0); PlayerTextDrawShow(playerid, Textdraw1); PlayerTextDrawShow(playerid, Textdraw2); PlayerTextDrawShow(playerid, Textdraw3); PlayerTextDrawShow(playerid, Textdraw4); GivePlayerSavedWeapons(playerid); } return 1; }
I just cant figure out why the weapons aren't saving and being given out to the player, the only error I get is yini saying it cant find the player profile, but it can normally find it, I think thats something to do with the stock.
I'm pretty sure its something to do with the variables I'm using, also, credits for the Weapon stocks goto another user on the forums, I just changed them, it appears, for the worse of things lol.
Any help would be appreciated,
Thanks,
Zonoya.