From 8166c351649ae37786945179816a9066d4c0e8e6 Mon Sep 17 00:00:00 2001 From: rubin Date: Sun, 22 Jan 2023 23:58:42 +0300 Subject: [PATCH] remove unnecessary & update server detect --- corn-hud.lua | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/corn-hud.lua b/corn-hud.lua index 5ca91af..12e02fe 100644 --- a/corn-hud.lua +++ b/corn-hud.lua @@ -20,21 +20,18 @@ local coord = { function main() if not isSampLoaded() or not isSampfuncsLoaded() then return end while not isSampAvailable() do wait(0) end - repeat - wait(100) - local res, id = sampGetPlayerIdByCharHandle(PLAYER_PED) - nickname = sampGetPlayerNickname(id) - if res then score = sampGetPlayerScore(id) end - until score > 0 - local magicChar = { ":", "|" } - local hostName = sampGetCurrentServerName() - for i = 1, #magicChar do hostName = hostName:gsub(magicChar[i], '') end - if string.find(hostName, "Legacy") then serverName = "Legacy" end - if string.find(hostName, "Reborn") then serverName = "Reborn" 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 serverName == nil then thisScript():unload() end - iniName = string.format("cornHUD-%s", serverName) + repeat wait(0) until sampGetCurrentServerName() ~= "SA-MP" + repeat wait(0) until sampGetCurrentServerName():find("Samp%-Rp.Ru") or sampGetCurrentServerName():find("SRP") + server = sampGetCurrentServerName():gsub("|", "") + server = + (server:find("02") and "Two" or + (server:find("Revo") and "Revolution" or + (server:find("Legacy") and "Legacy" or (server:find("Classic") and "Classic" or + (server:find("Zero Two") and "Two" or ""))))) + if server == "" then + thisScript():unload() + end + iniName = string.format("cornHUD-%s", server) ini = inicfg.load({ ['Farm 0'] = { corn = 0, @@ -91,13 +88,8 @@ function main() }, }, iniName) 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_", '')) + sampfuncsLog(' {FFFFFF}corn-hud 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()