local sampev = require 'lib.samp.events'
function spawnNpc(x, y, z, skin, animLib, animName)
local ped = createChar(4, skin, x, y, z)
setCharHeading(ped, 0.0)
freezeCharPosition(ped, true)
setCharInvincible(ped, true)
requestAnimation(animLib)
while not hasAnimationLoaded(animLib) do wait(0) end
taskPlayAnim(ped, animName, animLib, 4.0, true, false, false, false, -1)
end
function main()
while not isSampAvailable() do wait(0) end
sampRegisterChatCommand("npc", function(arg)
local skin, anim = arg:match("(%d+)%s+(%S+)")
if not skin or not anim then
sampAddChatMessage("/npc skin anim (пример: /npc 30 IDLE_CHAT)", -1)
return
end
local x, y, z = getCharCoordinates(PLAYER_PED)
spawnNpc(x + 1.0, y, z, tonumber(skin), "PED", anim)
end)
while true do wait(0) end
end