HelpLua Script help

Posts 1–2 of 2 · Page 1 of 1
Lua Script help
Took this from another forum, i only know pretty basic of this.
Can anyone tell me the bodyguards that spawn work fine, BUT don't fire when in vehicle.

local bodyguard = {}
bodyguard.peds = {}
bodyguard.howMany = 2
function bodyguard.unload()
for k,guard in pairs(bodyguard.peds) do
if( guard ~= nil) then
PED.DELETE_PED(guard)
bodyguard.peds[k] = nil
end
end
end
function bodyguard.tick()
if(get_key_pressed(107)) then
local zombieSkinID = GAMEPLAY.GET_HASH_KEY("ig_fbisuit_01")
local playerPed = PLAYER.PLAYER_PED_ID()
local player = PLAYER.GET_PLAYER_PED(playerPed)
local playerID = PLAYER.PLAYER_ID()
local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)
local playerPosition = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(play erPed, 0.0, 5.0, 0.0)
local playerGroup = PED.GET_PED_GROUP_INDEX(playerPed)
bodyguard.unload()
STREAMING.REQUEST_MODEL(zombieSkinID)
while(not STREAMING.HAS_MODEL_LOADED(zombieSkinID)) do
wait(50)
end
for i = 0 ,bodyguard.howMany,1 do
bodyguard.peds[i] = PED.CREATE_PED( 26,zombieSkinID,playerPosition.x, playerPosition.y, playerPosition.z,1,false,true)
PED.SET_PED_CAN_SWITCH_WEAPON(bodyguard.peds[i],true)
WEAPON.GIVE_DELAYED_WEAPON_TO_PED(bodyguard.peds[i], GAMEPLAY.GET_HASH_KEY("WEAPON_SPECIALCARBINE"), 1000, false)
WEAPON.GIVE_DELAYED_WEAPON_TO_PED(bodyguard.peds[i], GAMEPLAY.GET_HASH_KEY("WEAPON_MICROSMG"), 1000, false)
PED.SET_PED_AS_GROUP_MEMBER(bodyguard.peds[i], playerGroup)
end
STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(zombieSkin ID)
end
end

return bodyguard
Pretty sure you need a line that changes the AI behavior, AI.TASK_COMBAT_HATED_TARGETS_AROUND_PED(zombieSkin ID, 5000, 0);
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us