fix load/unload & add update button menu

master
rubin 2 years ago
parent 4668297ae9
commit c0904a85b5
  1. 160
      corn-hud.lua

@ -14,7 +14,7 @@ local coord = {
['Farm 4'] = {x = 1912.754150, y = 176.559540, z = 37.375542 },
['Narko'] = {x = 2182.483887, y = -1657.505615, z = 15.201279 },
['Zerno'] = {x = 2206.272949, y = -2245.668457, z = 13.661810 },
['Urojai'] = {x = 1622.458374, y = 2327.077881, z = 10.934480 }
['Urojai'] = {x = 972.86, y = 2105.53, z = 10.94 }
}
function main()
@ -39,41 +39,36 @@ function main()
['Farm 0'] = {
corn = 0,
cornPrice = 0,
cornuct = 0,
cornuctPrice = 0,
cornName = '',
product = 0,
productPrice = 0,
bank = 0
},
['Farm 1'] = {
corn = 0,
cornPrice = 0,
cornuct = 0,
cornuctPrice = 0,
cornName = '',
product = 0,
productPrice = 0,
bank = 0
},
['Farm 2'] = {
corn = 0,
cornPrice = 0,
cornuct = 0,
cornuctPrice = 0,
cornName = '',
product = 0,
productPrice = 0,
bank = 0
},
['Farm 3'] = {
corn = 0,
cornPrice = 0,
cornuct = 0,
cornuctPrice = 0,
cornName = '',
product = 0,
productPrice = 0,
bank = 0
},
['Farm 4'] = {
corn = 0,
cornPrice = 0,
cornuct = 0,
cornuctPrice = 0,
cornName = '',
product = 0,
productPrice = 0,
bank = 0
},
price = {
@ -98,6 +93,11 @@ function main()
inicfg.save(ini, iniName)
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('getcoord', function(param)
local x, y, z = getCharCoordinates(PLAYER_PED)
string = string.format("%0.2f, %0.2f, %0.2f", x, y, z)
setClipboardText(string)
end)
sampRegisterChatCommand('corn', function(param)
if render and param:lower():find('pos') then
SetPos()
@ -129,11 +129,11 @@ function main()
[1] = '{00D900}Öåíà ïîêóïêè çåðíà: '..ini.price.zerno..'$',
[2] = '{00D900}Öåíà ïðîäàæè óðîæàÿ: '..ini.price.urojai..'$',
[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),
[4] = string.format('{00D900}Ôåðìà ¹0 | Áàëàíñ: %d$ | Çåðíî: %d [%d$] | Óðîæàé: %d [%d$]', ini['Farm 0'].bank, ini['Farm 0'].corn, ini['Farm 0'].cornPrice, ini['Farm 0'].product, ini['Farm 0'].productPrice),
[5] = string.format('{00D900}Ôåðìà ¹1 | Áàëàíñ: %d$ | Çåðíî: %s [%s$] | Óðîæàé: %s [%s$]', ini['Farm 1'].bank, ini['Farm 1'].corn, ini['Farm 1'].cornPrice, ini['Farm 1'].product, ini['Farm 1'].productPrice),
[6] = string.format('{00D900}Ôåðìà ¹2 | Áàëàíñ: %d$ | Çåðíî: %s [%s$] | Óðîæàé: %s [%s$]', ini['Farm 2'].bank, ini['Farm 2'].corn, ini['Farm 2'].cornPrice, ini['Farm 2'].product, ini['Farm 2'].productPrice),
[7] = string.format('{00D900}Ôåðìà ¹3 | Áàëàíñ: %d$ | Çåðíî: %s [%s$] | Óðîæàé: %s [%s$]', ini['Farm 3'].bank, ini['Farm 3'].corn, ini['Farm 3'].cornPrice, ini['Farm 3'].product, ini['Farm 3'].productPrice),
[8] = string.format('{00D900}Ôåðìà ¹4 | Áàëàíñ: %d$ | Çåðíî: %s [%s$] | Óðîæàé: %s [%s$]', ini['Farm 4'].bank, ini['Farm 4'].corn, ini['Farm 4'].cornPrice, ini['Farm 4'].product, ini['Farm 4'].productPrice),
}
local X, Y = ini.Settings.X, ini.Settings.Y
for i = 1, #renderText do
@ -157,51 +157,48 @@ function main()
[2] = 'Çàãðóçèòü',
[3] = 'Ðàçãðóçèòü',
[4] = 'Èíôîðìàöèÿ î ôåðìå',
[5] = 'Îáíîâèòü èíôîðìàöèþ î ôåðìå'
}
for i = 1, #renderText do
renderFontDrawText(font, renderText[i], posX - (renderGetFontDrawTextLength(font, renderText[i]) / 2), posY, 0xFF00D900)
local textLenght = renderGetFontDrawTextLength(font, renderText[i])
local textHeight = renderGetFontDrawHeight(font)
local curX, curY = getCursorPos()
if curX >= posX and curX <= posX + textLenght and curY >= posY and curY <= posY + textHeight then
renderFontDrawText(font, renderText[i], posX - (renderGetFontDrawTextLength(font, renderText[i]) / 2), posY, -1)
if isKeyJustPressed(1) then
if i == 1 then
render = not render
end
if i == 2 then
if points ~= '' then
if points:find('Farm') then
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
sampSendChat('/cornmenu 0 '..(1000 - zerno))
end
end
end
if i == 3 then
if points ~= '' then
if points:find('Farm') then
sampSendChat('/cornmenu 1 '..zerno)
finfoCheck = 1
end
if points:find('Narko') then
sampSendChat('/cornmenu 3 '..narko)
end
if points:find('Urojai') then
sampSendChat('/cornmenu 3 '..urojai)
end
end
end
if i == 4 then
sampSendChat('/finfo')
end
end
if drawClickableText(renderText[i], posX - (renderGetFontDrawTextLength(font, renderText[i]) / 2), posY, 0xFF00D900, 0xFFFFFFFF) then
if i == 1 then
render = not render
end
if i == 2 then
if points ~= '' then
if points:find('Farm') then
local warecorn = urojai
local corn = ( (1500 - warecorn) < tonumber(ini[points].product) and (1500 - warecorn) or tonumber(ini[points].product) )
sampSendChat('/cornmenu 2 '..corn)
finfoCheck = 1
end
if points:find('Zerno') then
sampSendChat('/cornmenu 0 '..(1500 - zerno))
end
end
end
if i == 3 then
if points ~= '' then
if points:find('Farm') then
sampSendChat('/cornmenu 1 '..(zerno > (10000 - ini[points].corn) and (10000 - ini[points].corn) or zerno))
finfoCheck = 1
end
if points:find('Narko') then
sampSendChat('/cornmenu 4 '..narko)
end
if points:find('Urojai') then
sampSendChat('/cornmenu 4 '..urojai)
end
end
end
if i == 4 then
sampSendChat('/finfo')
end
if i == 5 then
finfoCheck = 1
end
end
posY = posY + plus
end
else
@ -214,14 +211,14 @@ function main()
end
function sampev.onServerMessage(color, message)
if message:find(' Çåðíî: (%d+) / 1000') then
zerno = message:match(' Çåðíî: (%d+) / 1000')
if message:find(' Çåðíî: (%d+) / 1500') then
zerno = tonumber(message:match(' Çåðíî: (%d+) / 1500'))
end
if message:find(' Óðîæàé: (%d+) / 1000') then
urojai = message:match(' Óðîæàé: (%d+) / 1000')
if message:find(' Óðîæàé: (%d+) / 1500') then
urojai = tonumber(message:match(' Óðîæàé: (%d+) / 1500'))
end
if message:find(' Íàðêîòèêè: (%d+) / 1000') then
narko = message:match(' Íàðêîòèêè: (%d+) / 1000')
if message:find(' Íàðêîòèêè: (%d+) / 1500') then
narko = tonumber(message:match(' Íàðêîòèêè: (%d+) / 1500'))
end
end
@ -244,7 +241,7 @@ function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
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].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+)")
ini[S0].bank, ini[S0].corn, ini[S0].product, ini[S0].cornPrice, ini[S0].productPrice = 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
@ -254,15 +251,19 @@ function sampev.onShowDialog(dialogId, style, title, button1, button2, text)
end
if text:find('{FFFFFF}Çåðíà êóïëåíî: {0289CC}(%d+).*{FFFFFF}Öåíà: {0289CC}%d+ âèðò.*{FFFFFF}Ñêèäêà: {0289CC}%d+ âèðò') then
zerno = zerno + tonumber(text:match('{FFFFFF}Çåðíà êóïëåíî: {0289CC}(%d+).*{FFFFFF}Öåíà: {0289CC}%d+ âèðò.*{FFFFFF}Ñêèäêà: {0289CC}%d+ âèðò'))
print(zerno)
end
if text:find('{FFFFFF}Çåðíà ïðîäàíî: {0289CC}(%d+).*{FFFFFF}Öåíà: {0289CC}%d+ âèðò.*{FFFFFF}Äîáàâëåíî ê ÇÏ: {0289CC}%d+ âèðò') then
zerno = zerno - tonumber(text:match('{FFFFFF}Çåðíà ïðîäàíî: {0289CC}(%d+).*{FFFFFF}Öåíà: {0289CC}%d+ âèðò.*{FFFFFF}Äîáàâëåíî ê ÇÏ: {0289CC}%d+ âèðò'))
print(zerno)
end
if text:find('{FFFFFF}Óðîæàÿ êóïëåíî: {0289CC}(%d+).*{FFFFFF}Öåíà: {0289CC}%d+ âèðò') then
urojai = urojai + tonumber(text:match('{FFFFFF}Óðîæàÿ êóïëåíî: {0289CC}(%d+).*{FFFFFF}Öåíà: {0289CC}%d+ âèðò'))
print(urojai)
end
if text:find('Óðîæàÿ ïðîäàíî: {0289CC}(%d+).*{FFFFFF}Öåíà: {0289CC}%d+ âèðò') then
urojai = urojai - tonumber(text:match('Óðîæàÿ ïðîäàíî: {0289CC}(%d+).*{FFFFFF}Öåíà: {0289CC}%d+ âèðò'))
print(urojai)
end
if text:find('{FFFFFF}Íàðêîòèêîâ êóïëåíî: {0289CC}(%d+).*{FFFFFF}Öåíà: {0289CC}%d+ âèðò') then
narko = narko + tonumber(text:match('{FFFFFF}Íàðêîòèêîâ êóïëåíî: {0289CC}(%d+).*{FFFFFF}Öåíà: {0289CC}%d+ âèðò'))
@ -301,4 +302,23 @@ function SetPos()
wait(100)
pos = false
end)
end
function drawClickableText(text, posX, posY, Color1, Color2)
if text ~= nil and posX ~= nil and posY ~= nil then
renderFontDrawText(font, text, posX, posY, Color1)
local textLenght = renderGetFontDrawTextLength(font, text)
local textHeight = renderGetFontDrawHeight(font)
local curX, curY = getCursorPos()
if curX >= posX and curX <= posX + textLenght and curY >= posY and curY <= posY + textHeight then
renderFontDrawText(font, text, posX, posY, Color2)
if isKeyJustPressed(1) then
return true
else
return false
end
end
else
return false
end
end
Loading…
Cancel
Save