Playstation23 Posted January 22, 2010 Share Posted January 22, 2010 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
Playstation23 Posted January 22, 2010 Author Share Posted January 22, 2010 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
Robert333 Posted January 22, 2010 Share Posted January 22, 2010 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 Posted January 22, 2010 Share Posted January 22, 2010 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
Playstation23 Posted January 22, 2010 Author Share Posted January 22, 2010 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
Playstation23 Posted January 22, 2010 Author Share Posted January 22, 2010 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 Posted January 22, 2010 Share Posted January 22, 2010 (edited) Use a timer for giving the weapon to PED on onResourceStart. And you don't need the setPedWeaponslot etc. function, setting setAsCurrent true for giveWeapon does the same. Edited January 23, 2010 by Guest Link to comment
Nich Posted January 22, 2010 Share Posted January 22, 2010 (edited) Use a timer for giving the weapon to PED on onResourceStart. And you don't need the setPedWeaponslot etc. function, setting setAsCurrent true for giveWeapon does the same. Edited January 23, 2010 by Guest Link to comment
Playstation23 Posted January 22, 2010 Author Share Posted January 22, 2010 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. Link to comment
Playstation23 Posted January 22, 2010 Author Share Posted January 22, 2010 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. Link to comment
madis Posted January 23, 2010 Share Posted January 23, 2010 setTimer( giveWeapon, 1000, 1, ped1, 31, 500, true) Link to comment
madis Posted January 23, 2010 Share Posted January 23, 2010 setTimer( giveWeapon, 1000, 1, ped1, 31, 500, true) Link to comment
Playstation23 Posted January 23, 2010 Author Share Posted January 23, 2010 madis said: setTimer( giveWeapon, 1000, 1, ped1, 31, 500, true) Works a charm, thanks mate. Link to comment
Playstation23 Posted January 23, 2010 Author Share Posted January 23, 2010 madis said: setTimer( giveWeapon, 1000, 1, ped1, 31, 500, true) Works a charm, thanks mate. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now