Sziasztok! Az lenne a kérdésem, hogy adott egy sziréna panel, ahol modellek alapján van megadva a Draw. Meg szeretném oldani, hogy bizonyos járműveknél, ID alapján is megjelenítse a panelt. Ezt hogy lehetne megoldani? A jelenlegi megoldásom nem működik, mutatom a mostanit.
function drawPanel()
local vehicle = getPedOccupiedVehicle(localPlayer)
if SirenPanel then
if isPedInVehicle(localPlayer) then
local model = getElementModel(vehicle)
local fin = findVehicle(id)
if (model==598) or (model==597) or (model==596) or (model==599) or (model==490) or (model==604) or (model==479) or (model==490) or (model==523) or (model==528) or (model==601) or (model==427) or (model==416) or (model==419) or (model==407) or (model==544) or (fin==268) or (fin==265) or (fin==269) then
if isCursorShowing() then
cursorX, cursorY = getCursorPosition()
cursorX, cursorY = cursorX * scSz[1], cursorY * scSz[2]
Ez egy részlet! A findVehicle funkció:
function findVehicle(id)
for k,v in ipairs(getElementsByType(\"vehicle\")) do
local vid = tonumber(getElementData(v, \"veh:id\")) or -1
if vid == tonumber(id) then
return v
end
end
return nil
end
function findVehicle(id)
for k,v in ipairs(getElementsByType(\"vehicle\")) do
local vid = tonumber(getElementData(v, \"veh:id\")) or -1
if vid == tonumber(id) then
return true
end
end
return false
end
Én átírnám így a findVehicle-t ésa drawot pedig így:
function drawPanel()
local vehicle = getPedOccupiedVehicle(localPlayer)
if SirenPanel then
if isPedInVehicle(localPlayer) then
local model = getElementModel(vehicle)
local fin = findVehicle(id)
if (model==598) or (többi modell, csak lerövidítettem, hogy ne legyen hosszú) or (findVehicle(993123)) then
if isCursorShowing() then
cursorX, cursorY = getCursorPosition()
cursorX, cursorY = cursorX * scSz[1], cursorY * scSz[2]
a \"local fin = findVehicle(id)\" felesleges oda
findVehicle(A kocsi ID-je) -- Ez 2 értéket adhat vissza. Ha megtalálja az adatbázisba , akkor \"true\" és megjeleníti neki a panel, az egyik pedig a \"false\" akkor nem fogja megjeleníteni neki a panelt.