replace name prod>corn & fix dialog finfo & delete narko

master
rubin 2 years ago
parent cfb82c2d4b
commit 4668297ae9
  1. 69
      corn-hud.lua

@ -1,4 +1,4 @@
script_name('ProdHUD') script_name('cornHUD')
script_author("Serhiy_Rubin") script_author("Serhiy_Rubin")
script_version("22/09/2019") script_version("22/09/2019")
require 'lib.sampfuncs' require 'lib.sampfuncs'
@ -34,46 +34,46 @@ function main()
if string.find(hostName, "Revolution") then serverName = "Revolution" end 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 hostName == "Samp-Rp.Ru Server 02 Client 0.3.7" then serverName = "Two" end
if serverName == nil then thisScript():unload() end if serverName == nil then thisScript():unload() end
iniName = string.format("ProdHUD-%s", serverName) iniName = string.format("cornHUD-%s", serverName)
ini = inicfg.load({ ini = inicfg.load({
['Farm 0'] = { ['Farm 0'] = {
corn = 0, corn = 0,
cornPrice = 0, cornPrice = 0,
product = 0, cornuct = 0,
productPrice = 0, cornuctPrice = 0,
prodName = '', cornName = '',
bank = 0 bank = 0
}, },
['Farm 1'] = { ['Farm 1'] = {
corn = 0, corn = 0,
cornPrice = 0, cornPrice = 0,
product = 0, cornuct = 0,
productPrice = 0, cornuctPrice = 0,
prodName = '', cornName = '',
bank = 0 bank = 0
}, },
['Farm 2'] = { ['Farm 2'] = {
corn = 0, corn = 0,
cornPrice = 0, cornPrice = 0,
product = 0, cornuct = 0,
productPrice = 0, cornuctPrice = 0,
prodName = '', cornName = '',
bank = 0 bank = 0
}, },
['Farm 3'] = { ['Farm 3'] = {
corn = 0, corn = 0,
cornPrice = 0, cornPrice = 0,
product = 0, cornuct = 0,
productPrice = 0, cornuctPrice = 0,
prodName = '', cornName = '',
bank = 0 bank = 0
}, },
['Farm 4'] = { ['Farm 4'] = {
corn = 0, corn = 0,
cornPrice = 0, cornPrice = 0,
product = 0, cornuct = 0,
productPrice = 0, cornuctPrice = 0,
prodName = '', cornName = '',
bank = 0 bank = 0
}, },
price = { price = {
@ -96,10 +96,10 @@ function main()
}, },
}, iniName) }, iniName)
inicfg.save(ini, 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) font = renderCreateFont(ini.Render.FontName, ini.Render.FontSize, ini.Render.FontFlag)
sampRegisterChatCommand('prod', function(param) sampRegisterChatCommand('corn', function(param)
if param:lower():find('pos') then if render and param:lower():find('pos') then
SetPos() SetPos()
else else
render = not render render = not render
@ -128,18 +128,17 @@ function main()
renderText = { renderText = {
[1] = '{00D900}Öåíà ïîêóïêè çåðíà: '..ini.price.zerno..'$', [1] = '{00D900}Öåíà ïîêóïêè çåðíà: '..ini.price.zerno..'$',
[2] = '{00D900}Öåíà ïðîäàæè óðîæàÿ: '..ini.price.urojai..'$', [2] = '{00D900}Öåíà ïðîäàæè óðîæàÿ: '..ini.price.urojai..'$',
[3] = '{00D900}Öåíà ïðîäàæè íàðêîòèêîâ: '..ini.price.narko..'$', [3] = '{00D900} ',
[4] = '{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}Ôåðìà ¹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), [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}Ôåðìà ¹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), [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}Ôåðìà ¹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), [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}Ôåðìà ¹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), [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),
[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),
} }
local X, Y = ini.Settings.X, ini.Settings.Y local X, Y = ini.Settings.X, ini.Settings.Y
for i = 1, #renderText do for i = 1, #renderText do
renderFontDrawText(font, renderText[i], X, Y, -1) renderFontDrawText(font, renderText[i], X, Y, -1)
if i ~= 4 then if i ~= 3 then
Y = Y + (renderGetFontDrawHeight(font) - (renderGetFontDrawHeight(font) / 5)) Y = Y + (renderGetFontDrawHeight(font) - (renderGetFontDrawHeight(font) / 5))
else else
Y = Y + (renderGetFontDrawHeight(font) / 5) Y = Y + (renderGetFontDrawHeight(font) / 5)
@ -154,7 +153,7 @@ function main()
posX = posX / 2 posX = posX / 2
posY = ((posY / 2.2) - (renderGetFontDrawHeight(font) * 3)) posY = ((posY / 2.2) - (renderGetFontDrawHeight(font) * 3))
renderText = { renderText = {
[1] = (render and 'ProdHUD: ON' or 'ProdHUD: OFF'), [1] = (render and 'Corn-HUD: ON' or 'Corn-HUD: OFF'),
[2] = 'Çàãðóçèòü', [2] = 'Çàãðóçèòü',
[3] = 'Ðàçãðóçèòü', [3] = 'Ðàçãðóçèòü',
[4] = 'Èíôîðìàöèÿ î ôåðìå', [4] = 'Èíôîðìàöèÿ î ôåðìå',
@ -173,10 +172,10 @@ function main()
if i == 2 then if i == 2 then
if points ~= '' then if points ~= '' then
if points:find('Farm') then if points:find('Farm') then
local wareprod = (ini[points].prodName == 'Êàðòîôåëü' and urojai or narko ) local warecorn = (ini[points].cornName == 'Êàðòîôåëü' and urojai or narko )
local prod = ( (1000 - wareprod) < tonumber(ini[points].product) and (1000 - wareprod) or tonumber(ini[points].product) ) local corn = ( (1000 - warecorn) < tonumber(ini[points].cornuct) and (1000 - warecorn) or tonumber(ini[points].cornuct) )
sampAddChatMessage(prod, -1 ) sampAddChatMessage(corn, -1 )
sampSendChat('/cornmenu 2 '..prod) sampSendChat('/cornmenu 2 '..corn)
finfoCheck = 1 finfoCheck = 1
end end
if points:find('Zerno') then if points:find('Zerno') then
@ -242,10 +241,10 @@ function sampev.onCreate3DText(id, color, position, distance, testLOS, attachedP
end end
function sampev.onShowDialog(dialogId, style, title, button1, button2, text) 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() local S0 = CheckCoord()
if S0 ~= '' then 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) inicfg.save(ini, iniName)
if finfoCheck ~= 0 then if finfoCheck ~= 0 then
finfoCheck = 0 finfoCheck = 0

Loading…
Cancel
Save