Вот есть такой код. Запускаю его, а там ошибка.
[21:30:33.776672] (error) Composition of the territory: ...P\SBORKAX\drainsava\moonloader\2_5226900406671512363.lua:107: attempt to index field 'set' (a nil value)
stack traceback:
...P\SBORKAX\drainsava\moonloader\2_5226900406671512363.lua: in function <...P\SBORKAX\drainsava\moonloader\2_5226900406671512363.lua:103>
[21:30:33.776672] (error) Composition of the territory: Script died due to an error. (196501EC)
Вот сам код
[21:30:33.776672] (error) Composition of the territory: ...P\SBORKAX\drainsava\moonloader\2_5226900406671512363.lua:107: attempt to index field 'set' (a nil value)
stack traceback:
...P\SBORKAX\drainsava\moonloader\2_5226900406671512363.lua: in function <...P\SBORKAX\drainsava\moonloader\2_5226900406671512363.lua:103>
[21:30:33.776672] (error) Composition of the territory: Script died due to an error. (196501EC)
Вот сам код
Код:
require("lib.moonloader")
require("lib.sampfuncs")
local inicfg = require("inicfg")
local encoding = require("encoding")
local ffi = require("ffi")
encoding.default = "cp1251"
local slot13_a1133 = encoding.UTF8
local slot15_a1137 = {}
ffi.cdef([[
struct stGangzone
{
float fPosition[4];
uint32_t dwColor;
uint32_t dwAltColor;
};
struct stGangzonePool
{
struct stGangzone *pGangzone[1024];
int iIsListed[1024];
};
]])
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then
return
end
while not isSampAvailable() do
wait(1000)
end
sampAddChatMessage("[Check Terr]{FFFFFF} Скрипт успешно запущен.", 15356241)
sampAddChatMessage("[Check Terr]{FFFFFF} /t_edit - Изменить местоположение чекера", 15356241)
sampAddChatMessage("[Check Terr]{FFFFFF} /t_off - Выключить/включить чекер", 15356241)
local wx, wy = getScreenResolution()
local slot2_a1162 = inicfg.load
local slot3_a1163 = {set = slot4_a1164}
local slot4_a1164 = {status = true,posx = wx / 2,posy = wy / 1.3}
settings = slot2_a1162(slot3_a1163, "terrinfo")
sampRegisterChatCommand("t_off", function (args)
settings.set.status = not settings.set.status
inicfg.save(settings, "terrinfo")
end)
sampRegisterChatCommand("t_edit", function (args)
lua_thread.create(function ()
wait(200)
sampSetCursorMode(4)
if not settings.set.status then
sampAddChatMessage("[Ошибка]{FFFFFF} Перемещение невозможно пока выключен чекер", 15356241)
sampSetCursorMode(0)
return
end
NoRenderSettingscheck = true
sampAddChatMessage("[Примечание] {FFFFFF}Нажмите ЛКМ чтобы сохранить местоположение", 15356241)
while not sampIsChatInputActive() and NoRenderSettingscheck do
wait(0)
settings.set.posx, settings.set.posy = getCursorPos()
if isKeyJustPressed(1) then
while isKeyDown(1) do
wait(0)
end
NoRenderSettingscheck = false
elseif isKeyJustPressed(27) then
NoRenderSettingscheck = false
end
end
sampSetCursorMode(0)
NoRenderSettingscheck = false
if inicfg.save(settings, "terrinfo") then
print("Онлайн успешно сохранен.")
end
sampAddChatMessage("[Примечание] {FFFFFF}Настройки сохранены!", 15356241)
end)
end)
Font = renderCreateFont("arial", 10, 13)
lua_thread.create(function ()
while true do
wait(300)
if settings.set.status then
gangs = {}
for _, v in pairs(getAllChars()) do
local playerIsGangZone = IsPlayerGangZone(v)
local localIsGangZone = IsPlayerGangZone(PLAYER_PED)
if playerIsGangZone and localIsGangZone and playerIsGangZone.id == localIsGangZone.id then
local res, id = sampGetPlayerIdByCharHandle(v)
if res then
check_family = false
for i = 0, 3000 do
if sampIs3dTextDefined(i) then
local text, color, posX, posY, posZ, dist, ignore, playerId, vehicleId = sampGet3dTextInfoById(i)
if playerId == id and text:find("({......}.+) {FFFFFF}%w+$") and tostring(posZ) == tostring(0.050000000745058) and tostring(posY) == tostring(0) and tostring(posX) == tostring(0) then
local text_match = text:match("({......}.+) {FFFFFF}%w+$")
if gangs[text_match] then
gangs[text_match] = gangs[text_match] + 1
else
gangs[text_match] = 1
end
check_family = true
break
end
end
end
if not check_family then
if gangs["{C3C4BD}No Fam"] then
gangs["{C3C4BD}No Fam"] = gangs["{C3C4BD}No Fam"] + 1
else
gangs["{C3C4BD}No Fam"] = 1
end
end
end
end
end
end
end
end)
while true do
wait(0)
if settings.set.status then
renderPosY = settings.set.posy
renderFontDrawText(Font, "Сейчас на терре:", settings.set.color, renderPosY - 15, -1)
renderPosY = renderPosY + 4
for _, v in pairs(gangs) do
renderFontDrawText(Font, _ .. " - " .. v, settings.set.color, renderPosY, -1)
renderPosY = renderPosY + 15
end
end
end
end
function IsPlayerGangZone(arg)
local handle = arg or PLAYER_PED
local gang = ffi.cast("struct stGangzonePool*", sampGetGangzonePoolPtr())
for i = 0, 1023 do
if gang.iIsListed[i] ~= 0 and gang.pGangzone[i] ~= nil then
local gang_pos = gang.pGangzone[i].fPosition
local gang_col = gang.pGangzone[i].dwColor
local x, y, z = getCharCoordinates(handle)
if (gang_pos[0] <= x and x <= gang_pos[2] or x <= gang_pos[0] and gang_pos[2] <= x) and (gang_pos[1] <= y and y <= gang_pos[3] or y <= gang_pos[1] and gang_pos[3] <= y) then
return {id = i,x = gang_pos[0] + (gang_pos[2] - gang_pos[0]) / 2,y = gang_pos[1] + (gang_pos[3] - gang_pos[1]) / 2,color = gang_col}
end
end
end
end