Saving weapons with ammo over 9998 - 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 weapons with ammo over 9998 (
/showthread.php?tid=418006)
Saving weapons with ammo over 9998 -
SKAzini - 23.02.2013
Some weapons will become infinite when ammo is set to 9999, however with my code (if weapon ammo is infinite), the weapons will become bugged.
OnPlayerDeath:
pawn Код:
for (new i = 0; i < 13; i++) GetPlayerWeaponData(playerid, i, PAdminDeathWeapons[playerid][i][0], PAdminDeathWeapons[playerid][i][1]);
SetSpawnInfo(playerid, 0, UserStats[playerid][Skin], x, y, z, 0, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
SetPlayerHealth(playerid, 100);
SetTimerEx("DeathGiveWep", 750, false, "i", playerid);
pawn Код:
public DeathGiveWep(playerid)
{
for (new i = 0; i < 13; i++)
{
GivePlayerWeapon(playerid, PAdminDeathWeapons[playerid][i][0], PAdminDeathWeapons[playerid][i][1]);
}
}
It loops through all weapon slots and saves the weapons to an array, then when they respawn it gives them the weapons again with the same ammo amount.
So basically, if I /givewep 0 24 9999 the Desert Eagle ammunition is infinite, when I die and I get the weapon again, I can't switch to it as it is bugged with an ammo which seems to be something like -1 ...
If I set the ammo to a lower amount than 9999 it works, however.
Any fix for this?
Re: Saving weapons with ammo over 9998 -
[MG]Dimi - 23.02.2013
When Ammo is infinite it doesn't save as 9999 or any higher number, it saves as -.... so do
pawn Код:
public DeathGiveWep(playerid)
{
for (new i = 0; i < 13; i++)
{
if(PAdminDeathWeapons[playerid][i][1] < 0) PAdminDeathWeapons[playerid][i][1] = 99999;
GivePlayerWeapon(playerid, PAdminDeathWeapons[playerid][i][0], PAdminDeathWeapons[playerid][i][1]);
}
}