From 4668297ae97e7fb8894f8187b7bc2e5eed8cc986 Mon Sep 17 00:00:00 2001 From: rubin Date: Sun, 1 Jan 2023 23:13:17 +0300 Subject: [PATCH] replace name prod>corn & fix dialog finfo & delete narko --- corn-hud.lua | 69 ++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/corn-hud.lua b/corn-hud.lua index e62c940..c1599a3 100644 --- a/corn-hud.lua +++ b/corn-hud.lua @@ -1,4 +1,4 @@ -script_name('ProdHUD') +script_name('cornHUD') script_author("Serhiy_Rubin") script_version("22/09/2019") require 'lib.sampfuncs' @@ -34,46 +34,46 @@ function main() if string.find(hostName, "Revolution") then serverName = "Revolution" end if hostName == "Samp-Rp.Ru Server 02 Client 0.3.7" then serverName = "Two" end if serverName == nil then thisScript():unload() end - iniName = string.format("ProdHUD-%s", serverName) + iniName = string.format("cornHUD-%s", serverName) ini = inicfg.load({ ['Farm 0'] = { corn = 0, cornPrice = 0, - product = 0, - productPrice = 0, - prodName = '', + cornuct = 0, + cornuctPrice = 0, + cornName = '', bank = 0 }, ['Farm 1'] = { corn = 0, cornPrice = 0, - product = 0, - productPrice = 0, - prodName = '', + cornuct = 0, + cornuctPrice = 0, + cornName = '', bank = 0 }, ['Farm 2'] = { corn = 0, cornPrice = 0, - product = 0, - productPrice = 0, - prodName = '', + cornuct = 0, + cornuctPrice = 0, + cornName = '', bank = 0 }, ['Farm 3'] = { corn = 0, cornPrice = 0, - product = 0, - productPrice = 0, - prodName = '', + cornuct = 0, + cornuctPrice = 0, + cornName = '', bank = 0 }, ['Farm 4'] = { corn = 0, cornPrice = 0, - product = 0, - productPrice = 0, - prodName = '', + cornuct = 0, + cornuctPrice = 0, + cornName = '', bank = 0 }, price = { @@ -96,10 +96,10 @@ function main() }, }, iniName) inicfg.save(ini, iniName) - sampfuncsLog(' {FFFFFF}ProdHUD by Serhiy_Rubin loaded. CMD: /prod | /prod hud. | Key combo: '..ini.Settings.Key1:gsub("VK_", '')..' + '..ini.Settings.Key2:gsub("VK_", '')) + sampfuncsLog(' {FFFFFF}corn-hud by Serhiy_Rubin loaded. CMD: /corn | /corn hud. | Key combo: '..ini.Settings.Key1:gsub("VK_", '')..' + '..ini.Settings.Key2:gsub("VK_", '')) font = renderCreateFont(ini.Render.FontName, ini.Render.FontSize, ini.Render.FontFlag) - sampRegisterChatCommand('prod', function(param) - if param:lower():find('pos') then + sampRegisterChatCommand('corn', function(param) + if render and param:lower():find('pos') then SetPos() else render = not render @@ -128,18 +128,17 @@ function main() renderText = { [1] = '{00D900}Цена покупки зерна: '..ini.price.zerno..'$', [2] = '{00D900}Цена продажи урожая: '..ini.price.urojai..'$', - [3] = '{00D900}Цена продажи наркотиков: '..ini.price.narko..'$', - [4] = '{00D900} ', - [5] = string.format('{00D900}Ферма №0 | Баланс: %d$ | Зерно: %d [%d$] | %s: %d [%d$]', ini['Farm 0'].bank, ini['Farm 0'].corn, ini['Farm 0'].cornPrice, ini['Farm 0'].prodName, ini['Farm 0'].product, ini['Farm 0'].productPrice), - [6] = string.format('{00D900}Ферма №1 | Баланс: %d$ | Зерно: %s [%s$] | %s: %s [%s$]', ini['Farm 1'].bank, ini['Farm 1'].corn, ini['Farm 1'].cornPrice, ini['Farm 1'].prodName, ini['Farm 1'].product, ini['Farm 1'].productPrice), - [7] = string.format('{00D900}Ферма №2 | Баланс: %d$ | Зерно: %s [%s$] | %s: %s [%s$]', ini['Farm 2'].bank, ini['Farm 2'].corn, ini['Farm 2'].cornPrice, ini['Farm 2'].prodName, ini['Farm 2'].product, ini['Farm 2'].productPrice), - [8] = string.format('{00D900}Ферма №3 | Баланс: %d$ | Зерно: %s [%s$] | %s: %s [%s$]', ini['Farm 3'].bank, ini['Farm 3'].corn, ini['Farm 3'].cornPrice, ini['Farm 3'].prodName, ini['Farm 3'].product, ini['Farm 3'].productPrice), - [9] = string.format('{00D900}Ферма №4 | Баланс: %d$ | Зерно: %s [%s$] | %s: %s [%s$]', ini['Farm 4'].bank, ini['Farm 4'].corn, ini['Farm 4'].cornPrice, ini['Farm 4'].prodName, ini['Farm 4'].product, ini['Farm 4'].productPrice), + [3] = '{00D900} ', + [4] = string.format('{00D900}Ферма №0 | Баланс: %d$ | Зерно: %d [%d$] | %s: %d [%d$]', ini['Farm 0'].bank, ini['Farm 0'].corn, ini['Farm 0'].cornPrice, ini['Farm 0'].cornName, ini['Farm 0'].cornuct, ini['Farm 0'].cornuctPrice), + [5] = string.format('{00D900}Ферма №1 | Баланс: %d$ | Зерно: %s [%s$] | %s: %s [%s$]', ini['Farm 1'].bank, ini['Farm 1'].corn, ini['Farm 1'].cornPrice, ini['Farm 1'].cornName, ini['Farm 1'].cornuct, ini['Farm 1'].cornuctPrice), + [6] = string.format('{00D900}Ферма №2 | Баланс: %d$ | Зерно: %s [%s$] | %s: %s [%s$]', ini['Farm 2'].bank, ini['Farm 2'].corn, ini['Farm 2'].cornPrice, ini['Farm 2'].cornName, ini['Farm 2'].cornuct, ini['Farm 2'].cornuctPrice), + [7] = string.format('{00D900}Ферма №3 | Баланс: %d$ | Зерно: %s [%s$] | %s: %s [%s$]', ini['Farm 3'].bank, ini['Farm 3'].corn, ini['Farm 3'].cornPrice, ini['Farm 3'].cornName, ini['Farm 3'].cornuct, ini['Farm 3'].cornuctPrice), + [8] = string.format('{00D900}Ферма №4 | Баланс: %d$ | Зерно: %s [%s$] | %s: %s [%s$]', ini['Farm 4'].bank, ini['Farm 4'].corn, ini['Farm 4'].cornPrice, ini['Farm 4'].cornName, ini['Farm 4'].cornuct, ini['Farm 4'].cornuctPrice), } local X, Y = ini.Settings.X, ini.Settings.Y for i = 1, #renderText do renderFontDrawText(font, renderText[i], X, Y, -1) - if i ~= 4 then + if i ~= 3 then Y = Y + (renderGetFontDrawHeight(font) - (renderGetFontDrawHeight(font) / 5)) else Y = Y + (renderGetFontDrawHeight(font) / 5) @@ -154,7 +153,7 @@ function main() posX = posX / 2 posY = ((posY / 2.2) - (renderGetFontDrawHeight(font) * 3)) renderText = { - [1] = (render and 'ProdHUD: ON' or 'ProdHUD: OFF'), + [1] = (render and 'Corn-HUD: ON' or 'Corn-HUD: OFF'), [2] = 'Загрузить', [3] = 'Разгрузить', [4] = 'Информация о ферме', @@ -173,10 +172,10 @@ function main() if i == 2 then if points ~= '' then if points:find('Farm') then - local wareprod = (ini[points].prodName == 'Картофель' and urojai or narko ) - local prod = ( (1000 - wareprod) < tonumber(ini[points].product) and (1000 - wareprod) or tonumber(ini[points].product) ) - sampAddChatMessage(prod, -1 ) - sampSendChat('/cornmenu 2 '..prod) + local warecorn = (ini[points].cornName == 'Картофель' and urojai or narko ) + local corn = ( (1000 - warecorn) < tonumber(ini[points].cornuct) and (1000 - warecorn) or tonumber(ini[points].cornuct) ) + sampAddChatMessage(corn, -1 ) + sampSendChat('/cornmenu 2 '..corn) finfoCheck = 1 end if points:find('Zerno') then @@ -242,10 +241,10 @@ function sampev.onCreate3DText(id, color, position, distance, testLOS, attachedP end function sampev.onShowDialog(dialogId, style, title, button1, button2, text) - if text:find('.+Цена зерна: (%d+).*Зерна закуплено: (%d+) / 10000.*.+продукт: (.+).+на складе: (%d+) / 10000.*Цена продукта: (%d+)') then + if text:find(".FBDD7E.Баланс фермы:.FFFFFF.\t\t\t(%d+).+FBDD7E.Семена в амбаре:.FFFFFF.\t\t\t(%d+) / %d+.+FBDD7E.Урожая на поле:{FFFFFF}\t\t\t(%d+) / %d+.+FBDD7E.Продукции в амбаре:.FFFFFF.\t\t\t(%d+) / %d+.+FBDD7E.Цена за семена:.FFFFFF.\t\t\t(%d+).+FBDD7E.Цена на продукцию:.FFFFFF.\t\t\t(%d+)") then local S0 = CheckCoord() if S0 ~= '' then - ini[S0].bank, ini[S0].cornPrice, ini[S0].corn, ini[S0].prodName, ini[S0].product, ini[S0].productPrice = text:match('.+Баланс банка: (%d+).+Цена зерна: (%d+).*Зерна закуплено: (%d+) / 10000.*.+продукт: (%W+)..*Количество на складе: (%d+) / 10000.*Цена продукта: (%d+)') + ini[S0].bank, ini[S0].corn, ini[S0].cornuct, ini[S0].cornPrice, ini[S0].cornuctPrice = text:match(".FBDD7E.Баланс фермы:.FFFFFF.\t\t\t(%d+).+FBDD7E.Семена в амбаре:.FFFFFF.\t\t\t(%d+) / %d+.+FBDD7E.Урожая на поле:{FFFFFF}\t\t\t%d+ / %d+.+FBDD7E.Продукции в амбаре:.FFFFFF.\t\t\t(%d+) / %d+.+FBDD7E.Цена за семена:.FFFFFF.\t\t\t(%d+).+FBDD7E.Цена на продукцию:.FFFFFF.\t\t\t(%d+)") inicfg.save(ini, iniName) if finfoCheck ~= 0 then finfoCheck = 0