Is there a way to stop guns being destroyed when ammo is 0?
#1

Title says all.

I'm trying to do different ammo types for guns so if they use one kind, I'd rather they didn't destroy the gun so they can load in new ammo?
Reply
#2

Maybe you could utilise objects?

https://sampwiki.blast.hk/wiki/Game_Object_ID_List
Reply
#3

I don't follow? All I need to know is if when ammo = 0 is there a way to make them keep the gun with 0 ammo?
Reply
#4

Quote:
Originally Posted by Dokins
Посмотреть сообщение
I don't follow? All I need to know is if when ammo = 0 is there a way to make them keep the gun with 0 ammo?
I'm not sure if that is possible, hence my idea of objects. Once you've run out of bullets for a gun, it would turn into the object version (see object list), once you have bullets again, the object is removed and the actual gun is put back in your hands.
Reply
#5

Alright, thank you.

Anyone else have an idea how I can do this also?
Reply
#6

I don't think this is possible with the way GTA handles the guns themselves. If a gun is empty, it is tossed away. What you CAN do is (note that it is a little hacky) always keep 1 bullet in the gun and then make it so that the gun cannot be shot when it only has one bullet left.
Reply
#7

Since 0.3z you can detect weapon firing state using OnPlayerWeaponShot. So using this you can check like if ammo is like near to or less than 2 ( if(ammo < 2) { ammo about to over } ). Because i am guessing that this callback count every single shot fired.
So maybe this might come usefull.
Else you can use a very quick timer or OnPlayerUpdate which aint the best thing to do though.
Reply
#8

What I can do is:

If the ammo type runs out in the gun, automatically set it to the standard rounds.
Reply
#9

Quote:
Originally Posted by Dokins
Посмотреть сообщение
What I can do is:

If the ammo type runs out in the gun, automatically set it to the standard rounds.
euhm what.?

Anyways i think using OnPlayerWeapon shoot itself you can prevent other players to get hit by returning specific value inside function (like 0 or 1 ,unsure).
e.g:
pawn Код:
OnPlayerWeaponShot(...)
{
       // get ammo and stuff
       if( ammo < 2 )
       {              
               if( hitid == ONE THAT IS TREATED AS PLAYER HIT )
               {
                    //he hitted with his last ammo to a player and make to make it isnt counted as a hit return 0 / 1;
                    return 0;
               }
               //give player one ammo;
       }
}
Though the code itself isnt correct therefore you need to work out with hit so as to make it in good working condition
Reply
#10

I've seen this kind of system in another server , just make a inventroy system and when it dedects the gun have 0 ammo its sends it to the inventory and you cant take it out untill you combine it with the ammo it needs.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)