add checker 3d text on changed price

test-utf-8
rubin 2 years ago
parent b2fe6cf38b
commit 0e32990d75
  1. 96
      TruckHUD.lua

@ -75,6 +75,8 @@ local my_nick, server, timer_min, timer_sec, workload = "", "", 0, 0, 0
local mon_life, mon_time, mon_ctime = 0, 0, 0
local prices_3dtext_pos = {}
local prices_3dtext_id = {}
local prices_3dtext = { n1 = 0, n2 = 0, y1 = 0, y2 = 0, l1 = 0, l2 = 0, lsn = 0, lsy = 0, lsl = 0, sfn = 0, sfy = 0, sfl = 0 }
local prices_mon = { n1 = 0, n2 = 0, y1 = 0, y2 = 0, l1 = 0, l2 = 0, lsn = 0, lsy = 0, lsl = 0, sfn = 0, sfy = 0, sfl = 0 }
local prices_smon = { n1 = 0, n2 = 0, y1 = 0, y2 = 0, l1 = 0, l2 = 0, lsn = 0, lsy = 0, lsl = 0, sfn = 0, sfy = 0, sfl = 0 }
@ -269,7 +271,8 @@ function settings_load()
stats_text = defaultMon,
renderTruck = true,
AutoClear = true,
NewPairMSG = true
NewPairMSG = true,
luCheckerCargo = 0
},
Render = {
FontName = "Segoe UI",
@ -2669,6 +2672,7 @@ function loadEvents()
lua_thread.create(
function(id, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, textt)
for k, v in pairs(find_3dText) do
if string.find(text, v) then
if (msk_timestamp - id_3D_text) > 1 then
wait_auto = msk_timestamp
@ -2676,9 +2680,11 @@ function loadEvents()
id_3D_text = id
if text:find("Ïîðò") then
unload_location = true
prices_3dtext[k .. "n"], prices_3dtext[k .. "y"], prices_3dtext[k .. "l"] =
string.match(text, v)
say(prices_3dtext[k .. "n"])
local cargoN, cargoY, cargoL = string.match(text, v)
luChecker.set3Dtext("Ïîðò", {prices_3dtext[k .. "n"], prices_3dtext[k .. "y"], prices_3dtext[k .. "l"]}, {cargoN, cargoY, cargoL})
prices_3dtext[k .. "n"], prices_3dtext[k .. "y"], prices_3dtext[k .. "l"] = cargoN, cargoY, cargoL
prices_3dtext_id[k .. "n"], prices_3dtext_id[k .. "y"], prices_3dtext_id[k .. "l"] = id, id, id
prices_3dtext_pos[k .. "n"], prices_3dtext_pos[k .. "y"], prices_3dtext_pos[k .. "l"] = position, position, position
for k, v in pairs(prices_3dtext) do
if string.find(tostring(prices_3dtext[k]), "99") then
prices_3dtext[k] = tonumber(prices_3dtext[k]) + 1
@ -2723,7 +2729,11 @@ function loadEvents()
attachedVehicleId
)
else
prices_3dtext[k] = string.match(text, v)
local cargo_save = string.match(text, v)
luChecker.set3Dtext("Ñêëàä", {prices_3dtext[k], k}, {cargo_save, k})
prices_3dtext[k] = cargo_save
prices_3dtext_id[k] = id
prices_3dtext_pos[k] = position
load_location = true
current_warehouse = k
end
@ -2748,7 +2758,32 @@ function loadEvents()
unload_location = false
current_warehouse = "none"
end
local result, key = isTruck3dTextDefined(Cid)
if result then
for i = 1, #key do
prices_3dtext_id[key[i]] = -1
prices_3dtext[key[i]] = 0
say("Óäàëåíî "..key[i])
end
end
end
end
function isTruck3dTextDefined(id)
local result = false
local delete = {}
local x, y, z = getCharCoordinates(PLAYER_PED)
for k,v in pairs(prices_3dtext_id) do
local dist = getDistanceBetweenCoords3d(x, y, z, prices_3dtext_pos[k].x, prices_3dtext_pos[k].y, prices_3dtext_pos[k].z)
say(dist)
if id == v and v ~= -1 and dist > 20 then
result = true
say(k)
delete[#delete+1] = k
end
end
return result, delete
end
function say(text)
@ -3959,9 +3994,18 @@ end
luChecker = {
vehicles = {},
truckers = {}, -- Èãðîêè íå â ñêðèïòå
event = {}
}
--[[
ðàçãðóçèë ýâåíò
ñìåíèëñÿ 3ä òåêñò ýâåíò
ðàçãðóçèë ýâåíò
ñìåíèëñÿ 3ä òåêñò ýâåíò
]]
function isPlayerHaveTruckHUD(playerId)
local result = false
for k,v in pairs(base) do
@ -3978,7 +4022,7 @@ function isVehicleTruckersDelete(table, vehicleId)
local playerId = -1
local isTrailer = false
for k,v in pairs(table) do
if v["trailerData"].trailerId == vehicleId then
if v["trailerData"] ~= nil and v["trailerData"].trailerId == vehicleId then
result = true
playerId = k
isTrailer = true
@ -4024,8 +4068,44 @@ function luChecker.vehicleSync(playerId, vehicleId, data)
end
end
function luChecker.trailerSync(playerId, data)
function luChecker.trailerSync(playerId, data_old, data)
if not isPlayerHaveTruckHUD(playerId) and luChecker.truckers[playerId] ~= nil then
luChecker.truckers[playerId]["trailerData"] = data
end
end
function luChecker.set3Dtext(type, data_old, data)
inifiles.Settings.luCheckerCargo = 1
if type == "Ïîðò" then
local key = inifiles.Settings.luCheckerCargo
say(string.format("%s %s", data_old[key], data[key]))
if tonumber(data_old[key]) ~= 0 and not (tonumber(data_old[key]) == tonumber(data[1])) then
if tonumber(data_old[key]) > tonumber(data[key]) then
say("Ðàçãðóçêà â ïîðòó ðÿäîì "..inifiles.Settings.luCheckerCargo)
else
say("â äðóãîì ïîðòó êòî òî ðàçãðóçèëñÿ "..inifiles.Settings.luCheckerCargo)
end
end
elseif type == "Ñêëàä" then
local cargoName = data[2]
local cargoId = (cargoName:find("n") and 1 or (cargoName:find("y") and 2 or (cargoName:find("l") and 3 or 0)))
if cargoId == inifiles.Settings.luCheckerCargo and tonumber(data_old[1]) ~= 0 and not (tonumber(data_old[1]) == tonumber(data[1])) then
if tonumber(data_old[1]) < tonumber(data[1]) then
say("Çàãðóçêà íà ñêëàäå ðÿäîì "..inifiles.Settings.luCheckerCargo)
else
say("íà äðóãîì ñêëàäå êòî òî çàêóïèëñÿ "..inifiles.Settings.luCheckerCargo)
end
end
end
end
--- luCheckerCargo
--[[
settings_save()
inifiles.Settings.luCheckerCargo
]]
Loading…
Cancel
Save