Jump to content

give ped a weapon


Playstation23

Recommended Posts

Ok, I need some help with giving a ped a weapon.

I've managed to create the ped, but I want to give him a M4 with 500 Ammo, but it doesn't seem to be giving him it,

here's the .lua file;

function pedLoad ( )

ped1 = createPed ( 287, 223, 1875, 18 )

giveWeapon( ped1, 31, 500, true )

end

addEventHandler ( "onResourceStart", getRootElement(), pedLoad )

I'm a bit of a noob at lua scripting ;P

Link to comment

Ok, I need some help with giving a ped a weapon.

I've managed to create the ped, but I want to give him a M4 with 500 Ammo, but it doesn't seem to be giving him it,

here's the .lua file;

function pedLoad ( )

ped1 = createPed ( 287, 223, 1875, 18 )

giveWeapon( ped1, 31, 500, true )

end

addEventHandler ( "onResourceStart", getRootElement(), pedLoad )

I'm a bit of a noob at lua scripting ;P

Link to comment

Maybe the Ped havn't the right slot of weapon, use setPedWeaponSlot to set M4 as Weapon for Ped.

But I don't know whether that works I don't work with peds until now.

function pedLoad()
 
   ped1 = createPed ( 287, 223, 1875, 18 )
giveWeapon( ped1, 31, 500, true )
setPedWeaponSlot ( ped1, 5 ) -- Slot 5, because M4 is a "Assault Rifles" and that is in Slot 5
 
end
 
addEventHandler ( "onResourceStart", getRootElement(), pedLoad )

Link to comment

Maybe the Ped havn't the right slot of weapon, use setPedWeaponSlot to set M4 as Weapon for Ped.

But I don't know whether that works I don't work with peds until now.

function pedLoad()
 
   ped1 = createPed ( 287, 223, 1875, 18 )
giveWeapon( ped1, 31, 500, true )
setPedWeaponSlot ( ped1, 5 ) -- Slot 5, because M4 is a "Assault Rifles" and that is in Slot 5
 
end
 
addEventHandler ( "onResourceStart", getRootElement(), pedLoad )

Link to comment
  Robert333 said:
Maybe the Ped havn't the right slot of weapon, use setPedWeaponSlot to set M4 as Weapon for Ped.

But I don't know whether that works I don't work with peds until now.

function pedLoad()
 
   ped1 = createPed ( 287, 223, 1875, 18 )
giveWeapon( ped1, 31, 500, true )
setPedWeaponSlot ( ped1, 5 ) -- Slot 5, because M4 is a "Assault Rifles" and that is in Slot 5
 
end
 
addEventHandler ( "onResourceStart", getRootElement(), pedLoad )

I tried that before and it still didn't work, I have no idea why. :( PLus, I think the 'true' in giveWeapon sets the weapon slot to the weapon that is being given.

Link to comment
  Robert333 said:
Maybe the Ped havn't the right slot of weapon, use setPedWeaponSlot to set M4 as Weapon for Ped.

But I don't know whether that works I don't work with peds until now.

function pedLoad()
 
   ped1 = createPed ( 287, 223, 1875, 18 )
giveWeapon( ped1, 31, 500, true )
setPedWeaponSlot ( ped1, 5 ) -- Slot 5, because M4 is a "Assault Rifles" and that is in Slot 5
 
end
 
addEventHandler ( "onResourceStart", getRootElement(), pedLoad )

I tried that before and it still didn't work, I have no idea why. :( PLus, I think the 'true' in giveWeapon sets the weapon slot to the weapon that is being given.

Link to comment
  Nich said:
Use a timer for giving the weapon to PED on onResourceStart.

And you don't need the setWeaponslot etc. function, setting setAsCurrent true for giveWeapon does the same.

how would I go about doing that? I tried using the wiki and came up with this;

function pedLoad()
ped1 = createPed ( 287, 223, 1875, 18 )
giveWeapon( ped1, 31, 500, true )
setTimer( giveWeapon, 1000, 1, ped1, 2)
end
 
 
addEventHandler ( "onResourceStart", getRootElement(), pedLoad )

doesn't work though. :S

Link to comment
  Nich said:
Use a timer for giving the weapon to PED on onResourceStart.

And you don't need the setWeaponslot etc. function, setting setAsCurrent true for giveWeapon does the same.

how would I go about doing that? I tried using the wiki and came up with this;

function pedLoad()ped1 = createPed ( 287, 223, 1875, 18 )giveWeapon( ped1, 31, 500, true )setTimer( giveWeapon, 1000, 1, ped1, 2)end  addEventHandler ( "onResourceStart", getRootElement(), pedLoad )

doesn't work though. :S

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