saving weapon ammo problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: saving weapon ammo problem (
/showthread.php?tid=358819)
saving weapon ammo problem -
lewismichaelbbc - 11.07.2012
Код:
public SaveAmmo(playerid)
{
new weapon, ammo, gun;
GetPlayerWeaponData(playerid, gun, weapon, ammo);
switch(gun)
{
case 0:
{
PlayerInfo[playerid][pGunAmmo0] = ammo;
}
case 1:
{
PlayerInfo[playerid][pGunAmmo1] = ammo;
}
case 2:
{
PlayerInfo[playerid][pGunAmmo2] = ammo;
}
case 3:
{
PlayerInfo[playerid][pGunAmmo3] = ammo;
}
case 4:
{
PlayerInfo[playerid][pGunAmmo4] = ammo;
}
case 5:
{
PlayerInfo[playerid][pGunAmmo5] = ammo;
}
case 6:
{
PlayerInfo[playerid][pGunAmmo6] = ammo;
}
case 7:
{
PlayerInfo[playerid][pGunAmmo7] = ammo;
}
case 8:
{
PlayerInfo[playerid][pGunAmmo8] = ammo;
}
case 9:
{
PlayerInfo[playerid][pGunAmmo9] = ammo;
}
case 10:
{
PlayerInfo[playerid][pGunAmmo10] = ammo;
}
case 11:
{
PlayerInfo[playerid][pGunAmmo11] = ammo;
}
case 12:
{
PlayerInfo[playerid][pGunAmmo12] = ammo;
}
}
return 1;
}
I recreated the code, but it still doesnt work. Look above
Thanks
IT is still setting each variable as 0... why??!!
Re: saving weapon ammo problem -
lewismichaelbbc - 11.07.2012
Код:
public SaveAmmo(playerid)
{
new weapon, ammo, gun;
GetPlayerWeaponData(playerid, gun, weapon, ammo);
switch(gun)
{
case 0:
{
PlayerInfo[playerid][pGunAmmo0] = ammo;
}
case 1:
{
PlayerInfo[playerid][pGunAmmo1] = ammo;
}
case 2:
{
PlayerInfo[playerid][pGunAmmo2] = ammo;
}
case 3:
{
PlayerInfo[playerid][pGunAmmo3] = ammo;
}
case 4:
{
PlayerInfo[playerid][pGunAmmo4] = ammo;
}
case 5:
{
PlayerInfo[playerid][pGunAmmo5] = ammo;
}
case 6:
{
PlayerInfo[playerid][pGunAmmo6] = ammo;
}
case 7:
{
PlayerInfo[playerid][pGunAmmo7] = ammo;
}
case 8:
{
PlayerInfo[playerid][pGunAmmo8] = ammo;
}
case 9:
{
PlayerInfo[playerid][pGunAmmo9] = ammo;
}
case 10:
{
PlayerInfo[playerid][pGunAmmo10] = ammo;
}
case 11:
{
PlayerInfo[playerid][pGunAmmo11] = ammo;
}
case 12:
{
PlayerInfo[playerid][pGunAmmo12] = ammo;
}
}
return 1;
}
I recreated the code, but it still doesnt work. Look above
Thanks
p.s. sorry for double post
Re: saving weapon ammo problem -
Joe Staff - 11.07.2012
You're not using the function "GetPlayerWeaponData" properly.
pawn Код:
public SaveAmmo(playerid)
{
new weapon, ammo;
for(new gun; gun<12; gun++)
{
GetPlayerWeaponData(playerid, gun, weapon, ammo);
switch(gun)
{
case 0:
{
PlayerInfo[playerid][pGunAmmo0] = ammo;
}
case 1:
{
PlayerInfo[playerid][pGunAmmo1] = ammo;
}
case 2:
{
PlayerInfo[playerid][pGunAmmo2] = ammo;
}
case 3:
{
PlayerInfo[playerid][pGunAmmo3] = ammo;
}
case 4:
{
PlayerInfo[playerid][pGunAmmo4] = ammo;
}
case 5:
{
PlayerInfo[playerid][pGunAmmo5] = ammo;
}
case 6:
{
PlayerInfo[playerid][pGunAmmo6] = ammo;
}
case 7:
{
PlayerInfo[playerid][pGunAmmo7] = ammo;
}
case 8:
{
PlayerInfo[playerid][pGunAmmo8] = ammo;
}
case 9:
{
PlayerInfo[playerid][pGunAmmo9] = ammo;
}
case 10:
{
PlayerInfo[playerid][pGunAmmo10] = ammo;
}
case 11:
{
PlayerInfo[playerid][pGunAmmo11] = ammo;
}
case 12:
{
PlayerInfo[playerid][pGunAmmo12] = ammo;
}
}
}
return 1;
}
Edit: Also you're not saving the actual gun, only its ammo.
pawn Код:
PlayerInfo[playerid][pGun12] = weapon;
Re: saving weapon ammo problem -
Cypress - 11.07.2012
do pGunAmmo[13]
pGun[13]
use like PlayerInfo[playerid][pGunAmmo][0] , PlayerInfo[playerid][pGun][0]
pawn Код:
stock SavePlayerWeaponsAndAmmo(playerid)
{
new WeaponData[2];
for (new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, WeaponData[0], WeaponData[1]);
if(WeaponData[0] && WeaponData[1] && (WeaponData[1] < 65535 || !i || i == 1 || i == 10 || i == 12))
{
PlayerInfo[playerid][pGun][i] = WeaponData[0];
PlayerInfo[playerid][pGunAmmo][i] = WeaponData[1];
}
WeaponData[0] = 0;
WeaponData[1] = 0;
}
return 1;
}