SA-MP Forums Archive
How would one make a weapon not dissapear, even at 0 ammunition? - 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: How would one make a weapon not dissapear, even at 0 ammunition? (/showthread.php?tid=591084)



How would one make a weapon not dissapear, even at 0 ammunition? - rangerxxll - 07.10.2015

Self explanatory title. Is there an easy trick to do such a thing?

Example: Player crafts a 9mm with 0 ammo. Weapon is unusable, but still in inventory.


Re: How would one make a weapon not dissapear, even at 0 ammunition? - MrDiase - 07.10.2015

Sorry not quite understand, do not disappear or not finish the ammo of your hand? GivePlayerWeapon(playerid, ID, 99999); :-/ ??

@EDIT

ok ok hmm, 'l think it is not possible..


Re: How would one make a weapon not dissapear, even at 0 ammunition? - sanamalik400 - 07.10.2015

i think this is not possible.. not perfectly


AW: How would one make a weapon not dissapear, even at 0 ammunition? - Kaliber - 07.10.2015

Set the ammunation to infinity..an then newkeys & KEY_FIRE check if he had the disabled weapon and play a animation if he wanna shoot..like falling down or sth else


Re: How would one make a weapon not dissapear, even at 0 ammunition? - rangerxxll - 07.10.2015

There's no other way around it?


Re: How would one make a weapon not dissapear, even at 0 ammunition? - PrO.GameR - 07.10.2015

You should save it on a variable, it's not possible to keep it in the weapon reel, unless maybe you save a variable as soon as he fires his gun with 1 ammo, make it like WeaponDisabled[playerid][weaponid]=1, and check if thats 1, you play idle stance animation to cancel his shot nexttime


Re: How would one make a weapon not dissapear, even at 0 ammunition? - HydraHumza - 08.10.2015

How much i knew that weapon is disappear when you have 0 bullets this is how it works in SAMP. But i am not confirmed that is there any way that we can save that weapon in inventory. As if ur weapon is 0 bullet then it would be auto hide.but as i said as much i knew the gun would be disappear.


Re: How would one make a weapon not dissapear, even at 0 ammunition? - sanamalik400 - 08.10.2015

in my cod gm inventory disapear,,
but in my zombie gm,inventory not disapear,,even at 0 ammo


Re: How would one make a weapon not dissapear, even at 0 ammunition? - faff - 08.10.2015

Ehhh... Use "1 ammo" as 0 ammo.
PHP код:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
   new 
ammo GetPlayerAmmo(playerid); // Getting player his current ammo.
   
new weapon GetPlayerWeapon(playerid); // Getting player his current weapon.
   
if(ammo == 1){ // Check if player has 1 ammo.
   
SetPlayerAmmo(playeridweapon1); // Prevent the weapon from dissappearing.
   
return 0;} // Bullet won't do damage. 
   
else{
   return 
1;}

Tested it and works perfect.
It won't shoot any bullet when having 1 ammo.
REMINDER: Since a minigun and someother weapons are shooting to fast you'll have to raise the amount of ammo for these. Tested this with Desert Deagle, Colt45, Shotgun, Spaz-12 and Grenades and was working perfectly.
It didn't work with Miniguns since it was shooting to fast. Just raise up if(ammo == 1) to if(ammo == 2).


Re: How would one make a weapon not dissapear, even at 0 ammunition? - Patchwerk - 08.10.2015

You should use Attached object