View Issue Details

IDProjectCategoryView StatusLast Update
0004008Multi Theft Auto : San AndreasServerpublic2018-09-02 17:11
ReporterAce_GambitAssigned To 
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0004008: Can't use give[Ped]Weapon directly after createPed

You can't give weapons directly after creating peds.

Additional Information

Does not work:

ped = createPed(...)

Does work:

ped = createPed(...)

TagsNo tags attached.


has duplicate 0008966 closed New issues givePedWeapon or setPedControlState returns error 



2009-02-13 13:56

viewer   ~~0008364

I noticed that sometimes elements are created short time after the function is called. And weapons aren't synced, because when I spawned a ped with a gun and reconnected, ped didn't have the gun anymore. Maybe it's the reason?


2009-02-13 14:01

administrator   ~~0008365

The reason is that peds dont have their weapons restored when streamed out/in


2009-05-10 16:17

reporter   ~~0009146

Last edited: 2009-05-10 16:18

I managed to recreate this in r804 with
run local ped = createPed(123,getElementPosition(getRandomPlayer())) giveWeapon(ped, 31, 100) setPedWeaponSlot(ped, 5)

the ped seems to get the weapon in the next frame so you can then do
run setPedWeaponSlot(getElementsByType("ped")[1], 5)
just after and the ped has the weapon

Would be nice to have this fixed but it isn't major due to being fixable via lua itself.

Also as for the second bug reported I reproduced that as well with the same script


2009-05-19 14:33

reporter   ~~0009273

"getPedWeaponSlot" returns the correct slot after the ped streams out but 0 when they stream back in again.


2014-09-12 21:50

administrator   ~~0022003

I think this has been fixed:


2014-09-18 09:54

viewer   ~~0022026

Had the same issue a while back. Not sure if it still occurs but whenever I gave players weapons when they spawned with spawnPlayerAtSpawnpoint from spawnmanager sometimes they would not receive their weapons or they would get more bullets or less bullets than what I typed in sometimes. A timer fixed that but it still seemed to occur on a rare occasion (probably due to lag).


2015-07-17 12:20

manager   ~~0023644

Seems that since 1.5 this now applies to client side created peds as well whereas before updating to 1.5 no timer was necessary for givePedWeapon.

I'm guessing this commit caused this new problem:


2015-07-21 17:43

administrator   ~~0023704

Do you use both createPed and givePedWeapon on the client? If not, the linked commit cannot be the problem as it only changes relevant things on the server.


2018-07-05 13:33

reporter   ~~0026616

This bug seems to be already solved, giveWeapon/givePedWeapon directly after creating the ped worked for me.


2018-07-06 11:34

updater   ~~0026627

I can confirm Bonus1702's comment. I am not able to reproduce this bug on client or server-side. givePedWeapon and giveWeapon work fine.

Issue History

Date Modified Username Field Change