View Issue Details

IDProjectCategoryView StatusLast Update
0004008Multi Theft Auto : San AndreasServerpublic2018-07-06 11:49
ReporterAce_GambitAssigned To 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Target VersionConfirmed IssuesFixed in Version 
Summary0004008: Can't use give[Ped]Weapon directly after createPed
Description

You can't give weapons directly after creating peds.

Additional Information

Does not work:

ped = createPed(...)
giveWeapon(ped,...)

Does work:

ped = createPed(...)
setTimer(giveWeapon,5000,1,...)

TagsNo tags attached.

Relationships

has duplicate 0008966 closed New issues givePedWeapon or setPedControlState returns error 

Activities

Devan_LT

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?

lil_Toady

2009-02-13 14:01

administrator   ~~0008365

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

Cazomino05

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

lucasc190

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.

qaisjp

2014-09-12 21:50

administrator   ~~0022003

I think this has been fixed: http://i.imgur.com/wfctLFC.png

Inspirator

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).

arranTuna

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: https://github.com/multitheftauto/mtasa-blue/commit/27dd16873edbabc6663109ade2c5c9b4e3edc61e

Jusonex

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.

Bonus1702

2018-07-05 13:33

reporter   ~~0026616

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

myonlake

2018-07-06 11:34

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