add send solo checker

test-utf-8
rubin 2 years ago
parent b94c097447
commit 10b073a229
  1. 102
      TruckHUD.lua

@ -56,13 +56,14 @@ local menu = {
[2] = {[1] = "Load/Unload: {06940f}ON", [2] = "Load/Unload: {d10000}OFF", run = false}, [2] = {[1] = "Load/Unload: {06940f}ON", [2] = "Load/Unload: {d10000}OFF", run = false},
[3] = {[1] = "Àâòî-Äîêëàä: {06940f}ON", [2] = "Àâòî-Äîêëàä: {d10000}OFF", run = false}, [3] = {[1] = "Àâòî-Äîêëàä: {06940f}ON", [2] = "Àâòî-Äîêëàä: {d10000}OFF", run = false},
[4] = {[1] = "SMS » Serhiy_Rubin[777]", [2] = "Ðåæèì ïàðû: {d10000}OFF", run = false}, [4] = {[1] = "SMS » Serhiy_Rubin[777]", [2] = "Ðåæèì ïàðû: {d10000}OFF", run = false},
[5] = {[1] = "Äàëüíîáîéùèêè îíëàéí", [2] = "Äàëüíîáîéùèêè îíëàéí", run = false}, [5] = {[1] = "Ñîëî-×åêåð: ", [2] = "Ñîëî-×åêåð: ", run = false},
[6] = {[1] = "Äàëüíîáîéùèêè ñî ñêðèïòîì", [2] = "Äàëüíîáîéùèêè ñî ñêðèïòîì", run = false}, [6] = {[1] = "Äàëüíîáîéùèêè îíëàéí", [2] = "Äàëüíîáîéùèêè îíëàéí", run = false},
[7] = {[1] = "Íàñòðîéêè", [2] = "Íàñòðîéêè", run = false}, [7] = {[1] = "Äàëüíîáîéùèêè ñî ñêðèïòîì", [2] = "Äàëüíîáîéùèêè ñî ñêðèïòîì", run = false},
[8] = {[1] = "Ìîíèòîðèíã öåí", [2] = "Ìîíèòîðèíã öåí", run = false}, [8] = {[1] = "Íàñòðîéêè", [2] = "Íàñòðîéêè", run = false},
[9] = {[1] = "Êóïèòü ãðóç", [2] = "Êóïèòü ãðóç", run = false}, [9] = {[1] = "Ìîíèòîðèíã öåí", [2] = "Ìîíèòîðèíã öåí", run = false},
[10] = {[1] = "Ïðîäàòü ãðóç", [2] = "Ïðîäàòü ãðóç", run = false}, [10] = {[1] = "Êóïèòü ãðóç", [2] = "Êóïèòü ãðóç", run = false},
[11] = {[1] = "Âîññòàíîâèòü ãðóç", [2] = "Âîññòàíîâèòü ãðóç", run = false} [11] = {[1] = "Ïðîäàòü ãðóç", [2] = "Ïðîäàòü ãðóç", run = false},
[12] = {[1] = "Âîññòàíîâèòü ãðóç", [2] = "Âîññòàíîâèòü ãðóç", run = false}
} }
local pair_mode, sms_pair_mode, report_text, pair_mode_id, pair_mode_name, BinderMode = false, "", "", -1, "Íåò", true local pair_mode, sms_pair_mode, report_text, pair_mode_id, pair_mode_name, BinderMode = false, "", "", -1, "Íåò", true
@ -389,6 +390,12 @@ function doControl()
Y = ((Y / 2.2) - (renderGetFontDrawHeight(font) * 3)) Y = ((Y / 2.2) - (renderGetFontDrawHeight(font) * 3))
for i = 1, 11 do for i = 1, 11 do
local string_render = (menu[i].run and menu[i][1] or menu[i][2]) local string_render = (menu[i].run and menu[i][1] or menu[i][2])
if i == 5 then
local text = { "{d10000}OFF", "{06940f}Íåôòü", "{06940f}Óãîëü", "{06940f}Äåðåâî" }
if text[inifiles.Settings.luCheckerCargo+1] ~= nil then
string_render = string.format("%s%s", string_render, text[inifiles.Settings.luCheckerCargo+1])
end
end
if drawClickableText(string_render, ((X / 2) - (renderGetFontDrawTextLength(font, string_render) / 2)), Y) then if drawClickableText(string_render, ((X / 2) - (renderGetFontDrawTextLength(font, string_render) / 2)), Y) then
if i == 1 then if i == 1 then
script_run = not script_run script_run = not script_run
@ -415,24 +422,32 @@ function doControl()
end end
end end
if i == 5 then if i == 5 then
inifiles.Settings.luCheckerCargo = inifiles.Settings.luCheckerCargo + 1
if inifiles.Settings.luCheckerCargo >= 4 then
inifiles.Settings.luCheckerCargo = 0
end
luChecker.load_position.x, luChecker.load_position.y, luChecker.load_position.z = 7777.0, 7777.0, 7777.0
settings_save()
end
if i == 6 then
delay.dir = 1 delay.dir = 1
end end
if i == 6 and script_run then if i == 7 and script_run then
lua_thread.create(showTruckers) lua_thread.create(showTruckers)
end end
if i == 7 then if i == 8 then
ShowDialog1(1) ShowDialog1(1)
end end
if i == 8 then if i == 9 then
sampSendChat("/truck mon") sampSendChat("/truck mon")
end end
if i == 9 then if i == 10 then
sampSendChat("/truck load " .. GetGruz()) sampSendChat("/truck load " .. GetGruz())
end end
if i == 10 then if i == 11 then
sampSendChat("/truck unload") sampSendChat("/truck unload")
end end
if i == 11 then if i == 12 then
sampSendChat("/truck trailer") sampSendChat("/truck trailer")
end end
end end
@ -2073,7 +2088,7 @@ function loadEvents()
function() function()
local fpath = os.getenv("TEMP") .. "\\TruckHUD-up.txt" local fpath = os.getenv("TEMP") .. "\\TruckHUD-up.txt"
downloadUrlToFile( downloadUrlToFile(
"http://th.deadpoo.net/download/changelog", "http://thprivate.deadpoo.net/download/changelog",
fpath, fpath,
function(id, status, p1, p2) function(id, status, p1, p2)
if stop_downloading_3 then if stop_downloading_3 then
@ -2937,7 +2952,7 @@ end
function check_version(update, downgrade_ver) function check_version(update, downgrade_ver)
local fpath = os.getenv("TEMP") .. "\\truck-version.txt" local fpath = os.getenv("TEMP") .. "\\truck-version.txt"
downloadUrlToFile( downloadUrlToFile(
"http://th.deadpoo.net/download/version", "http://thprivate.deadpoo.net/download/version",
fpath, fpath,
function(id, status, p1, p2) function(id, status, p1, p2)
if status == dlstatus.STATUS_ENDDOWNLOADDATA then if status == dlstatus.STATUS_ENDDOWNLOADDATA then
@ -2981,7 +2996,7 @@ function check_version(update, downgrade_ver)
lua_thread.create(function(data) lua_thread.create(function(data)
wait(1000) wait(1000)
fpath = os.getenv("TEMP").."\\truck-update.txt" fpath = os.getenv("TEMP").."\\truck-update.txt"
downloadUrlToFile("http://th.deadpoo.net/download/"..downgrade_ver, fpath, downloadUrlToFile("http://thprivate.deadpoo.net/download/"..downgrade_ver, fpath,
function(id3, status1, p13, p23) function(id3, status1, p13, p23)
if status1 == dlstatus.STATUS_ENDDOWNLOADDATA then if status1 == dlstatus.STATUS_ENDDOWNLOADDATA then
local f = io.open(fpath, "r") local f = io.open(fpath, "r")
@ -3268,9 +3283,20 @@ end
--------------------------------------GMAP-------------------------------------- --------------------------------------GMAP--------------------------------------
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
delay_start = 0 delay_start = 0
function clearSoloMessage()
solo_message_send = {
name = "",
id = -1,
cargo = 0,
time = 0
}
end
function transponder() function transponder()
new_pair = {} new_pair = {}
error_array = {} error_array = {}
clearSoloMessage()
while true do while true do
wait(0) wait(0)
if script_run and inifiles.Settings.transponder then if script_run and inifiles.Settings.transponder then
@ -3287,6 +3313,10 @@ function transponder()
local result, myid = sampGetPlayerIdByCharHandle(PLAYER_PED) local result, myid = sampGetPlayerIdByCharHandle(PLAYER_PED)
local myname = sampGetPlayerNickname(myid) local myname = sampGetPlayerNickname(myid)
if os.time() - solo_message_send.time > 5 then -- Î÷èñòèòü åñëè äàííûå óñòàðåëè
clearSoloMessage()
end
request_table["info"] = { request_table["info"] = {
server = ip .. ":" .. tostring(port), server = ip .. ":" .. tostring(port),
sender = myname, sender = myname,
@ -3301,7 +3331,8 @@ function transponder()
paraid = pair_mode_id, paraid = pair_mode_id,
timer = timer, timer = timer,
tmonitor = inifiles.tmonitor tmonitor = inifiles.tmonitor
} },
solo_message = solo_message_send
} }
request_table['random'] = tostring(os.clock()):gsub('%.', '') request_table['random'] = tostring(os.clock()):gsub('%.', '')
@ -3317,7 +3348,7 @@ function transponder()
local response_path = os.tmpname() local response_path = os.tmpname()
down = false down = false
download_id_4 = downloadUrlToFile( download_id_4 = downloadUrlToFile(
"http://th.deadpoo.net/" .. encodeJson(request_table), "http://thprivate.deadpoo.net/" .. encodeJson(request_table),
response_path, response_path,
function(id, status, p1, p2) function(id, status, p1, p2)
if stop_downloading_4 then if stop_downloading_4 then
@ -3350,6 +3381,7 @@ function transponder()
print("{ff0000}[" .. string.upper(thisScript().name) .. "]: Áûë ïîëó÷åí íåêîððåêòíûé îòâåò îò ñåðâåðà.") print("{ff0000}[" .. string.upper(thisScript().name) .. "]: Áûë ïîëó÷åí íåêîððåêòíûé îòâåò îò ñåðâåðà.")
else else
if download_call == 0 then if download_call == 0 then
clearSoloMessage()
transponder_delay = info.delay transponder_delay = info.delay
response_timestamp = info.timestamp response_timestamp = info.timestamp
if info.base ~= nil then if info.base ~= nil then
@ -3478,7 +3510,7 @@ function dn(nam)
file = getGameDirectory() .. "\\moonloader\\resource\\TruckHUD\\" .. nam file = getGameDirectory() .. "\\moonloader\\resource\\TruckHUD\\" .. nam
if not doesFileExist(file) then if not doesFileExist(file) then
downloadUrlToFile( downloadUrlToFile(
"http://th.deadpoo.net/download/" .. nam, "http://thprivate.deadpoo.net/download/" .. nam,
file file
) )
end end
@ -3599,7 +3631,7 @@ function get_time()
_time = os.time() _time = os.time()
if inifiles.Settings.transponder then if inifiles.Settings.transponder then
local adress = os.getenv('TEMP')..'\\truck-timestamp' local adress = os.getenv('TEMP')..'\\truck-timestamp'
local url = 'http://th.deadpoo.net/timestamp' local url = 'http://thprivate.deadpoo.net/timestamp'
downloadUrlToFile(url, adress, function(id, status, p1, p2) downloadUrlToFile(url, adress, function(id, status, p1, p2)
if status == dlstatus.STATUSEX_ENDDOWNLOAD then if status == dlstatus.STATUSEX_ENDDOWNLOAD then
if doesFileExist(adress) then if doesFileExist(adress) then
@ -4114,6 +4146,13 @@ function luChecker.checkerLoad(playerId, data, position) --
local dist_trucker_storage = getDistanceBetweenCoords3d(trucker_x, trucker_y, trucker_z, x, y, z) local dist_trucker_storage = getDistanceBetweenCoords3d(trucker_x, trucker_y, trucker_z, x, y, z)
if dist_localPlayer_storage <= 120.0 and dist_trucker_storage <= 50.0 then if dist_localPlayer_storage <= 120.0 and dist_trucker_storage <= 50.0 then
solo_message_send = {
name = getNameById(playerId),
id = playerId,
action = "load"
cargo = inifiles.Settings.luCheckerCargo,
time = os.time()
}
sampAddChatMessage("èãðîê ïîëó÷èë ãðóç "..playerId.." "..dist_localPlayer_storage.." "..dist_trucker_storage.." +++ "..luChecker.truckers[playerId]["trailerData"]["trailerId"].." ++++ "..data["trailerId"],-1) sampAddChatMessage("èãðîê ïîëó÷èë ãðóç "..playerId.." "..dist_localPlayer_storage.." "..dist_trucker_storage.." +++ "..luChecker.truckers[playerId]["trailerData"]["trailerId"].." ++++ "..data["trailerId"],-1)
end end
end end
@ -4121,7 +4160,6 @@ function luChecker.checkerLoad(playerId, data, position) --
end end
function luChecker.set3Dtext(type, data_old, data, position) function luChecker.set3Dtext(type, data_old, data, position)
inifiles.Settings.luCheckerCargo = 1
if type == "Ïîðò" then if type == "Ïîðò" then
local key = inifiles.Settings.luCheckerCargo local key = inifiles.Settings.luCheckerCargo
say(string.format("%s %s", data_old[key], data[key])) say(string.format("%s %s", data_old[key], data[key]))
@ -4157,9 +4195,17 @@ function luChecker.checker()
if getLocalPlayerId() ~= playerId then if getLocalPlayerId() ~= playerId then
local dist = getDistanceBetweenCoords3d(position_3dtext.x,position_3dtext.y,position_3dtext.z,position_trailer.x,position_trailer.y,position_trailer.z) local dist = getDistanceBetweenCoords3d(position_3dtext.x,position_3dtext.y,position_3dtext.z,position_trailer.x,position_trailer.y,position_trailer.z)
if dist < 50 then
local text = string.format("èãðîê %s %s %s %s", playerId, (type == "load" and "çàãðóçèë" or "ðàçãðóçèë"), inifiles.Settings.luCheckerCargo, dist ) solo_message_send = {
say(">> "..text) name = getNameById(playerId),
id = playerId,
action = "unload"
cargo = inifiles.Settings.luCheckerCargo,
time = os.time()
}
local text = string.format("èãðîê %s %s %s %s", playerId, (type == "load" and "çàãðóçèë" or "ðàçãðóçèë"), inifiles.Settings.luCheckerCargo, dist )
say(">> "..text)
end
end end
table.remove(luChecker.trailer_delete, 1) table.remove(luChecker.trailer_delete, 1)
@ -4172,6 +4218,14 @@ function getLocalPlayerId()
return select(2,sampGetPlayerIdByCharHandle(PLAYER_PED)) return select(2,sampGetPlayerIdByCharHandle(PLAYER_PED))
end end
function getNameById(i)
local name = ""
if sampIsPlayerConnected(i) or i == select(2,sampGetPlayerIdByCharHandle(PLAYER_PED)) then
local name = sampGetPlayerNickname(i)
end
return name
end
function clear_old_value(key) function clear_old_value(key)
local delete = {} local delete = {}
for i = 1, #luChecker[key] do for i = 1, #luChecker[key] do

Loading…
Cancel
Save