Jump to content

Making a ped fire


Drakath

Recommended Posts

I have encountered a strange problem. I gave a minigun to a ped: giveWeapon(myPed, 38, 9999, true)

And when I tried to make him shoot using setPedControlState he just shot a few bullets and then it looked like he ran out of ammo even though I gave him 9999. I also tried it with a rocket launcher but I only saw him do a shooting animation, no rockets were actually launched. Is this some sort of bug? Is it possible to fix it by scripting?

Link to comment

Even though you found a solution but tell me tell you the reason why you couldn't see the ped shooting. Since setPedControlState is client side event and only the client can see him shooting. For example,

  
player1 = getRandomPlayer()  
triggerClientEvent(player1,"onClientControlTrigger", player1)  -- Now this event is triggered for player1 only and player1 can only see what's happening ;P 
  

Link to comment
Because setPedControlState is client side event and only the client can see him shooting. For example,
  
player1 = getRandomPlayer()  
triggerClientEvent(player1,"onClientControlTrigger", player1)  -- Now this event is triggered for player1 only and player1 can only see what's happening ;P 
  

That doesn't make much sense...

The reason is that ammo data is only kept as long as the ped is streamed in. If the ped is streamed out after or while the weapon is given (that includes giving the weapon right after ped creation when it's not streamed in yet), then upon streaming in it will only have one bullet. The workaround is to give the weapon again, which can be done using repeatedly executing timer.

Edit: oops, didn't notice "Never mind, I found a way to fix this" message.

Link to comment
Because setPedControlState is client side event and only the client can see him shooting. For example,
  
player1 = getRandomPlayer()  
triggerClientEvent(player1,"onClientControlTrigger", player1)  -- Now this event is triggered for player1 only and player1 can only see what's happening ;P 
  

That doesn't make much sense...

The reason is that ammo data is only kept as long as the ped is streamed in. If the ped is streamed out after or while the weapon is given (that includes giving the weapon right after ped creation when it's not streamed in yet), then upon streaming in it will only have one bullet. The workaround is to give the weapon again, which can be done using repeatedly executing timer.

You're right. That can be the reason, I totally forgot about that. I experienced this problem once with slothbot resource.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...