0 in gioco
Scarica
Inseguimento della polizia sotto la sopraelevata in Mafia II

Wiki

NPCs

Characters of the server's own: shopkeepers, guards, passers-by. npcs.create on the server; everyone near sees the same one, standing where it was put, playing its animation, walking where it's sent. Nobody's game moves them.

A shop

-- server
local seller = npcs.create("VITPRA", 121.5, 846.0, -19.9, 3.14, { name = "Shopkeeper" })
seller:playAnimation("sc_man_smoke_stat_a", true)
blips.attach(seller, { icon = 1, style = 9 })

events.onClient("buy", function(player, id)
    local npc = npcs.get(id)
    if not npc or (npc:getDistanceTo(player) or 99) > 3 then return end
    npc:lookAt(player)
    chat.send(player, "Here you go")
end)

-- client
keys.on("E", function()
    local id = npcs.getNearest(2)
    if id then events.emitServer("buy", id) end
end)

Walking

local guard = npcs.create("VITPRA", 115, 840, -19.9, 0, { name = "Guard" })
local points, i = { {115, 840, -19.9}, {125, 850, -19.9} }, 1
guard:walkTo(table.unpack(points[2]))
events.on("npcArrived", function(npc)
    if npc.id ~= guard.id then return end
    i = i % #points + 1
    npc:walkTo(table.unpack(points[i]))
end)

They walk straight to the point ({ run = true } to run), so give them a path of points around corners.

Limits

Each player is shown the nearest 64 NPCs, on a budget of their own: players (up to the server's maxStreamedPlayers) and the traffic's pedestrians keep theirs. Character models: when the game's slots run short, players get theirs first, then NPCs, then the traffic; the others wear the default look for a while.

The skins are the game's character models (the Character models page); dimension works as for players.