- 41
- 9
- Версия SA-MP
-
- 0.3.7 (R1)
Приветствую. Недавно нашел скрипт NPC tools, попытался подключить туда кастомные скины с аризоны, сам по себе скрипт внутри себя их имеет, но на некоторые айдишники скрипт просто падает, к примеру 1000, 320 // Скорее всего, не работает как либо peds_2.ide. Вообще я спастил парс скинов у чапо, сам скрипт у меня воркает, но так же падает.
Держите код:
Держите код:
Lua:
script_name("npc")
script_author("tam1que")
require "lib.moonloader"
require "lib.sampfuncs"
local encoding = require 'encoding'
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local animationList = {
["SMOKE"] = {"smoking", "m_smklean_loop", -1},
["DANCE"] = {"dancing", "dnce_m_d", -1},
["TIME"] = {"COP_AMBIENT", "COPLOOK_WATCH", -1},
["CRACK1"] = {"CRACK", "CRCKDETH1", -1},
}
local npcList = {}
local arzskins = {}
-- арз скины (пытался)
function LOAD_LAUNCHER_SKINS()
local file = getGameDirectory() .. '\\SAMP\\SAMP.ide'
if doesFileExist(file) then
arzskins = {}
local F = io.open(file, 'r')
local Text = F:read('*all')
F:close()
local pedline = 0
local lineIndex = 0
local l_s_count = 0
for line in Text:gmatch('[^\n]+') do
lineIndex = lineIndex + 1
if line:find('^peds') then pedline = lineIndex end
if pedline ~= 0 and lineIndex > pedline then
if line:find('(%d+), (%w+)') then
local id, model = line:match('(%d+), (%w+)')
if tonumber(id) then
if tonumber(id) > 311 then
table.insert(arzskins, { id = tonumber(id), name = '(ARZ) ' .. tostring(model) })
l_s_count = l_s_count + 1
end
end
end
end
end
print('Загружено ' .. l_s_count .. ' лаунчерных (ARZ) скинов!')
else
print('Ошибка: файл SAMP.ide не найден, ARZ скины не загружены')
end
end
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
LOAD_LAUNCHER_SKINS()
sampAddChatMessage("NPC Tools (ARZ support) - loaded", 0x00BFFF)
sampRegisterChatCommand("actor", function(param)
local params = {}
for word in string.gmatch(param, "%S+") do
table.insert(params, word)
end
local skinID = tonumber(params[1]) or 120
local animKey = params[2] and params[2]:upper() or nil
lua_thread.create(function()
spawnNpcWithDelay(skinID, animKey, 1500)
end)
end)
sampRegisterChatCommand("dactor", function(param)
local id = tonumber(param)
if id and npcList[id] then
deleteChar(npcList[id])
table.remove(npcList, id)
sampAddChatMessage("Актёр №" .. id .. " удалён.", 0x00FF00)
else
sampAddChatMessage("Неверный ID актёра.", 0xFF0000)
end
end)
sampRegisterChatCommand("tpactor", function(param)
local id = tonumber(param)
if id and npcList[id] then
lua_thread.create(function()
wait(1000)
local x, y, z = getCharCoordinates(PLAYER_PED)
setCharCoordinates(npcList[id], x + 1, y + 1, z - 1)
sampAddChatMessage("Актёр №" .. id .. " телепортирован к вам.", 0x00FF00)
end)
else
sampAddChatMessage("Неверный ID актёра.", 0xFF0000)
end
end)
sampRegisterChatCommand("animactor", function(param)
local params = {}
for word in string.gmatch(param, "%S+") do
table.insert(params, word)
end
local id = tonumber(params[1])
local animKey = params[2] and params[2]:upper() or nil
if id and npcList[id] then
if animKey and animationList[animKey] then
local anim = animationList[animKey]
lua_thread.create(function()
applyAnimation(npcList[id], anim[1], anim[2])
end)
sampAddChatMessage("Анимация " .. animKey .. " применена к актёру №" .. id, 0x00FF00)
else
sampAddChatMessage("Неверный ключ анимации.", 0xFF0000)
end
else
sampAddChatMessage("Неверный ID актёра.", 0xFF0000)
end
end)
sampRegisterChatCommand("delallactor", function()
for _, ped in ipairs(npcList) do
deleteChar(ped)
end
npcList = {}
sampAddChatMessage("Все актёры удалены.", 0x00FF00)
end)
sampRegisterChatCommand("npclist", function()
if #npcList == 0 then
sampAddChatMessage("Список актёров пуст.", 0xFF8800)
else
sampAddChatMessage("===== Список актёров =====", 0xB0E0E6)
for id, ped in ipairs(npcList) do
local model = getCharModel(ped)
local arzTag = (model > 311) and " (ARZ)" or ""
sampAddChatMessage(string.format("ID: %d | Skin: %d%s", id, model, arzTag), 0xFFFFFF)
end
end
end)
sampRegisterChatCommand("npcmenu", showNpcMenu)
wait(-1)
end
function spawnNpcWithDelay(skinID, animKey, delay)
local px, py, pz = getCharCoordinates(PLAYER_PED)
local angle = getCharHeading(PLAYER_PED)
wait(delay)
local offsetX = math.sin(-angle * math.pi / 180)
local offsetY = math.cos(-angle * math.pi / 180)
local x, y, z = px + offsetX, py + offsetY, pz - 1.0
requestModel(skinID)
loadAllModelsNow()
local ped = createChar(4, skinID, x, y, z)
if ped then
freezeCharPosition(ped, true)
setCharProofs(ped, true, true, true, true, true)
setCharHeading(ped, angle)
table.insert(npcList, ped)
if animKey and animationList[animKey] then
local anim = animationList[animKey]
applyAnimation(ped, anim[1], anim[2])
end
local tag = (skinID > 311) and " (ARZ)" or ""
sampAddChatMessage(string.format("Актёр создан: ID %d | Skin %d%s", #npcList, skinID, tag), 0x00FF00)
else
sampAddChatMessage("Не удалось создать актёра.", 0xFF0000)
end
markModelAsNoLongerNeeded(skinID)
end
function applyAnimation(ped, lib, anim)
requestAnimation(lib)
local timer = 0
while not hasAnimationLoaded(lib) do
wait(10)
timer = timer + 10
if timer > 5000 then
sampAddChatMessage("Не удалось загрузить анимацию: " .. lib, 0xFF0000)
return
end
end
taskPlayAnim(ped, anim, lib, 4.0, true, false, false, false, -1)
end
function showNpcMenu()
sampAddChatMessage("========= Меню NPC =========", 0x00BFFF)
sampAddChatMessage("/actor [skin] [anim] - создать NPC с анимацией", 0xFFFFFF)
sampAddChatMessage("/dactor [id] - удалить NPC по ID", 0xFFFFFF)
sampAddChatMessage("/tpactor [id] - телепортировать NPC к себе", 0xFFFFFF)
sampAddChatMessage("/animactor [id] [anim] - применить анимацию к NPC", 0xFFFFFF)
sampAddChatMessage("/changeskin [id] [skin] - сменить скин у NPC", 0xFFFFFF)
sampAddChatMessage("/npclist - список всех NPC (в т.ч. ARZ)", 0xFFFFFF)
sampAddChatMessage("/delallactor - удалить всех NPC", 0xFFFFFF)
sampAddChatMessage("/npcmenu - открыть это меню", 0xFFFFFF)
sampAddChatMessage("Доступные анимации: SMOKE, DANCE, TIME, CRACK1", 0xCCCCCC)
sampAddChatMessage("============================", 0x00BFFF)
end