It's pretty simple to set a ped with a firearm. I used this method with my Zombie Mod Beta allowing Bucky to use the Spudgun all the time by doing this.
F_SpudGunFire2 = function()
local x,y = -772,-123
local r1 = x + 3.5
local r2 = y + 3.5
local r3 = x - 3.5
local r4 = y - 3.5
repeat
Wait(0)
until PedInRectangle(gPlayer,r1,r2,r3,r4)
PedDismissAlly(gplayer, Troy)
PedDismissAlly(Troy, Wade)
PedDismissAlly(Wade, Tom)
PedGuardPed(gplayer, Troy)
PedGuardPed(gplayer, Tom)
PedGuardPed(gplayer, Wade)
PedAttackPlayer(Infected06, gPlayer,2)
BlipRemove(Blip600)
PedMoveToXYZ(gBucky, 3, -772.3766, -123.5870, 7.3712)
PedSetPedToTypeAttitude(gMelvin, 13, 0)
PedAttackPlayer(gMelvin, gPlayer,2)
PedSetWeapon(gMelvin, 305, 10000)
PedSetPedToTypeAttitude(gBucky, 13, 0)
PedAttackPlayer(gBucky, gPlayer,2)
PedSetWeapon(gBucky, 305, 10000)
PedSetWeaponNow(gBucky, 305, 20)
SoundPlayStream("MS_TenementsHigh.rsm", 0.69999998807907)
PedSetActionNode(gBucky, "/Global/N_Earnest/Offense/FireSpudGun", "Act/Anim/N_Earnest.act")
repeat
Wait(0)
if PedHasWeapon(gBucky, 305) and PedIsPlaying(gBucky, "/Global/N_Earnest/Offense/FireSpudGun", "Act/Anim/N_Earnest.act") then
Wait(8000)
PedSetActionNode(gBucky, "/Global/N_Earnest/Offense/FireSpudGun", "Act/Anim/N_Earnest.act")
end
Wait(400)
until not PedIsValid(gBucky) or PedIsDead(gBucky) or PedGetHealth(gBucky) < 1
end
PedHasWeapon and set a l_3_0 = false
Just remove the animation for the ped and set the PedHasWeapon and set a l_3_0 = false to true.
if PedHasWeapon and l_3_0 == false then
PedSetWeapon(WID)
end
Use this code to test setting weapons to peds. I also use these functions to open and close doors you can test this also.