View Issue Details

IDProjectCategoryView StatusLast Update
0009767New issuesScriptingpublic2017-11-29 16:08
ReporterXMLAssigned To 
Status newResolutionopen 
Summary0009767: takeWeapon problems

the problem in this code is
the weapon doesn't really disappear when you take all of the ammo
from the gun, using the third argument in this function to determine
how much of bullets you want to take

so let's say that i have 5000 of bullets
and i fired some bullets ... like 50 of them
and i used this code: takeWeapon (source, 31, 4950)

you can actually see that the weapon has been removed from your hand
but .. check if it's really has been removed or not by using this function: getPedWeapon
you'll see that you still have the gun with the same ammo nothing changed ..
you can save these bullets 2 times .. which is not actually a good thing

i had to make it differently like if the bullets were the same as you wanna take from the weapon
i had to put another 'takeWeapon' .. but this time with no third argument to be completely removed.

TagsNo tags attached.



2017-11-22 22:06

viewer   ~~0026300

there should be argument to remove weapon from hand


2017-11-22 22:26

viewer   ~~0026301

would be good too ..

but it should be automatically removed
while there is no ammo in your gun.

  • Note: after firing and reloading .. use these functions (getPedWeapon - getPedTotalAmmo) with the weapon slot,
    i forgot to explain it above.


2017-11-27 10:32

viewer   ~~0026304

It's happening to me on my RP server. When using takeWeapon(ped, weapon) without putting ammo, all good, but when using takeWeapon(ped, weapon, ammo) and that ammo is the total ped ammo, the function deletes the weapon, bug when checking the bullets are saved.

The hotfix (if you really need to put ammo on takeWeapon()) is to use something like this:

ammo = the ammo you want to retrieve
totalAmmo = getPedWeaponTotalAmmo
slot = getSlotFromWeapon(weapon)

takeWeapon(thePlayer, weapon, ammo)
if getPedWeapon(thePlayer, slot) and ammo >= totalAmmo then
takeWeapon(thePlayer, weapon)


2017-11-28 00:57

viewer   ~~0026305

i already did something like that,
to avoid this big problem in future.

but it will be great to fix this problem completely.


2017-11-29 16:08

viewer   ~~0026306

What if you want to let the player have the weapon so he just has to buy the ammo instead of the whole weapon again?
My gamemodes always used the fact that the weapon doesn't get removed.

Issue History

Date Modified Username Field Change