View Issue Details

IDProjectCategoryView StatusLast Update
0009767Multi Theft Auto : San AndreasScriptingpublic2018-09-02 20:37
ReporterXMLAssigned To 
Status closedResolutionsuspended 
Product Version1.5.4 
Target VersionFixed in Version 
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

reporter   ~~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

reporter   ~~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.


2018-07-16 00:39

updater   ~~0026702

Essentially this is what happens:

1) giveWeapon and set the weapon to their hand
2) takeWeapon with ammo specified (put the current ammo amount so it should remove the weapon)
3) Calling getPedWeapon right after will still return the weapon slot ID even though the weapon is gone and it has visually switched to fist (0)
4) getPedTotalAmmo will however return 0 as supposed to

If you do not specify the ammo in step 2 (just simply take weapon), it will return the correct fist slot (0) with getPedWeapon right after takeWeapon was performed.

So it seems there is a small delay when removing the current ammo amount (and thereby removing the weapon).

I guess it technically should be fixed since there is no reason for getWeapon to return the old slot half the time, and half the time the new slot...

Multi Theft Auto v1.5.5-release-12430


2018-07-16 18:52

administrator   ~~0026717

Thanks for confirming this @myonlake


2018-09-02 20:37

manager   ~~0026919

Needs describing better on github.

Issue History

Date Modified Username Field Change