add checker 3d text on changed price

test-utf-8
rubin 2 years ago
parent b2fe6cf38b
commit 0e32990d75
  1. 98
      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 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_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_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 } 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, stats_text = defaultMon,
renderTruck = true, renderTruck = true,
AutoClear = true, AutoClear = true,
NewPairMSG = true NewPairMSG = true,
luCheckerCargo = 0
}, },
Render = { Render = {
FontName = "Segoe UI", FontName = "Segoe UI",
@ -2669,6 +2672,7 @@ function loadEvents()
lua_thread.create( lua_thread.create(
function(id, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, textt) function(id, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, textt)
for k, v in pairs(find_3dText) do for k, v in pairs(find_3dText) do
if string.find(text, v) then if string.find(text, v) then
if (msk_timestamp - id_3D_text) > 1 then if (msk_timestamp - id_3D_text) > 1 then
wait_auto = msk_timestamp wait_auto = msk_timestamp
@ -2676,9 +2680,11 @@ function loadEvents()
id_3D_text = id id_3D_text = id
if text:find("Ïîðò") then if text:find("Ïîðò") then
unload_location = true unload_location = true
prices_3dtext[k .. "n"], prices_3dtext[k .. "y"], prices_3dtext[k .. "l"] = local cargoN, cargoY, cargoL = string.match(text, v)
string.match(text, v) luChecker.set3Dtext("Ïîðò", {prices_3dtext[k .. "n"], prices_3dtext[k .. "y"], prices_3dtext[k .. "l"]}, {cargoN, cargoY, cargoL})
say(prices_3dtext[k .. "n"]) 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 for k, v in pairs(prices_3dtext) do
if string.find(tostring(prices_3dtext[k]), "99") then if string.find(tostring(prices_3dtext[k]), "99") then
prices_3dtext[k] = tonumber(prices_3dtext[k]) + 1 prices_3dtext[k] = tonumber(prices_3dtext[k]) + 1
@ -2723,7 +2729,11 @@ function loadEvents()
attachedVehicleId attachedVehicleId
) )
else 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 load_location = true
current_warehouse = k current_warehouse = k
end end
@ -2748,9 +2758,34 @@ function loadEvents()
unload_location = false unload_location = false
current_warehouse = "none" current_warehouse = "none"
end 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
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) function say(text)
sampAddChatMessage(tostring(text),-1) sampAddChatMessage(tostring(text),-1)
end end
@ -3959,9 +3994,18 @@ end
luChecker = { luChecker = {
vehicles = {}, vehicles = {},
truckers = {}, -- Èãðîêè íå â ñêðèïòå truckers = {}, -- Èãðîêè íå â ñêðèïòå
event = {}
} }
--[[
ðàçãðóçèë ýâåíò
ñìåíèëñÿ 3ä òåêñò ýâåíò
ðàçãðóçèë ýâåíò
ñìåíèëñÿ 3ä òåêñò ýâåíò
]]
function isPlayerHaveTruckHUD(playerId) function isPlayerHaveTruckHUD(playerId)
local result = false local result = false
for k,v in pairs(base) do for k,v in pairs(base) do
@ -3978,7 +4022,7 @@ function isVehicleTruckersDelete(table, vehicleId)
local playerId = -1 local playerId = -1
local isTrailer = false local isTrailer = false
for k,v in pairs(table) do 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 result = true
playerId = k playerId = k
isTrailer = true isTrailer = true
@ -4024,8 +4068,44 @@ function luChecker.vehicleSync(playerId, vehicleId, data)
end end
end end
function luChecker.trailerSync(playerId, data) function luChecker.trailerSync(playerId, data_old, data)
if not isPlayerHaveTruckHUD(playerId) and luChecker.truckers[playerId] ~= nil then if not isPlayerHaveTruckHUD(playerId) and luChecker.truckers[playerId] ~= nil then
luChecker.truckers[playerId]["trailerData"] = data luChecker.truckers[playerId]["trailerData"] = data
end end
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