π§βπΎAmbient NPC
Client Side
Start the Script
It's already set in the config.lua, remove lines 3-11 if you want to change it with your system.
TriggerEvent("Botiv:startPNJSystem")
Client Event
Botiv-publicnpc:insertNewNPC(String name, Table value)
Example :
TriggerEvent("Botiv-publicnpc:insertNewNPC", "boss-1", {
model = "a_m_m_sddockworkers_02",
coords = { x = -803.6, y = -1292.98, z = 42.63 },
heading = 60.62,
anim = "WORLD_HUMAN_SIT_GROUND_READ_NEWSPAPER",
distance = 50.0,
dontreact = true,
walking = false,
walking_distance = 20.0,
weapon = ""
})
Client exports
exports.bt_publicnpc:getNPCEntity("paper-1")
Return the entity number of the NPC "paper-1" (config.lua or generated by event like "boss-1")
If the function returns 0, it means that the player has not generated the NPC because they are too far away.
Example :
Citizen.CreateThread(function()
while true do
Citizen.Wait(100)
local botNPC = exports.bt_publicnpc:getNPCEntity("paper-1")
if DoesEntityExist(botNPC) then
if #(GetEntityCoords(PlayerPedId()) - GetEntityCoords(botNPC)) < 5.0 then
SetPedScale(botNPC, 2.0)
else
SetPedScale(botNPC, 1.0)
end
end
end
end)
Server Side
Server Event
Botiv-publicnpc:insertNewNPC(String name, Table value)
Example :
TriggerClientEvent("Botiv-publicnpc:insertNewNPC",source, "boss-1", {
model = "a_m_m_sddockworkers_02",
coords = { x = -803.6, y = -1292.98, z = 42.63 },
heading = 60.62,
anim = "WORLD_HUMAN_SIT_GROUND_READ_NEWSPAPER",
distance = 50.0,
dontreact = true,
walking = false,
walking_distance = 20.0,
weapon = ""
})
Here is an excerpt from the config.lua file : (parts of the excerpt are hidden)
-- model : model name of the NPC
-- coords : x y z location
-- heading : the direction or orientation that the NPC is facing or looking towards
-- anim : scenario (hidden link)
-- distance : The distance from which the NPC will be loaded.
-- dontreact : The NPC ignores everything that is happening around him.
-- walking : The NPC will walk around
-- walking distance : The distance to walk around
-- weapon : Give a Weapon to the NPC.
Config.PNJ = {
["paper-1"] = { -- PAPERBOY
model = "S_M_Y_NewspaperBoy_01",
coords = { x = -793.6 , y = -1292.98 , z = 42.63 },
heading = 79.56,
anim = "WORLD_HUMAN_SIT_GROUND_READ_NEWSPAPER",
distance = 50.0,
dontreact = true,
walking = true,
walking_distance = 10.0,
weapon = ""
},
-- this content is hidden in the excerpt
}
Last updated