- 5
- 0
Помогите найти ошибку в коде
В этом скрипте не логируется статистика, то есть в окно статистики не идет подсчет
И помогите доработать, рендер на места появление руды
script_author('akimoto777')
script_name('mine-kirka')
local mem = require "memory"
local imgui = require "imgui"
local encoding = require "encoding"
local events = require "lib.samp.events"
encoding.default = "CP1251"
u8 = encoding.UTF8
font = renderCreateFont("Century Gothic", 9, 5)
local cjtrue = true
local cjfalse = false
local infinityruntrue = true
local infinityrunfalse = false
local work = imgui.ImBool(false)
local work_stat = imgui.ImBool(false)
local render = imgui.ImBool(false)
local mesta = imgui.ImBool(false)
local infinityrun = imgui.ImBool(false)
local cj = imgui.ImBool(false)
local stat = imgui.ImBool(false)
local sbiv_q = imgui.ImBool(false)
local tag = "{cc66ff}[mine-kirka]{ffffff} - "
local stone = 0
local metall = 0
local bronze = 0
local silver = 0
local gold = 0
local vsego = 0
function main()
repeat wait(0) until isSampAvailable()
wait(100)
sampAddChatMessage(tag.."Скрипт загружен!", -1)
sampAddChatMessage(tag.."Приобретайте вирты по низким ценам в нашем магазине.", -1)
sampAddChatMessage(tag.."Активация: /kirka", -1)
sampRegisterChatCommand("kirka.stat", stat_imgui)
sampRegisterChatCommand("kirka", menu_imgui)
while true do
wait(0)
if render.v then
for id = 0, 2048 do
if sampIs3dTextDefined(id) then
local text, color, x, y, z, distance, ignoreWalls, player, vehicle = sampGet3dTextInfoById(id)
if text:find("Месторождение ресурсов") then
if isPointOnScreen(x, y, z, 3.0) then
xp, yp, zp = getCharCoordinates(PLAYER_PED)
x1, y2 = convert3DCoordsToScreen(x, y, z)
p3, p4 = convert3DCoordsToScreen(xp, yp, zp)
distance = string.format("%.0f", getDistanceBetweenCoords3d(x, y, z, xp, yp, zp))
text = ("{ffffff}Руда:\n{cc66ff}Дистанция: "..distance)
renderDrawLine(x1, y2, p3, p4, 1.1, 0xFFFF0000)
renderFontDrawText(font, text, x1, y2, -1)
end
end
end
end
end
if mesta.v then
for _, v in pairs(getAllObjects()) do
if isObjectOnScreen(v) then
local result, oX, oY, oZ = getObjectCoordinates(v)
local x1, y1 = convert3DCoordsToScreen(oX,oY,oZ)
local objmodel = getObjectModel(v)
local x2,y2,z2 = getCharCoordinates(PLAYER_PED)
local x3, y3 = convert3DCoordsToScreen(x2,y2,z2)
distance = string.format("%.0f", getDistanceBetweenCoords3d(oX,oY,oZ, x2, y2, z2))
if objmodel == 19475 then
renderFontDrawText(font,"Место появление ресурса", x1, y1, -1)
end
end
end
end
if sbiv_q.v then
if isKeyJustPressed(0x51) then
taskPlayAnim(PLAYER_PED, "WF_FWD", "WAYFARER", 1, false, false, false, false, -1)
end
end
end
end
function menu_imgui()
work.v = not work.v
imgui.Process = work.v
end
function events.onShowTextDraw(id, textdr)
if textdr.text == "stone + 1" then
stone = stone + 1
elseif textdr.text == "metal + 1" then
metall = metall + 1
elseif textdr.text == "bronze + 1" then
bronze = bronze + 1
elseif textdr.text == "silver + 1" then
silver = silver + 1
elseif textdr.text == "gold + 1" then
gold = gold + 1
elseif textdr.text == "stone + 2" then
stone = stone + 2
elseif textdr.text == "metal + 2" then
metall = metall + 2
elseif textdr.text == "bronze + 2" then
bronze = bronze + 2
elseif textdr.text == "silver + 2" then
silver = silver + 2
elseif textdr.text == "gold + 2" then
gold = gold + 2
end
end
function imgui_colors()
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
local ImVec2 = imgui.ImVec2
style.WindowPadding = imgui.ImVec2(8, 8)
style.WindowRounding = 6
style.FramePadding = imgui.ImVec2(5, 3)
style.FrameRounding = 3.0
style.ItemSpacing = imgui.ImVec2(5, 4)
style.ItemInnerSpacing = imgui.ImVec2(4, 4)
style.IndentSpacing = 21
style.ScrollbarSize = 10.0
style.ScrollbarRounding = 13
style.GrabMinSize = 8
style.GrabRounding = 1
colors[clr.Text] = ImVec4(0.95, 0.96, 0.98, 1.00);
colors[clr.TextDisabled] = ImVec4(0.29, 0.29, 0.29, 1.00);
colors[clr.WindowBg] = ImVec4(0.14, 0.14, 0.14, 1.00);
colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 0.94);
colors[clr.Border] = ImVec4(0.14, 0.14, 0.14, 1.00);
colors[clr.FrameBg] = ImVec4(0.22, 0.22, 0.22, 1.00);
colors[clr.FrameBgHovered] = ImVec4(0.18, 0.18, 0.18, 1.00);
colors[clr.FrameBgActive] = ImVec4(0.09, 0.12, 0.14, 1.00);
colors[clr.TitleBg] = ImVec4(0.14, 0.14, 0.14, 0.81);
colors[clr.TitleBgActive] = ImVec4(0.14, 0.14, 0.14, 1.00);
colors[clr.MenuBarBg] = ImVec4(0.20, 0.20, 0.20, 1.00);
colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.39);
colors[clr.ScrollbarGrab] = ImVec4(0.36, 0.36, 0.36, 1.00);
colors[clr.Button] = ImVec4(1.00, 0.28, 0.28, 1.00);
colors[clr.ButtonHovered] = ImVec4(1.00, 0.39, 0.39, 1.00);
colors[clr.ButtonActive] = ImVec4(1.00, 0.21, 0.21, 1.00);
colors[clr.Header] = ImVec4(1.00, 0.28, 0.28, 1.00);
colors[clr.HeaderHovered] = ImVec4(1.00, 0.39, 0.39, 1.00);
colors[clr.Separator] = ImVec4(0.12, 0.12, 0.12, 1.00);
colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16);
colors[clr.PlotLines] = ImVec4(0.61, 0.61, 0.61, 1.00);
colors[clr.TextSelectedBg] = ImVec4(1.00, 0.32, 0.32, 1.00);
colors[clr.ModalWindowDarkening] = ImVec4(0.26, 0.26, 0.26, 0.60);
end
function imgui.OnDrawFrame()
if not work.v and not work_stat.v then
imgui.Process = false
end
if work.v then
imgui_colors()
imgui.ShowCursor = true
imgui.GetStyle().WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
imgui.Begin(u8"Mine-Kirka", work, imgui.WindowFlags.NoResize)
if imgui.Button(u8 "Перейти в магазин на Funpay", imgui.ImVec2(210, 25) ) then
local url = "https://funpay.com/users/11794199/"
os.execute("cmd.exe /c start " .. url)
end
if imgui.Button(u8"Состояние", imgui.ImVec2(210, 25) ) then
sampTextdrawSetStyle(222, 4)
sampAddChatMessage("Состояние:", -1)
sampAddChatMessage(render.v and "Рендер на руду: {26FF00}Включен" or "Рендер на руду: {cc66ff}Выключен", -1)
sampAddChatMessage(mesta.v and "Места появления руды: {26FF00}Включен" or "Места появления руды: {cc66ff}Выключен", -1)
sampAddChatMessage(infinityrun.v and "Бесконечный бег: {26FF00}Включен" or "Бесконечный бег: {cc66ff}Выключен", -1)
sampAddChatMessage(cj.v and "Скин CJ: {26FF00}Включен" or "Скин CJ: {cc66ff}Выключен", -1)
sampAddChatMessage(stat.v and "Статистика: {26FF00}Включена" or "Статистика: {cc66ff}Выключена", -1)
sampAddChatMessage(sbiv_q.v and "Сбив на Q: {26FF00}Включена" or "Сбив на Q: {cc66ff}Выключена", -1)
end
imgui.Checkbox(u8"Рендер на руду", render)
imgui.Checkbox(u8"Место появления руды", mesta)
imgui.Checkbox(u8"Бесконечный бег", infinityrun)
imgui.Checkbox(u8"Скин CJ + бег CJ", cj)
if imgui.Checkbox(u8"Статистика ресурсов", stat) then
work_stat.v = not work_stat.v
end
imgui.Checkbox(u8"Сбив на клавишу [Q]", sbiv_q)
if infinityrun.v then
if infinityruntrue then
mem.setint8(0xB7CEE4, 1)
infinityrunfalse = true
infinityruntrue = false
end
else
if infinityrunfalse then
mem.setint8(0xB7CEE4, 0)
infinityrunfalse = false
infinityruntrue = true
end
end
if cj.v then
if cjtrue then
local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
idskin = getCharModel(PLAYER_PED)
bss = raknetNewBitStream()
raknetBitStreamWriteInt32(bss, id)
raknetBitStreamWriteInt32(bss, 74)
raknetEmulRpcReceiveBitStream(153, bss)
raknetDeleteBitStream(bss)
cjfalse = true
cjtrue = false
end
else
if cjfalse then
local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
bs = raknetNewBitStream()
raknetBitStreamWriteInt32(bs, id)
raknetBitStreamWriteInt32(bs, idskin)
raknetEmulRpcReceiveBitStream(153, bs)
raknetDeleteBitStream(bs)
cjfalse = false
cjtrue = true
end
end
imgui.Text("")
imgui.Text(u8"Автор: Akimoto777")
imgui.End()
end
if work_stat.v then
if not work.v then
imgui.ShowCursor = false
end
imgui.Begin(u8"Статистика:", work, imgui.WindowFlags.NoResize)
imgui.Text(u8"Камень: "..stone)
imgui.Text(u8"Металл: "..metall)
imgui.Text(u8"Бронза: "..bronze)
imgui.Text(u8"Серебро: "..silver)
imgui.Text(u8"Золото: "..gold)
imgui.Text(u8"Всего: "..vsego)
vsego = stone + metall + bronze + silver + gold
if imgui.Button(u8"Сбросить статистику") then
stone = 0
metall = 0
bronze = 0
silver = 0
gold = 0
end
imgui.End()
end
end
script_name('mine-kirka')
local mem = require "memory"
local imgui = require "imgui"
local encoding = require "encoding"
local events = require "lib.samp.events"
encoding.default = "CP1251"
u8 = encoding.UTF8
font = renderCreateFont("Century Gothic", 9, 5)
local cjtrue = true
local cjfalse = false
local infinityruntrue = true
local infinityrunfalse = false
local work = imgui.ImBool(false)
local work_stat = imgui.ImBool(false)
local render = imgui.ImBool(false)
local mesta = imgui.ImBool(false)
local infinityrun = imgui.ImBool(false)
local cj = imgui.ImBool(false)
local stat = imgui.ImBool(false)
local sbiv_q = imgui.ImBool(false)
local tag = "{cc66ff}[mine-kirka]{ffffff} - "
local stone = 0
local metall = 0
local bronze = 0
local silver = 0
local gold = 0
local vsego = 0
function main()
repeat wait(0) until isSampAvailable()
wait(100)
sampAddChatMessage(tag.."Скрипт загружен!", -1)
sampAddChatMessage(tag.."Приобретайте вирты по низким ценам в нашем магазине.", -1)
sampAddChatMessage(tag.."Активация: /kirka", -1)
sampRegisterChatCommand("kirka.stat", stat_imgui)
sampRegisterChatCommand("kirka", menu_imgui)
while true do
wait(0)
if render.v then
for id = 0, 2048 do
if sampIs3dTextDefined(id) then
local text, color, x, y, z, distance, ignoreWalls, player, vehicle = sampGet3dTextInfoById(id)
if text:find("Месторождение ресурсов") then
if isPointOnScreen(x, y, z, 3.0) then
xp, yp, zp = getCharCoordinates(PLAYER_PED)
x1, y2 = convert3DCoordsToScreen(x, y, z)
p3, p4 = convert3DCoordsToScreen(xp, yp, zp)
distance = string.format("%.0f", getDistanceBetweenCoords3d(x, y, z, xp, yp, zp))
text = ("{ffffff}Руда:\n{cc66ff}Дистанция: "..distance)
renderDrawLine(x1, y2, p3, p4, 1.1, 0xFFFF0000)
renderFontDrawText(font, text, x1, y2, -1)
end
end
end
end
end
if mesta.v then
for _, v in pairs(getAllObjects()) do
if isObjectOnScreen(v) then
local result, oX, oY, oZ = getObjectCoordinates(v)
local x1, y1 = convert3DCoordsToScreen(oX,oY,oZ)
local objmodel = getObjectModel(v)
local x2,y2,z2 = getCharCoordinates(PLAYER_PED)
local x3, y3 = convert3DCoordsToScreen(x2,y2,z2)
distance = string.format("%.0f", getDistanceBetweenCoords3d(oX,oY,oZ, x2, y2, z2))
if objmodel == 19475 then
renderFontDrawText(font,"Место появление ресурса", x1, y1, -1)
end
end
end
end
if sbiv_q.v then
if isKeyJustPressed(0x51) then
taskPlayAnim(PLAYER_PED, "WF_FWD", "WAYFARER", 1, false, false, false, false, -1)
end
end
end
end
function menu_imgui()
work.v = not work.v
imgui.Process = work.v
end
function events.onShowTextDraw(id, textdr)
if textdr.text == "stone + 1" then
stone = stone + 1
elseif textdr.text == "metal + 1" then
metall = metall + 1
elseif textdr.text == "bronze + 1" then
bronze = bronze + 1
elseif textdr.text == "silver + 1" then
silver = silver + 1
elseif textdr.text == "gold + 1" then
gold = gold + 1
elseif textdr.text == "stone + 2" then
stone = stone + 2
elseif textdr.text == "metal + 2" then
metall = metall + 2
elseif textdr.text == "bronze + 2" then
bronze = bronze + 2
elseif textdr.text == "silver + 2" then
silver = silver + 2
elseif textdr.text == "gold + 2" then
gold = gold + 2
end
end
function imgui_colors()
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
local ImVec2 = imgui.ImVec2
style.WindowPadding = imgui.ImVec2(8, 8)
style.WindowRounding = 6
style.FramePadding = imgui.ImVec2(5, 3)
style.FrameRounding = 3.0
style.ItemSpacing = imgui.ImVec2(5, 4)
style.ItemInnerSpacing = imgui.ImVec2(4, 4)
style.IndentSpacing = 21
style.ScrollbarSize = 10.0
style.ScrollbarRounding = 13
style.GrabMinSize = 8
style.GrabRounding = 1
colors[clr.Text] = ImVec4(0.95, 0.96, 0.98, 1.00);
colors[clr.TextDisabled] = ImVec4(0.29, 0.29, 0.29, 1.00);
colors[clr.WindowBg] = ImVec4(0.14, 0.14, 0.14, 1.00);
colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 0.94);
colors[clr.Border] = ImVec4(0.14, 0.14, 0.14, 1.00);
colors[clr.FrameBg] = ImVec4(0.22, 0.22, 0.22, 1.00);
colors[clr.FrameBgHovered] = ImVec4(0.18, 0.18, 0.18, 1.00);
colors[clr.FrameBgActive] = ImVec4(0.09, 0.12, 0.14, 1.00);
colors[clr.TitleBg] = ImVec4(0.14, 0.14, 0.14, 0.81);
colors[clr.TitleBgActive] = ImVec4(0.14, 0.14, 0.14, 1.00);
colors[clr.MenuBarBg] = ImVec4(0.20, 0.20, 0.20, 1.00);
colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.39);
colors[clr.ScrollbarGrab] = ImVec4(0.36, 0.36, 0.36, 1.00);
colors[clr.Button] = ImVec4(1.00, 0.28, 0.28, 1.00);
colors[clr.ButtonHovered] = ImVec4(1.00, 0.39, 0.39, 1.00);
colors[clr.ButtonActive] = ImVec4(1.00, 0.21, 0.21, 1.00);
colors[clr.Header] = ImVec4(1.00, 0.28, 0.28, 1.00);
colors[clr.HeaderHovered] = ImVec4(1.00, 0.39, 0.39, 1.00);
colors[clr.Separator] = ImVec4(0.12, 0.12, 0.12, 1.00);
colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16);
colors[clr.PlotLines] = ImVec4(0.61, 0.61, 0.61, 1.00);
colors[clr.TextSelectedBg] = ImVec4(1.00, 0.32, 0.32, 1.00);
colors[clr.ModalWindowDarkening] = ImVec4(0.26, 0.26, 0.26, 0.60);
end
function imgui.OnDrawFrame()
if not work.v and not work_stat.v then
imgui.Process = false
end
if work.v then
imgui_colors()
imgui.ShowCursor = true
imgui.GetStyle().WindowTitleAlign = imgui.ImVec2(0.5, 0.5)
imgui.Begin(u8"Mine-Kirka", work, imgui.WindowFlags.NoResize)
if imgui.Button(u8 "Перейти в магазин на Funpay", imgui.ImVec2(210, 25) ) then
local url = "https://funpay.com/users/11794199/"
os.execute("cmd.exe /c start " .. url)
end
if imgui.Button(u8"Состояние", imgui.ImVec2(210, 25) ) then
sampTextdrawSetStyle(222, 4)
sampAddChatMessage("Состояние:", -1)
sampAddChatMessage(render.v and "Рендер на руду: {26FF00}Включен" or "Рендер на руду: {cc66ff}Выключен", -1)
sampAddChatMessage(mesta.v and "Места появления руды: {26FF00}Включен" or "Места появления руды: {cc66ff}Выключен", -1)
sampAddChatMessage(infinityrun.v and "Бесконечный бег: {26FF00}Включен" or "Бесконечный бег: {cc66ff}Выключен", -1)
sampAddChatMessage(cj.v and "Скин CJ: {26FF00}Включен" or "Скин CJ: {cc66ff}Выключен", -1)
sampAddChatMessage(stat.v and "Статистика: {26FF00}Включена" or "Статистика: {cc66ff}Выключена", -1)
sampAddChatMessage(sbiv_q.v and "Сбив на Q: {26FF00}Включена" or "Сбив на Q: {cc66ff}Выключена", -1)
end
imgui.Checkbox(u8"Рендер на руду", render)
imgui.Checkbox(u8"Место появления руды", mesta)
imgui.Checkbox(u8"Бесконечный бег", infinityrun)
imgui.Checkbox(u8"Скин CJ + бег CJ", cj)
if imgui.Checkbox(u8"Статистика ресурсов", stat) then
work_stat.v = not work_stat.v
end
imgui.Checkbox(u8"Сбив на клавишу [Q]", sbiv_q)
if infinityrun.v then
if infinityruntrue then
mem.setint8(0xB7CEE4, 1)
infinityrunfalse = true
infinityruntrue = false
end
else
if infinityrunfalse then
mem.setint8(0xB7CEE4, 0)
infinityrunfalse = false
infinityruntrue = true
end
end
if cj.v then
if cjtrue then
local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
idskin = getCharModel(PLAYER_PED)
bss = raknetNewBitStream()
raknetBitStreamWriteInt32(bss, id)
raknetBitStreamWriteInt32(bss, 74)
raknetEmulRpcReceiveBitStream(153, bss)
raknetDeleteBitStream(bss)
cjfalse = true
cjtrue = false
end
else
if cjfalse then
local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
bs = raknetNewBitStream()
raknetBitStreamWriteInt32(bs, id)
raknetBitStreamWriteInt32(bs, idskin)
raknetEmulRpcReceiveBitStream(153, bs)
raknetDeleteBitStream(bs)
cjfalse = false
cjtrue = true
end
end
imgui.Text("")
imgui.Text(u8"Автор: Akimoto777")
imgui.End()
end
if work_stat.v then
if not work.v then
imgui.ShowCursor = false
end
imgui.Begin(u8"Статистика:", work, imgui.WindowFlags.NoResize)
imgui.Text(u8"Камень: "..stone)
imgui.Text(u8"Металл: "..metall)
imgui.Text(u8"Бронза: "..bronze)
imgui.Text(u8"Серебро: "..silver)
imgui.Text(u8"Золото: "..gold)
imgui.Text(u8"Всего: "..vsego)
vsego = stone + metall + bronze + silver + gold
if imgui.Button(u8"Сбросить статистику") then
stone = 0
metall = 0
bronze = 0
silver = 0
gold = 0
end
imgui.End()
end
end
И помогите доработать, рендер на места появление руды
Последнее редактирование: