|
|
|
@ -2,6 +2,8 @@ script_name("TruckHUD") |
|
|
|
|
script_author("Serhiy_Rubin") |
|
|
|
|
script_version("2209011") |
|
|
|
|
|
|
|
|
|
local inspect = require("inspect") |
|
|
|
|
|
|
|
|
|
local inicfg = require "inicfg" |
|
|
|
|
local dlstatus = require("moonloader").download_status |
|
|
|
|
local vkeys = require "lib.vkeys" |
|
|
|
@ -140,6 +142,17 @@ location_pos = { |
|
|
|
|
["Ïîðò ÑÔ"] = {x = -1731.5022, y = 118.8936, z = 3.5547}, |
|
|
|
|
["Àðåíäà"] = {x = 2239.8333, y = 2779.6016, z = 10.8203} |
|
|
|
|
} |
|
|
|
|
location_keys = { |
|
|
|
|
["n1"] = {x = 256.02127075195, y = 1414.8492431641, z = 10.232398033142, }, |
|
|
|
|
["y1"] = {x = 832.10766601563, y = 864.03668212891, z = 11.643839836121}, |
|
|
|
|
["l1"] = {x = -448.91455078125, y = -65.951385498047, z = 58.959014892578}, |
|
|
|
|
["n2"] = {x = -1046.7521972656, y = -670.66937255859, z = 31.885597229004}, |
|
|
|
|
["y2"] = {x = -2913.8544921875, y = -1377.0952148438, z = 10.762256622314}, |
|
|
|
|
["l2"] = {x = -1978.8649902344, y = -2434.9421386719, z = 30.192840576172}, |
|
|
|
|
["ls"] = {x = 2507.02, y = -2234.05, z = 13.55}, |
|
|
|
|
["sf"] = {x = -1731.5022, y = 118.8936, z = 3.5547} |
|
|
|
|
} |
|
|
|
|
cargo_replace = { "n", "y", "l" } |
|
|
|
|
|
|
|
|
|
binder_mode_sms = false |
|
|
|
|
|
|
|
|
@ -2780,6 +2793,7 @@ function loadEvents() |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function sampev.onRemove3DTextLabel(Cid) -- f3d2 |
|
|
|
|
lua_thread.create(function(Cid) |
|
|
|
|
if id_3D_text == Cid then |
|
|
|
|
id_3D_text = msk_timestamp |
|
|
|
|
load_location = false |
|
|
|
@ -2797,6 +2811,7 @@ function loadEvents() |
|
|
|
|
say("Óäàëåíî "..key[i]) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end, Cid) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -3288,7 +3303,8 @@ function clearSoloMessage() |
|
|
|
|
solo_message_send = { |
|
|
|
|
name = "", |
|
|
|
|
id = -1, |
|
|
|
|
cargo = 0, |
|
|
|
|
action = "", |
|
|
|
|
cargo = "", |
|
|
|
|
time = 0 |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
@ -3296,7 +3312,21 @@ end |
|
|
|
|
function transponder() |
|
|
|
|
new_pair = {} |
|
|
|
|
error_array = {} |
|
|
|
|
solo_data_antiflood = {} |
|
|
|
|
clearSoloMessage() |
|
|
|
|
sampRegisterChatCommand("send",function(param) |
|
|
|
|
if param:find("(.+_.+) (%d+) (.+) (.+)") then |
|
|
|
|
local name, id, action, cargo = param:match("(.+_.+) (%d+) (.+) (.+)") |
|
|
|
|
-- /send name id action cargo |
|
|
|
|
solo_message_send = { |
|
|
|
|
name = name, |
|
|
|
|
id = tonumber(id), |
|
|
|
|
action = action, |
|
|
|
|
cargo = cargo, |
|
|
|
|
time = os.time() |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
end) |
|
|
|
|
while true do |
|
|
|
|
wait(0) |
|
|
|
|
if script_run and inifiles.Settings.transponder then |
|
|
|
@ -3376,7 +3406,13 @@ function transponder() |
|
|
|
|
if f then |
|
|
|
|
local fileText = f:read("*a") |
|
|
|
|
if fileText ~= nil and #fileText > 0 then |
|
|
|
|
try(function() |
|
|
|
|
info = decodeJson(fileText) |
|
|
|
|
end, function(e) |
|
|
|
|
sampfuncsLog(fileText) |
|
|
|
|
sampAddChatMessage("[TruckHUD]: Îøèáî÷íûé îòâåò ñåðâåðà!",-1) |
|
|
|
|
info = nil |
|
|
|
|
end) |
|
|
|
|
if info == nil then |
|
|
|
|
print("{ff0000}[" .. string.upper(thisScript().name) .. "]: Áûë ïîëó÷åí íåêîððåêòíûé îòâåò îò ñåðâåðà.") |
|
|
|
|
else |
|
|
|
@ -3385,6 +3421,9 @@ function transponder() |
|
|
|
|
transponder_delay = info.delay |
|
|
|
|
response_timestamp = info.timestamp |
|
|
|
|
if info.base ~= nil then |
|
|
|
|
transponder_solo_message(info) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
base = info.base |
|
|
|
|
error_message('2', '') |
|
|
|
|
local minKD = 1000000 |
|
|
|
@ -3477,6 +3516,40 @@ function transponder() |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function transponder_solo_message(info) |
|
|
|
|
if info.solo_data ~= nil then |
|
|
|
|
for sender, solo_data in pairs(info.solo_data) do |
|
|
|
|
if info.timestamp - solo_data.time < 5 and getNameById(tonumber(solo_data.id)) == solo_data.name then |
|
|
|
|
if solo_data_antiflood[sender] == nil then |
|
|
|
|
solo_data_antiflood[sender] = {} |
|
|
|
|
end |
|
|
|
|
local result_find = false -- Îòêëîíèòü ïîêàç ñîîáùåíèÿ |
|
|
|
|
local check_label = { "id", "name", "action", "cargo" } |
|
|
|
|
for i = 1, #solo_data_antiflood[sender] do -- Ïîèñê äóáëèêàòà |
|
|
|
|
local counter = 0 |
|
|
|
|
for s = 1, #check_label do |
|
|
|
|
if solo_data[s] == solo_data_antiflood[sender][i][s] then |
|
|
|
|
counter = counter + 1 |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
if counter == 4 and solo_data["time"] - solo_data_antiflood[sender][i]["time"] < 10 then |
|
|
|
|
result_find = true |
|
|
|
|
break |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
if not result_find then |
|
|
|
|
if texts_of_reports[solo_data["cargo"]] ~= nil then |
|
|
|
|
local text = string.format("[TruckHUD]: %s[%s] %s %s", solo_data.name, solo_data.id, (solo_data.action == "load" and "çàãðóçèëñÿ íà" or "ðàçãðóçèë"), texts_of_reports[solo_data["cargo"]]) |
|
|
|
|
sampAddChatMessage(text,-1) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
solo_data_antiflood[sender][#solo_data_antiflood[sender]+1] = solo_data |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function error_message(key, text) |
|
|
|
|
if text ~= '' then |
|
|
|
|
if error_array[key] == nil then |
|
|
|
@ -4146,11 +4219,17 @@ function luChecker.checkerLoad(playerId, data, position) -- |
|
|
|
|
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 |
|
|
|
|
local key = getKeysPoint(trucker_x, trucker_y, trucker_z) |
|
|
|
|
if key == "ls" or key == "sf" then |
|
|
|
|
if inifiles.Settings.luCheckerCargo >= 1 and inifiles.Settings.luCheckerCargo <= 3 then |
|
|
|
|
key = key..cargo_replace[inifiles.Settings.luCheckerCargo] |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
solo_message_send = { |
|
|
|
|
name = getNameById(playerId), |
|
|
|
|
id = playerId, |
|
|
|
|
action = "load" |
|
|
|
|
cargo = inifiles.Settings.luCheckerCargo, |
|
|
|
|
action = "load", |
|
|
|
|
cargo = key, |
|
|
|
|
time = os.time() |
|
|
|
|
} |
|
|
|
|
sampAddChatMessage("èãðîê ïîëó÷èë ãðóç "..playerId.." "..dist_localPlayer_storage.." "..dist_trucker_storage.." +++ "..luChecker.truckers[playerId]["trailerData"]["trailerId"].." ++++ "..data["trailerId"],-1) |
|
|
|
@ -4196,11 +4275,17 @@ function luChecker.checker() |
|
|
|
|
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) |
|
|
|
|
if dist < 50 then |
|
|
|
|
local key = getKeysPoint(position_trailer.x,position_trailer.y,position_trailer.z) |
|
|
|
|
if key == "ls" or key == "sf" then |
|
|
|
|
if inifiles.Settings.luCheckerCargo >= 1 and inifiles.Settings.luCheckerCargo <= 3 then |
|
|
|
|
key = key..cargo_replace[inifiles.Settings.luCheckerCargo] |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
solo_message_send = { |
|
|
|
|
name = getNameById(playerId), |
|
|
|
|
id = playerId, |
|
|
|
|
action = "unload" |
|
|
|
|
cargo = inifiles.Settings.luCheckerCargo, |
|
|
|
|
action = "unload", |
|
|
|
|
cargo = key, |
|
|
|
|
time = os.time() |
|
|
|
|
} |
|
|
|
|
local text = string.format("èãðîê %s %s %s %s", playerId, (type == "load" and "çàãðóçèë" or "ðàçãðóçèë"), inifiles.Settings.luCheckerCargo, dist ) |
|
|
|
@ -4221,7 +4306,7 @@ end |
|
|
|
|
function getNameById(i) |
|
|
|
|
local name = "" |
|
|
|
|
if sampIsPlayerConnected(i) or i == select(2,sampGetPlayerIdByCharHandle(PLAYER_PED)) then |
|
|
|
|
local name = sampGetPlayerNickname(i) |
|
|
|
|
name = sampGetPlayerNickname(i) |
|
|
|
|
end |
|
|
|
|
return name |
|
|
|
|
end |
|
|
|
@ -4239,6 +4324,19 @@ function clear_old_value(key) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
function getKeysPoint(x, y, z) |
|
|
|
|
local minDist, minResult = 1000000, "" |
|
|
|
|
for name, cord in pairs(location_keys) do |
|
|
|
|
local distance = getDistanceBetweenCoords3d(x, y, z, cord.x, cord.y, cord.z) |
|
|
|
|
if distance < minDist then |
|
|
|
|
minDist = distance |
|
|
|
|
minResult = name |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
return minResult |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--- luCheckerCargo |
|
|
|
|
--[[ |
|
|
|
|