Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2020-12-07, 20:26


xsuperx122







Wiek: 32
Na forum: 3415 dni
Posty: 18



Respekt: 50

Witam, mam dziwnego buga na moim pseudolku. Mianowicie kiedy pierwszy raz kupie samoch?d wyci?gne go z przecho i pojad? nim do tune by zmieni? kolor licznika ?adnie sie zmienia, ale kiedy dam go do przecho i wyjme go tego koloru ju? nie ma, ma?o tego jak ponownie pojade do tune, by ponownie zamontowa? kolor licznika nic sie nie dzieje, jest napisane, ?e zamontowano pomy?lnie, ale koloru nie wida?. Dodam, ?e w tabeli mysql zmienia sie wszystko ?adnie, a konsola nie pokazuj ?adnych b??d?w

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-07, 20:54


_jvneczek







Wiek: 22
Na forum: 4325 dni
Posty: 1513
Nick w MP: _jvneczek

Piwa: 3949

Respekt: 337,5
Respekt: 337,5Respekt: 337,5Respekt: 337,5

Zapewne nie wczytuje tego koloru licznika, zapis mo?e by? - ale brak wczytywania z bazy.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-07, 21:06


TheSebaPL

Mod-team






Wiek: 21
Na forum: 3098 dni
Posty: 964

Piwa: 3102

Respekt: 640,5
Respekt: 640,5Respekt: 640,5

Podaj kod vehicles tak?e licznika.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-08, 10:09


xsuperx122







Wiek: 32
Na forum: 3415 dni
Posty: 18



Respekt: 50

Kod vehicles

Kod:

vehicles=0
root=getRootElement()
resourceRoot=getResourceRootElement(getThisResource())

local handlingi = { --model, acceleration, maxVelocity, steering lock

{494, 14, 350, 55, "awd"},
{502, 21, 350, 55, "awd"},
{503, 18, 385, 55, "awd"},
{458, 17, 380, 55, "awd"},
{579, 17, 380, 55, "awd"},
{560, 20, 380, 55, "awd"},
{502, 20, 380, 55, "awd"},
{475, 20, 380, 55, "awd"},
{502, 21, 380, 55, "awd"},
{546, 21, 380, 55, "awd"},
{402, 10, 180, 55, "awd"},
{516, 20, 200, 55, "awd"},
}

for i, v in ipairs(handlingi) do
setModelHandling(v[1], "engineAcceleration", v[2])
setModelHandling(v[1], "maxVelocity", v[3])
setModelHandling(v[1], "steeringLock", v[4])
setModelHandling(v[1], "driveType", v[5])
if v[4] then
setModelHandling(v[1], "tractionLoss", v[6])
setModelHandling(v[1], "tractionBias", v[7])
setModelHandling(v[1], "mass", v[8])
setModelHandling(v[1], "turnmass", v[9])
end
end

function naprawa()
local veh=getPedOccupiedVehicle(source)
if getElementHealth(veh) < 200 then
setElementHealth(veh, 500)
return end
end

function getVehicleHandlingProperty ( element, property )
if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then
local handlingTable = getVehicleHandling ( element )
local value = handlingTable[property]

if value then
return value
end
end

return false
end

function getAdmin2(plr,level)
if level then
local result=exports["pystories-db"]:dbGet("SELECT * from pystories_admins WHERE serial=? AND level=?", getPlayerSerial(plr), level)
if result and #result > 0 then
return true
else
return false
end
else
local result=exports["pystories-db"]:dbGet("SELECT * from pystories_admins WHERE serial=?", getPlayerSerial(plr))
if result and #result > 0 then
return true
else
return false
end
end
end
--///////////////////////////////////// WCZYTYWANIE POJAZD?“W /////////////////////////////////
function onRespawnVehicles(_,id,poss)
-- Settings (QUERY)
if id then
result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_vehicles WHERE parking=1 AND id=?", id)
query=exports["pystories-db"]:dbSet("UPDATE pystories_vehicles SET parking=0 WHERE id=?", id)
else
result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_vehicles WHERE parking=0")
end

-- Pairs
for ile,vehicle in pairs(result) do
vehicles=ile

if id then pos={poss[1], poss[2], poss[3], poss[4], poss[5], poss[6]}
else pos=split(vehicle["pos"], ",") end

local color=split(vehicle["color"], ",")
local lights=split(vehicle["headlights"], ",")

local veh=createVehicle(vehicle["model"], pos[1], pos[2], pos[3], pos[4], pos[5], pos[6])
setVehicleColor(veh, color[1], color[2], color[3], color[4],color[5], color[6], color[7], color[8],color[9], color[10], color[11], color[12])
setVehicleHeadLightColor(veh, lights[1], lights[2], lights[3])
if vehicle["plateText"] ~= "" then
setVehiclePlateText(veh, vehicle["plateText"])
else
setVehiclePlateText(veh, tostring("SF "..vehicle["id"]))
end
setElementFrozen(veh, (vehicle["frozen"]) > 0)
if vehicle["paintjob"] ~= 3 then
setVehiclePaintjob(veh, vehicle["paintjob"])
end
setElementHealth(veh, vehicle["health"])
setElementData(veh,"vehicle:spawn",true)
setElementData(veh,"vehicle:id", vehicle["id"])
setElementData(veh,"vehicle:fuel", vehicle["fuel"])
setElementData(veh,"vehicle:desc", vehicle["text"] or false)
setElementData(veh,"vehicle:mileage", vehicle["mileage"])
setElementData(veh,"vehicle:driver", vehicle["driver"])
setElementData(veh,"vehicle:licznik", vehicle["licznik"])
setElementData(veh,"vehicle:ownedGroup", vehicle["ownedGroup"])
setElementData(veh,"vehicle:ownedPlayer", vehicle["ownedPlayer"])
setElementData(veh,"vehicle:tempomat", vehicle["ogranicznik"])
setElementData(veh,"vehicle:elektryk", vehicle["elektryk"])
setElementData(veh,"Pojemnosc:silnika", vehicle["silnik"])
local fastpoj = getVehicleHandlingProperty(veh,"maxVelocity")
local fastmax = getVehicleHandlingProperty(veh,"engineAcceleration")
local trakcjaLoss = getVehicleHandlingProperty(veh,"tractionLoss")
local trakcjaBias = getVehicleHandlingProperty(veh,"tractionBias")
local Pojemnosc = getElementData(veh,"Pojemnosc:silnika") or "1.4"

if Pojemnosc == '1.6' then -- pojemnosc silnika 1.6
setVehicleHandling(veh,"engineAcceleration",fastmax+1)
setVehicleHandling(veh,"maxVelocity",fastpoj+10)
setVehicleHandling(veh,"tractionLoss",trakcjaLoss+0.01)
setVehicleHandling(veh,"tractionBias",trakcjaBias+0.01)
elseif Pojemnosc == '1.8' then -- pojemnosc silnika 1.8
setVehicleHandling(veh,"maxVelocity",fastpoj+15)
setVehicleHandling(veh,"engineAcceleration",fastmax+2)
setVehicleHandling(veh,"tractionLoss",trakcjaLoss+0.015)
setVehicleHandling(veh,"tractionBias",trakcjaBias+0.015)
elseif Pojemnosc == '2.0' then -- pojemnosc silnika 2.0
setVehicleHandling(veh,"maxVelocity",fastpoj+20)
setVehicleHandling(veh,"engineAcceleration",fastmax+3)
setVehicleHandling(veh,"tractionLoss",trakcjaLoss+0.02)
setVehicleHandling(veh,"tractionBias",trakcjaBias+0.020)
elseif Pojemnosc == '2.2' then -- pojemnosc silnika 2.2
setVehicleHandling(veh,"maxVelocity",fastpoj+25)
setVehicleHandling(veh,"engineAcceleration",fastmax+4)
setVehicleHandling(veh,"tractionLoss",trakcjaLoss+0.025)
setVehicleHandling(veh,"tractionBias",trakcjaBias+0.025)
end

local mk1 = vehicle['mk1']
local mk1 = vehicle['mk2']
local xfour = vehicle['naped']
local chip = vehicle['chip']
local rh = vehicle['rh']

if (type(vehicle['rent']) == "string") then
local tabelka = {}
local rente = split(vehicle['rent'], ',')
for k,v in ipairs(rente) do
table.insert(tabelka,v)
end
setElementData(veh,"vehicle:rent", tabelka or false)
else
setElementData(veh,"vehicle:rent",0)
end

if tonumber(xfour) ~= 0 then
setElementData(veh, "vehicle:chgDrive", true)
end

if tonumber(rh) ~= 0 then
setElementData(veh, "vehicle:rh", true)
end

if tonumber(chip) ~= 0 then
local fast = getVehicleHandlingProperty(veh,"engineAcceleration")
local maxfast = getVehicleHandlingProperty(veh,"maxVelocity")
local masa = getVehicleHandlingProperty(veh,"mass")
local masa2 = getVehicleHandlingProperty(veh,"turnMass")
setVehicleHandling(veh,"engineAcceleration",fast+2)
setVehicleHandling(veh,"maxVelocity",maxfast+10)
setVehicleHandling(veh,"mass",masa+100)
end

if tonumber(mk1) ~= 0 then
local fast = getVehicleHandlingProperty(veh,"engineAcceleration")
local maxfast = getVehicleHandlingProperty(veh,"maxVelocity")
local masa = getVehicleHandlingProperty(veh,"mass")
local masa2 = getVehicleHandlingProperty(veh,"turnMass")
local xd = getVehicleHandlingProperty(veh,"tractionMultiplier")
local coef = getVehicleHandlingProperty(veh,"dragCoeff")
setVehicleHandling(veh,"engineAcceleration",fast+2)
setVehicleHandling(veh,"maxVelocity",maxfast+10)
setVehicleHandling(veh,"mass",masa+100)
setVehicleHandling(veh,"tractionMultiplier",xd+0.1)
setVehicleHandling(veh,"steeringLock",40)
setVehicleHandling(veh,"dragCoeff",coef-0.15)
end

if tonumber(mk2) ~= 0 then
local fast = getVehicleHandlingProperty(veh,"engineAcceleration")
local maxfast = getVehicleHandlingProperty(veh,"maxVelocity")
local masa = getVehicleHandlingProperty(veh,"mass")
local masa2 = getVehicleHandlingProperty(veh,"turnMass")
local xd = getVehicleHandlingProperty(veh,"tractionMultiplier")
local coef = getVehicleHandlingProperty(veh,"dragCoeff")
setVehicleHandling(veh,"engineAcceleration",fast+3)
setVehicleHandling(veh,"maxVelocity",maxfast+20)
setVehicleHandling(veh,"tractionMultiplier",xd+0.2)
setVehicleHandling(veh,"mass",masa+150)
setVehicleHandling(veh,"steeringLock",42)
setVehicleHandling(veh,"dragCoeff",coef-0.21)
end
local wariant = getElementModel(veh)
if wariant == 410 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 404 then
setVehicleVariant(veh, 1, 1)
end
if wariant == 543 then
setVehicleVariant(veh, 2, 2)
end
if wariant == 436 then
setVehicleVariant(veh, 1, 1)
end
if wariant == 585 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 496 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 526 then
setVehicleVariant(veh, 1, 1)
end
if wariant == 421 then
setVehicleVariant(veh, 1, 1)
end
if wariant == 542 then
setVehicleVariant(veh, 1, 1)
end
if wariant == 561 then
setVehicleVariant(veh, 1, 1)
end
if wariant == 405 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 587 then
setVehicleVariant(veh, 1, 1)
end
if wariant == 533 then
setVehicleVariant(veh, 1, 1)
end
if wariant == 603 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 565 then
setVehicleVariant(veh, 1, 1)
end
if wariant == 402 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 559 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 477 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 560 then
setVehicleVariant(veh, 1, 1)
end
if wariant == 562 then
setVehicleVariant(veh, 2, 2)
end
if wariant == 429 then
setVehicleVariant(veh, 4, 4)
end
if wariant == 480 then
setVehicleVariant(veh, 2, 0)
end
if wariant == 415 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 541 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 411 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 475 then
setVehicleVariant(veh, 1, 1)
end
if wariant == 521 then
setVehicleVariant(veh, 4, 4)
end
if wariant == 522 then
setVehicleVariant(veh, 4, 4)
end
if wariant == 483 then
setVehicleVariant(veh, 1, 1)
end
if wariant == 482 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 500 then
setVehicleVariant(veh, 1, 1)
end
if wariant == 554 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 489 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 579 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 490 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 506 then
setVehicleVariant(veh, 1, 1)
end
if wariant == 502 then
setVehicleVariant(veh, 0, 0)
end
if wariant == 586 then
setVehicleVariant(veh, 2, 2)
end
if vehicle["blokada"] == "true" then
setElementData(veh,"vehicle:block", true)
setVehicleWheelStates(veh, 2, 2, 2, 2)
else
setElementData(veh,"vehicle:block", false)
end

for i,v in ipairs(split(vehicle["tuning"], ",")) do addVehicleUpgrade(veh, v) end
for i,v in ipairs(split(vehicle["panelstates"], ",")) do setVehiclePanelState(veh, i, tonumber(v)) end
end
outputDebugString("[pystories_vehicles] Loaded "..vehicles.." vehicles.")
end


--///////////////////////////////////// ZAPISYWANIE POJAZD?“W /////////////////////////////////
function onSaveVehicle(vehicle)
if getElementData(vehicle,"vehicle:spawn") then
-- Setting
local panelstates={}
local model=getElementModel(vehicle)
local health=getElementHealth(vehicle)
local x,y,z=getElementPosition(vehicle)
local rx,ry,rz=getElementRotation(vehicle)
local desc=getElementData(vehicle,"vehicle:desc") or ""
local id=getElementData(vehicle,"vehicle:id")
local silnik=getElementData(vehicle,"Pojemnosc:silnika") or "1.4"
local fuel=getElementData(vehicle,"vehicle:fuel")
local mileage=getElementData(vehicle,"vehicle:mileage")
local c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12=getVehicleColor(vehicle, true)
local driver=getElementData(vehicle,"vehicle:driver") or ""
local rent=getElementData(vehicle,"vehicle:rent")
local ogranicznik=getElementData(vehicle,"vehicle:tempomat") or "Nie"
local elektryk=getElementData(vehicle,"vehicle:elektryk")
local licznik=getElementData(vehicle,"vehicle:licznik") or 0
local player=getElementData(vehicle,"vehicle:ownedPlayer")
-- local group=getElementData(vehicle,"vehicle:ownedGroup")
local blokada=getElementData(vehicle,"vehicle:block")
local h1,h2,h3=getVehicleHeadLightColor(vehicle)
local paintjob=getVehiclePaintjob(vehicle)
local rear="Brak"
local frozen= isElementFrozen(vehicle) and 1 or 0
for i=0,6 do table.insert(panelstates, getVehiclePanelState(vehicle,i)) end
panelstates=table.concat(panelstates,",")
upgrades=getVehicleUpgrades(vehicle)
if not upgrades then upgrades={} end
upgrades=table.concat(upgrades, ",")
-- Query
local query = exports["pystories-db"]:dbSet(string.format("UPDATE pystories_vehicles SET model='%d', pos='%.2f,%.2f,%.2f,%.2f,%.2f,%.2f', rent='%d',text='%s', health='%d', fuel='%d', mileage='%d', frozen='%d', driver='%s', color='%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d', panelstates='%s', paintjob='%d', tuning='%s', headlights='%d,%d,%d', ownedPlayer='%d', silnik='%s', blokada='%s', licznik='%s' WHERE id=%d",
model, x,y,z, rx,ry,rz, "0",desc, health, fuel, mileage, frozen, driver, c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12, panelstates, paintjob, upgrades, h1,h2,h3, player, silnik, tostring(blokada), licznik, id))
if (type(rent) == "table") then
local rr = string.format("%s", table.concat(rent, ',') )
-- outputDebugString(rr)
local query2= exports['pystories-db']:dbSet("UPDATE pystories_vehicles SET rent=? WHERE id=?",rr,id)
end
end
end

function onParkVehicle(vehicle)
local query=exports["pystories-db"]:dbSet("UPDATE pystories_vehicles SET parking=1 WHERE id=?", getElementData(vehicle,"vehicle:id"))
if query then
destroyElement(vehicle)
end
end

--///////////////////////////////////// SPRAWDZANIE USTAWIEŃ /////////////////////////////////
function getSettings(plr,code,value)
local sid=getElementData(plr,"player:sid")
if not sid then return end
if value == "faction" then
local result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_factions WHERE code=? AND sid=?", code, sid)
if result and #result > 0 then
return result[1].code
else
return false
end
end
if value == "organization" then
local result=exports["pystories-db"]:dbGet("SELECT * FROM ms_organizacje WHERE uid=?", sid)
if result and #result > 0 then
return result[1].code
else
return false
end
end
if value == "owner" then
local result=exports["pystories-db"]:dbGet("SELECT * FROM pystories_users WHERE id=?", sid)
if result and #result > 0 then
return result[1].id
else
return false
end
end
end

--///////////////////////////////////// INNE USTAWIENIA /////////////////////////////////
addEventHandler("onVehicleExit", root, function(plr,seat)
if seat ~= 0 then return end
if getElementData(source, "vehicle:id") then
onSaveVehicle(source)
setVehicleEngineState(source, false)
unbindKey(plr, 'n', 'down', bindHoron4)
end
end)


addEventHandler("onPlayerQuit", root, function()
local veh=getPedOccupiedVehicle(source)
if veh then
if getElementData(veh, "vehicle:id") then
onSaveVehicle(veh)
end
end
end)



addEventHandler("onResourceStop", resourceRoot, function()
for i,v in ipairs(getElementsByType("vehicle")) do
onSaveVehicle(v)
end
end)

addEventHandler("onVehicleEnter", root, function(plr,seat)
if seat ~= 0 then return end
if getElementData(source, "vehicle:id") then
setVehicleEngineState(source, false)
setElementData(source,"vehicle:driver",getPlayerName(plr))
end
end)

--///////////////////////////////////// SPRAWDZENIE WŁAŚCICIELA /////////////////////////////////
addEventHandler("onVehicleStartEnter", resourceRoot, function(plr,seat,jacked)
if seat == 0 then
if getElementData(source, "vehicle:id") then
local rent=getElementData(source, "vehicle:rent")
local group=getElementData(source, "vehicle:ownedGroup")
if group == "0" then group = "Brak" end
local player=getElementData(source, "vehicle:ownedPlayer")
if getAdmin2(plr, 4) then
return
end
if rent and (type(rent) == "table") then
for i,s in pairs(rent) do
if tonumber(s) == getElementData(plr,"player:sid") then
return end
end
end

local plrgroup = getElementData(plr,"player:organization")
if plrgroup then
-- outputDebugString(group)
if getSettings(plr,false,"organization") == group then return end
end
if player and player ~= getSettings(plr,false,"owner") then
outputChatBox("#ff0000✘ #ffffffNie posiadasz kluczyków do tego pojazdu.", plr, 0, 0, 0, true)
cancelEvent()
end
end
end
end)

addEventHandler("onVehicleStartEnter", root, function(plr,seat,jacked)
if jacked then
if getElementData(source,"vehicle:ownedPlayer") == getElementData(plr,"player:sid") then return end
cancelEvent()
end
end)

addEventHandler("onVehicleStartEnter", root, function(plr,seat,jacked)
if seat == 0 then
if getElementData(source,"spawnowany") == true then
if getElementData(plr,"player:admin")== false then
cancelEvent()
end
end
end
end)



addEventHandler("onResourceStart", resourceRoot, function() onRespawnVehicles(_,false) end)


--//////////////////////////////////////////////////////// Licencje

local categoryA={[463] = true,[462] = true,[461] = true,[581] = true,[448] = true,[468] = true,[471] = true,[521] = true,[522] = true,[523] = true}
local categoryB={[602] = true,[545] = true,[496] = true,[517] = true,[401] = true,[410] = true,[518] = true,[600] = true,[527] = true,[436] = true,[589] = true,[580] = true,[419] = true,[439] = true,[533] = true,[549] = true,[526] = true,[491] = true,[474] = true,[445] = true,[467] = true,[604] = true,[426] = true,[507] = true,[547] = true,[585] = true,[405] = true,[587] = true,[409] = true,[466] = true,[550] = true,[492] = true,[566] = true,[546] = true,[540] = true,[551] = true,[421] = true,[516] = true,[529] = true,[488] = true,[460] = true,[510] = true,[509] = true,[481] = true,[586] = true,[472] = true,[473] = true,[493] = true,[595] = true,[484] = true,[430] = true,[453] = true,[452] = true,[446] = true,[454] = true,[485] = true,[552] = true,
[438] = true,[574] = true,[420] = true,[525] = true,[408] = true,[596] = true,[597] = true,[427] = true,[599] = true,[490] = true,[432] = true,[528] = true,[601] = true,[407] = true,[544] = true,[470] = true,[598] = true,[588] = true,
[532] = true,[443] = true,[486] = true,[531] = true,[543] = true,[422] = true,[583] = true,[478] = true,[605] = true,[554] = true,[530] = true,[418] = true,[572] = true,[582] = true,[536] = true,[575] = true,[534] = true,
[567] = true,[535] = true,[576] = true,[412] = true,[402] = true,[542] = true,[603] = true,[475] = true,[449] = true,[537] = true,[570] = true,[441] = true,[464] = true,[501] = true,[465] = true,[564] = true,[568] = true,[557] = true,[424] = true,[504] = true,[495] = true,[457] = true,[539] = true,[483] = true,[571] = true,[500] = true,
[444] = true,[556] = true,[429] = true,[411] = true,[541] = true,[559] = true,[415] = true,[561] = true,[480] = true,[560] = true,[562] = true,[506] = true,[565] = true,[451] = true,[434] = true,[558] = true,[494] = true,[555] = true,[502] = true,[477] = true,[503] = true,[579] = true,[400] = true,[404] = true,[489] = true,[505] = true,[479] = true,[442] = true,[458] = true,
[606] = true,[607] = true,[610] = true,[590] = true,[569] = true,[611] = true,[584] = true,[608] = true,[435] = true,[450] = true,[591] = true,[594] = true}
local categoryC={[403] = true,[406] = true,[413] = true,[414] = true,[416] = true,[423] = true,[428] = true,[431] = true,[433] = true,[437] = true,[440] = true,[455] = true,[456] = true,[459] = true,[482] = true,[498] = true,[499] = true,[508] = true,[514] = true,[515] = true,[524] = true,[538] = true,[573] = true}
local categoryL={[469] = true, [487] = true, [593] = true, [519] = true, [513] = true}
addEventHandler("onVehicleStartEnter", resourceRoot, function(plr,seat,jacked)
if seat == 0 then
if categoryA[getElementModel(source)] then
if exports["pystories-ustawienia-praca"]:getVehicleLicense(plr,"A") then
cancelEvent()
end
elseif categoryB[getElementModel(source)] then
if exports["pystories-ustawienia-praca"]:getVehicleLicense(plr,"B") then
cancelEvent()
end
elseif categoryC[getElementModel(source)] then
if exports["pystories-ustawienia-praca"]:getVehicleLicense(plr,"C") then
cancelEvent()
end
elseif categoryL[getElementModel(source)] then
if exports["pystories-ustawienia-praca"]:getVehicleLicense(plr,"L") then
cancelEvent()
end
end
end
end)

addEventHandler("onVehicleEnter", getRootElement(), function(plr,seat,jacked)
local v = getPedOccupiedVehicle(plr)
if seat ~= 0 then return end
if getElementData(source, "vehicle:id") and getElementData(source, "vehicle:spawn") then
local mk2 = exports['pystories-db']:dbGet("SELECT * FROM pystories_vehicles WHERE id=? AND mk2=?",getElementData(source, "vehicle:id"), "1")
local mk1 = exports['pystories-db']:dbGet("SELECT * FROM pystories_vehicles WHERE id=? AND mk1=?",getElementData(source, "vehicle:id"), "1")
local rh = exports['pystories-db']:dbGet("SELECT * FROM pystories_vehicles WHERE id=? AND rh=?",getElementData(source, "vehicle:id"), "1")
local np = exports['pystories-db']:dbGet("SELECT * FROM pystories_vehicles WHERE id=? AND naped=?",getElementData(source, "vehicle:id"), "1")
local chip = exports['pystories-db']:dbGet("SELECT * FROM pystories_vehicles WHERE id=? AND chip=?",getElementData(source, "vehicle:id"), "1")
if #mk1 > 0 then outputChatBox("#FF8C00>> #ffffffPomy?›lnie zaprogramowano UP1", plr, 0, 144, 255, true) end
if #mk2 > 0 then outputChatBox("#FF8C00>> #ffffffPomy?›lnie zaprogramowano UP2", plr, 0, 144, 255, true) end
if #rh > 0 then outputChatBox("#FF8C00>> #ffffffPomy?›lnie zaprogramowano RH", plr, 0, 144, 255, true) end
if #np > 0 then outputChatBox("#FF8C00>> #ffffffPomy?›lnie zaprogramowano Zmienny Nap?™d", plr, 0, 144, 255, true) end
if #chip > 0 then outputChatBox("#FF8C00>> #ffffffPomy?›lnie zaprogramowano Chip Tuning!", plr, 0, 144, 255, true) end
end
end)

function vTeleport()
for k, veh in pairs(getElementsByType("vehicle")) do
if getElementData(veh, "vehicle:id") then
if isVehicleBlown(veh) then fixVehicle(veh) end
local plr = getVehicleController(veh)
if plr then
local x, y, z = getElementPosition(veh)
if isElementInWater(veh) then
setElementPosition(veh, x, y, -1000)
end
else
if isElementInWater(veh) then
exports["pystories-vehicles"]:onSaveVehicle(veh)
exports["pystories-vehicles"]:onParkVehicle(veh)
end
end
end
end
end

setTimer( function()
vTeleport()
end, 10000, 0)




licznik serwer

Kod:

function getVehicleHandlingProperty ( element, property )
if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then
local handlingTable = getVehicleHandling ( element )
local value = handlingTable[property]

if value then
return value
end
end

return false
end

addEvent("licznikk", true)
addEventHandler("licznikk", getRootElement(), function(plr, jaki, cena)
local cena = tonumber(cena)
local veh = getPedOccupiedVehicle(plr)
local rodzaj = tonumber(jaki)
if not veh then return end
if getElementData(veh, "vehicle:licznik") == rodzaj then
triggerClientEvent(plr, "onClientAddNotification", plr, "Posiadasz juĹĽ ten kolor licznika", "error")
return end
if getPlayerMoney(plr) < cena then triggerClientEvent(plr, "onClientAddNotification", plr, "Nie posiadasz tyle pieni?™dzy", "error") return end
local pay = takePlayerMoney(plr, cena)
if pay then
local data = setElementData(veh, "vehicle:licznik", rodzaj)
triggerClientEvent(plr, "onClientAddNotification", plr, "Zmieniono kolor licznika", "success")
end
end)


licznik client

Kod:

local car = createMarker(-2287.06763, -137.03835, 35.32312-1, "cylinder", 1.5, 0, 64,255,0,0)
createMarker(-2287.06763, -137.03835, 35.32312-4, "cylinder", 4, 0, 64,255,155)
local text=createElement("text")
setElementData(text, "name", "Zmiana pod?›wietlenia licznika")
setElementPosition(text,-2287.06763, -137.03835, 35.32312)
local Player = getLocalPlayer()

addEventHandler("onClientResourceStart", resourceRoot,
function()
local screenW, screenH = guiGetScreenSize()
gui = guiCreateWindow((screenW - 544) / 2, (screenH - 479) / 2, 544, 479, "Zmiana pod?›wietlenia licznika", false)
guiWindowSetSizable(gui, false)
guiSetAlpha(gui, 1.00)

napis = guiCreateLabel(10, 20, 528, 58, "", false, gui)
guiSetFont(napis, "default-bold-small")
guiLabelSetHorizontalAlign(napis, "left", true)

uski1 = guiCreateButton(111, 40, 325, 30, "Bia?‚y\n12,000 PLN", false, gui)
uski2 = guiCreateButton(111, 80, 325, 30, "Czerwony\n12,,000 PLN", false, gui)
uski3 = guiCreateButton(111, 120, 325, 30, "Zielony\n12,000 PLN", false, gui)
uski4 = guiCreateButton(111, 160, 325, 30, "RĂłzowy\n12,000 PLN", false, gui)
uski5 = guiCreateButton(111, 200, 325, 30, "Pomara?„czowy\n12,000 PLN", false, gui)
uski6 = guiCreateButton(111, 240, 325, 30, "?»Ăł?‚ty\n12,000 PLN", false, gui)
uski7 = guiCreateButton(111, 280, 325, 30, "Niebieski\n12,000 PLN", false, gui)
uski8 = guiCreateButton(111, 320, 325, 30, "Aqua\n12,000 PLN", false, gui)

closex = guiCreateButton(111, 422, 325, 47, "Zamknij Okno", false, gui)
guiSetVisible(gui, false)
end
)

function hit(el)
if el == localPlayer then
if getPedOccupiedVehicle(el) then
if getPlayerName(getVehicleController(getPedOccupiedVehicle(el))) == getPlayerName(el) then
guiSetVisible(gui, true)
showCursor(true)
end
end
end
end
addEventHandler("onClientMarkerHit", car, hit)

addEventHandler("onClientGUIClick", resourceRoot,
function()
if source == closex then
guiSetVisible(gui,false)
showCursor(false)
end
if source == uski1 and isElementWithinMarker(Player, car) then
triggerServerEvent ("licznikk", Player, Player, 1, 12000)
elseif source == uski2 and isElementWithinMarker(Player, car) then
triggerServerEvent ("licznikk", Player, Player, 2, 12000)
elseif source == uski3 and isElementWithinMarker(Player, car) then
triggerServerEvent ("licznikk", Player, Player, 3, 12000)
elseif source == uski4 and isElementWithinMarker(Player, car) then
triggerServerEvent ("licznikk", Player, Player, 4, 12000)
elseif source == uski5 and isElementWithinMarker(Player, car) then
triggerServerEvent ("licznikk", Player, Player, 5, 12000)
elseif source == uski6 and isElementWithinMarker(Player, car) then
triggerServerEvent ("licznikk", Player, Player, 6, 12000)
elseif source == uski7 and isElementWithinMarker(Player, car) then
triggerServerEvent ("licznikk", Player, Player, 7, 12000)
elseif source == uski8 and isElementWithinMarker(Player, car) then
triggerServerEvent ("licznikk", Player, Player, 8, 12000)
end

end
)

function filedelet ()
if fileExists("c.lua") then
fileDelete("c.lua")
end
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), filedelet)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-08, 10:52


RudyTMM
[Usunięty]









Jakie? b??dy DB3? by? mo?e jest to przyczyna braku zapisu.

 

 
Wysłany: 2020-12-08, 11:04


TheSebaPL

Mod-team






Wiek: 21
Na forum: 3098 dni
Posty: 964

Piwa: 3102

Respekt: 640,5
Respekt: 640,5Respekt: 640,5

Do??czam si? do pytania jak osoba wy?ej masz w bazie danych zrobione struktur? ?

Tak?e jak ona si? nazywa.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-08, 11:59


_jvneczek







Wiek: 22
Na forum: 4325 dni
Posty: 1513
Nick w MP: _jvneczek

Piwa: 3949

Respekt: 337,5
Respekt: 337,5Respekt: 337,5Respekt: 337,5

"RudyTMM" napisał/a:

Jakie? b??dy DB3? by? mo?e jest to przyczyna braku zapisu.


"TheSebaPL" napisał/a:

Do??czam si? do pytania jak osoba wy?ej masz w bazie danych zrobione struktur? ?

Tak?e jak ona si? nazywa.


Nie brak zapisu czy ?le zrobion? struktur? - bo napisa? ?e w bazie jest okej, powodem jest zapewne wczytywanie,
z tego co widz?, wina mo?e le?e? po stronie licznika, daj kod licznika, da?e? kod montowania licznika a potrzeba kodu licznika.

Kod montowania licznika najwygodniej by?oby zrobi? triggerem do strony servera i w stronie servera odwo?anie do bazy danych, najwygodniej by?o by zrobi? w strukturze = 0 standardowy, 1 kolorowy, 2 kolorowy etc.

Podpis

Support Team: 04.10.2020 - 01.09.2020
Test Moderator: 03.05.2021 - 01.09.2021
Moderator: 01.09.2021 - 23.10.2021

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-08, 12:49


xsuperx122







Wiek: 32
Na forum: 3415 dni
Posty: 18



Respekt: 50

Jasne ju? wszystko podaje, dzi?kuje za takie zainteresowanie

kod licznika

Kod:

img="skala"
lcd = dxCreateFont("zasoby/lcd.ttf", 30)
local dxfont0 = dxCreateFont("zasoby/LCD-font.ttf", 30)
local v = getPedOccupiedVehicle(localPlayer)
local w,h = guiGetScreenSize()
local samoloty = {[509]=true,[481]=true,[510]=true,[460]=true,[476]=true,[511]=true,[512]=true,[513]=true,[519]=true,[520]=true,[553]=true,[577]=true,[592]=true,[593]=true,[417]=true,[425]=true,[447]=true,[469]=true,[488]=true,[487]=true,[497]=true,[548]=true,[563]=true,}
local smothedRotation = 0

sw,sh = guiGetScreenSize()


function hud()
local v = getPedOccupiedVehicle(localPlayer)
if isPlayerMapVisible() then return end
if getElementData(localPlayer,"notshowhud") then
return end
if v then
local sx,sy,sz = getElementVelocity(getPedOccupiedVehicle(localPlayer))
local kmhs = math.ceil(((sx^2+sy^2+sz^2)^(0.5))*120)
local kmhs2 = math.ceil(((sx^2+sy^2+sz^2)^(0.5))*163)
local paliwo = getElementData(v,"vehicle:fuel")
local paliwo1 = getElementData(v,"vehicle:fuel")/100*paliwo or 0
local v = getPedOccupiedVehicle(localPlayer)
local sprawdzprzebieg = tonumber(getElementData(v,"vehicle:mileage")) or 0
local bak = getElementData(v,"vehicle:bak") or 25
local przebieg = math.floor(sprawdzprzebieg) or 0

if getElementData(v, "vehicle:licznik") == 1 then
r, g, b = 255, 255, 255
elseif getElementData(v, "vehicle:licznik") == 2 then
r, g, b = 255, 0, 0
elseif getElementData(v, "vehicle:licznik") == 3 then
r, g, b = 0, 255, 0
elseif getElementData(v, "vehicle:licznik") == 4 then
r, g, b = 255, 0, 212
elseif getElementData(v, "vehicle:licznik") == 5 then
r, g, b = 255, 106, 0
elseif getElementData(v, "vehicle:licznik") == 6 then
r, g, b = 255, 255, 0
elseif getElementData(v, "vehicle:licznik") == 7 then
r, g, b = 0, 149, 255
elseif getElementData(v, "vehicle:licznik") == 8 then
r, g, b = 0, 176, 129
else
r, g, b = 255, 255, 255
end

if #tostring(przebieg) == 1 then przebieg = ""..przebieg
end

local speed = getElementSpeed(getPedOccupiedVehicle(getLocalPlayer()), "kmh")
local speed2 = getElementSpeed(getPedOccupiedVehicle(getLocalPlayer()), "kmh") - 10

local screenW, screenH = guiGetScreenSize()


if kmhs > 220 then
if getElementData(v, "vehicle:licznik") ~= 0 then
if getVehicleOverrideLights(getPedOccupiedVehicle(localPlayer)) ~= 2 then
dxDrawImage(w * 0.7950, h * 0.6850, w * 0.2000, h * 0.2880, "zasoby/licznik.png", 0, 0, 0, tocolor(r4, g4, b4, 255), false)
dxDrawImage(w * 0.8185, h * 0.7000, w * 0.1500, h * 0.3100, "zasoby/wskazowka.png", 220-6, 0, 0, tocolor(255, 255, 255, 255), true)
dxDrawRectangle(w * 0.8859, h * 0.9000, w * 0.1141, h * 0.0361, tocolor(0, 0, 0, 155), false)
dxDrawText(string.format("%d", kmhs2).. " km/h", screenW * 0.8852, screenH * 0.8972, screenW * 1.0000, screenH * 0.9347, tocolor(255, 255, 255, 255), 0.5, dxfont0, "center", "center", false, false, true, false, false)
else
dxDrawImage(w * 0.7730, h * 0.6490, w * 0.2430, h * 0.3580,"zasoby/licznikpodswietlony.png",0,0,0,tocolor(r,g,b,255))
dxDrawImage(w * 0.8185, h * 0.7000, w * 0.1500, h * 0.3100, "zasoby/wskazowkargb.png", 220-6, 0, 0, tocolor(r,g,b, 255), true)
dxDrawImage(w * 0.7950, h * 0.6850, w * 0.2000, h * 0.2880, "zasoby/licznik.png", 0, 0, 0, tocolor(r4, g4, b4, 255), false)
dxDrawImage(w * 0.8185, h * 0.7000, w * 0.1500, h * 0.3100, "zasoby/wskazowka.png", 220-6, 0, 0, tocolor(255, 255, 255, 255), true)
dxDrawRectangle(w * 0.8859, h * 0.9000, w * 0.1141, h * 0.0361, tocolor(0, 0, 0, 155), false)
dxDrawText(string.format("%d", kmhs2).. " km/h", screenW * 0.8852, screenH * 0.8972, screenW * 1.0000, screenH * 0.9347, tocolor(255, 255, 255, 255), 0.5, dxfont0, "center", "center", false, false, true, false, false)
end
else
dxDrawImage(w * 0.7950, h * 0.6850, w * 0.2000, h * 0.2880, "zasoby/licznik.png", 0, 0, 0, tocolor(r4, g4, b4, 255), false)
dxDrawImage(w * 0.8185, h * 0.7000, w * 0.1500, h * 0.3100, "zasoby/wskazowka.png", 220-6, 0, 0, tocolor(255, 255, 255, 255), true)
dxDrawRectangle(w * 0.8859, h * 0.9000, w * 0.1141, h * 0.0361, tocolor(0, 0, 0, 155), false)
dxDrawText(string.format("%d", kmhs2).. " km/h", screenW * 0.8852, screenH * 0.8972, screenW * 1.0000, screenH * 0.9347, tocolor(255, 255, 255, 255), 0.5, dxfont0, "center", "center", false, false, true, false, false)
end
else
if getElementData(v, "vehicle:licznik") ~= 0 then
if getVehicleOverrideLights(getPedOccupiedVehicle(localPlayer)) ~= 2 then
dxDrawImage(w * 0.7950, h * 0.6850, w * 0.2000, h * 0.2880, "zasoby/licznik.png", 0, 0, 0, tocolor(r4, g4, b4, 255), false)
dxDrawImage(w * 0.8185, h * 0.7000, w * 0.1500, h * 0.3100, "zasoby/wskazowka.png", kmhs-6, 0, 0, tocolor(255, 255, 255, 255), true)
dxDrawRectangle(w * 0.8859, h * 0.9000, w * 0.1141, h * 0.0361, tocolor(0, 0, 0, 155), false)
dxDrawText(string.format("%08d", przebieg).. " km", screenW * 0.8852, screenH * 0.8972, screenW * 1.0000, screenH * 0.9347, tocolor(255, 255, 255, 255), 0.5, dxfont0, "center", "center", false, false, true, false, false)
else
dxDrawImage(w * 0.7730, h * 0.6490, w * 0.2430, h * 0.3580,"zasoby/licznikpodswietlony.png",0,0,0,tocolor(r,g,b,255))
dxDrawImage(w * 0.8185, h * 0.7000, w * 0.1500, h * 0.3100, "zasoby/wskazowkargb.png", kmhs-6, 0, 0, tocolor(r,g,b, 255), true)
dxDrawImage(w * 0.7950, h * 0.6850, w * 0.2000, h * 0.2880, "zasoby/licznik.png", 0, 0, 0, tocolor(r4, g4, b4, 255), false)
dxDrawImage(w * 0.8185, h * 0.7000, w * 0.1500, h * 0.3100, "zasoby/wskazowka.png", kmhs-6, 0, 0, tocolor(255, 255, 255, 255), true)
dxDrawRectangle(w * 0.8859, h * 0.9000, w * 0.1141, h * 0.0361, tocolor(0, 0, 0, 155), false)
dxDrawText(string.format("%08d", przebieg).. " km", screenW * 0.8852, screenH * 0.8972, screenW * 1.0000, screenH * 0.9347, tocolor(255, 255, 255, 255), 0.5, dxfont0, "center", "center", false, false, true, false, false)
end
else
dxDrawImage(w * 0.7950, h * 0.6850, w * 0.2000, h * 0.2880, "zasoby/licznik.png", 0, 0, 0, tocolor(r4, g4, b4, 255), false)
dxDrawImage(w * 0.8185, h * 0.7000, w * 0.1500, h * 0.3100, "zasoby/wskazowka.png", kmhs-6, 0, 0, tocolor(255, 255, 255, 255), true)
dxDrawRectangle(w * 0.8859, h * 0.9000, w * 0.1141, h * 0.0361, tocolor(0, 0, 0, 155), false)
dxDrawText(string.format("%08d", przebieg).. " km", screenW * 0.8852, screenH * 0.8972, screenW * 1.0000, screenH * 0.9347, tocolor(255, 255, 255, 255), 0.5, dxfont0, "center", "center", false, false, true, false, false)
end
end

local xd = getElementData(v,"Pojemnosc:silnika") or "1.4"

dxDrawLine((screenW * 0.8555) - 1, (screenH * 0.9486) - 1, (screenW * 0.8555) - 1, screenH * 0.9764, tocolor(0, 0, 0, 255), 1, false)
dxDrawLine(screenW * 0.9852, (screenH * 0.9486) - 1, (screenW * 0.8555) - 1, (screenH * 0.9486) - 1, tocolor(0, 0, 0, 255), 1, false)
dxDrawLine((screenW * 0.8555) - 1, screenH * 0.9764, screenW * 0.9852, screenH * 0.9764, tocolor(0, 0, 0, 255), 1, false)
dxDrawLine(screenW * 0.9852, screenH * 0.9764, screenW * 0.9852, (screenH * 0.9486) - 1, tocolor(0, 0, 0, 255), 1, false)
dxDrawRectangle(screenW * 0.8555, screenH * 0.9486, screenW * 0.1297, screenH * 0.0278, tocolor(0,0,0, 75), false)
dxDrawRectangle(screenW * 0.8555, screenH * 0.9486, screenW * 0.1297 /100*paliwo, screenH * 0.0278, tocolor(42, 254, 19, 255), false)
dxDrawText("Silnik "..xd.." dm3", (screenW * 0.8547) - 1, (screenH * 0.9458) - 1, (screenW * 0.9852) - 1, (screenH * 0.9764) - 1, tocolor(0, 0, 0, 255), 1, "default-bold", "center", "center", false, false, true, false, false)
dxDrawText("Silnik "..xd.." dm3", (screenW * 0.8547) + 1, (screenH * 0.9458) - 1, (screenW * 0.9852) + 1, (screenH * 0.9764) - 1, tocolor(0, 0, 0, 255), 1, "default-bold", "center", "center", false, false, true, false, false)
dxDrawText("Silnik "..xd.." dm3", (screenW * 0.8547) - 1, (screenH * 0.9458) + 1, (screenW * 0.9852) - 1, (screenH * 0.9764) + 1, tocolor(0, 0, 0, 255), 1, "default-bold", "center", "center", false, false, true, false, false)
dxDrawText("Silnik "..xd.." dm3", (screenW * 0.8547) + 1, (screenH * 0.9458) + 1, (screenW * 0.9852) + 1, (screenH * 0.9764) + 1, tocolor(0, 0, 0, 255), 1, "default-bold", "center", "center", false, false, true, false, false)
dxDrawText("Silnik "..xd.." dm3", screenW * 0.8547, screenH * 0.9458, screenW * 0.9852, screenH * 0.9764, tocolor(255, 255, 255, 255), 1, "default-bold", "center", "center", false, false, true, false, false)

dxDrawImage(screenW * 0.9688, screenH * 0.6389, screenW * 0.0234, screenH * 0.0389, ":DMTA-Licznik/zasoby/swiatla.png", 0, 0, 0, tocolor(r6, g6, b6, 255), false)
dxDrawImage(screenW * 0.9688, screenH * 0.6833, screenW * 0.0234, screenH * 0.0319, ":DMTA-Licznik/zasoby/reczny.png", 0, 0, 0, tocolor(r2, g2, b2, 255), false)
dxDrawImage(screenW * 0.9688, screenH * 0.6042, screenW * 0.0234, screenH * 0.0347, ":DMTA-Licznik/zasoby/silnik.png", 0, 0, 0, tocolor(r3, g3, b3, 255), false)



if isElementFrozen(v) then
r2,g2,b2 = 255,0,0
else
r2,g2,b2 = 35,35,35
end

local silnik = getVehicleEngineState(v)
if silnik == false then
r3,g3,b3 = 255,0,0
else
r3,g3,b3 = 35,35,35
end

if getVehicleOverrideLights(v) ~= 2 then
r4,g4,b4 = 255,255,255
r6,g6,b6 = 35,35,35
else
r4,g4,b4 = 255,255,255
r6,g6,b6 = 0,200,0
end

end
end

mojeW,mojeH = 1280,1024
sw,sh = guiGetScreenSize()
ww, hh = (sw/mojeW), (sh/mojeH)

mojeWW,mojeHH = 1920,1080
sww,shh = guiGetScreenSize()
www, hhh = (sww/mojeWW), (shh/mojeHH)
w1, h1 = (sww/mojeWW), (shh/mojeHH)

function round(num)
if num >= 0 then return math.floor(num+.5)
else return math.ceil(num-.5) end
end


function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
if
type( sEventName ) == 'string' and
isElement( pElementAttachedTo ) and
type( func ) == 'function'
then
local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
for i, v in ipairs( aAttachedFunctions ) do
if v == func then
return true
end
end
end
end

return false
end

addEventHandler("onClientVehicleEnter",root,function(plr)
if plr ~= localPlayer then return end
if not isEventHandlerAdded( 'onClientRender', root, hud ) then
addEventHandler("onClientRender",root,hud)
end
end)

addEventHandler("onClientVehicleExit",root,function(plr,seat)
if plr ~= localPlayer then return end
if seat ~= 0 then return end
removeEventHandler("onClientRender",root,hud)
end)


function getElementSpeed(element,unit)
if (unit == nil) then unit = 0 end
if (isElement(element)) then
local x,y,z = getElementVelocity(element)
if (unit=="mph" or unit==1 or unit =='1') then
return math.floor((x^2 + y^2 + z^2) ^ 0.5 * 100)
else
return math.floor((x^2 + y^2 + z^2) ^ 0.5 * 100 * 1.609344)
end
else
return false
end
end


Jak b?dzie potrzeba, dam jeszcze jak wygl?da baza danych, ale tak jak m?wi satan, ?adnego b??du w konsol, nie ma, wi?c pewnie to wina samego licznika.

Pozdrawiam

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-12-08, 13:19


_jvneczek







Wiek: 22
Na forum: 4325 dni
Posty: 1513
Nick w MP: _jvneczek

Piwa: 3949

Respekt: 337,5
Respekt: 337,5Respekt: 337,5Respekt: 337,5

"xsuperx122" napisał/a:

Jasne ju? wszystko podaje, dzi?kuje za takie zainteresowanie

kod licznika

Kod:

img="skala"
lcd = dxCreateFont("zasoby/lcd.ttf", 30)
local dxfont0 = dxCreateFont("zasoby/LCD-font.ttf", 30)
local v = getPedOccupiedVehicle(localPlayer)
local w,h = guiGetScreenSize()
local samoloty = {[509]=true,[481]=true,[510]=true,[460]=true,[476]=true,[511]=true,[512]=true,[513]=true,[519]=true,[520]=true,[553]=true,[577]=true,[592]=true,[593]=true,[417]=true,[425]=true,[447]=true,[469]=true,[488]=true,[487]=true,[497]=true,[548]=true,[563]=true,}
local smothedRotation = 0

sw,sh = guiGetScreenSize()


function hud()
local v = getPedOccupiedVehicle(localPlayer)
if isPlayerMapVisible() then return end
if getElementData(localPlayer,"notshowhud") then
return end
if v then
local sx,sy,sz = getElementVelocity(getPedOccupiedVehicle(localPlayer))
local kmhs = math.ceil(((sx^2+sy^2+sz^2)^(0.5))*120)
local kmhs2 = math.ceil(((sx^2+sy^2+sz^2)^(0.5))*163)
local paliwo = getElementData(v,"vehicle:fuel")
local paliwo1 = getElementData(v,"vehicle:fuel")/100*paliwo or 0
local v = getPedOccupiedVehicle(localPlayer)
local sprawdzprzebieg = tonumber(getElementData(v,"vehicle:mileage")) or 0
local bak = getElementData(v,"vehicle:bak") or 25
local przebieg = math.floor(sprawdzprzebieg) or 0

if getElementData(v, "vehicle:licznik") == 1 then
r, g, b = 255, 255, 255
elseif getElementData(v, "vehicle:licznik") == 2 then
r, g, b = 255, 0, 0
elseif getElementData(v, "vehicle:licznik") == 3 then
r, g, b = 0, 255, 0
elseif getElementData(v, "vehicle:licznik") == 4 then
r, g, b = 255, 0, 212
elseif getElementData(v, "vehicle:licznik") == 5 then
r, g, b = 255, 106, 0
elseif getElementData(v, "vehicle:licznik") == 6 then
r, g, b = 255, 255, 0
elseif getElementData(v, "vehicle:licznik") == 7 then
r, g, b = 0, 149, 255
elseif getElementData(v, "vehicle:licznik") == 8 then
r, g, b = 0, 176, 129
else
r, g, b = 255, 255, 255
end

if #tostring(przebieg) == 1 then przebieg = ""..przebieg
end

local speed = getElementSpeed(getPedOccupiedVehicle(getLocalPlayer()), "kmh")
local speed2 = getElementSpeed(getPedOccupiedVehicle(getLocalPlayer()), "kmh") - 10

local screenW, screenH = guiGetScreenSize()


if kmhs > 220 then
if getElementData(v, "vehicle:licznik") ~= 0 then
if getVehicleOverrideLights(getPedOccupiedVehicle(localPlayer)) ~= 2 then
dxDrawImage(w * 0.7950, h * 0.6850, w * 0.2000, h * 0.2880, "zasoby/licznik.png", 0, 0, 0, tocolor(r4, g4, b4, 255), false)
dxDrawImage(w * 0.8185, h * 0.7000, w * 0.1500, h * 0.3100, "zasoby/wskazowka.png", 220-6, 0, 0, tocolor(255, 255, 255, 255), true)
dxDrawRectangle(w * 0.8859, h * 0.9000, w * 0.1141, h * 0.0361, tocolor(0, 0, 0, 155), false)
dxDrawText(string.format("%d", kmhs2).. " km/h", screenW * 0.8852, screenH * 0.8972, screenW * 1.0000, screenH * 0.9347, tocolor(255, 255, 255, 255), 0.5, dxfont0, "center", "center", false, false, true, false, false)
else
dxDrawImage(w * 0.7730, h * 0.6490, w * 0.2430, h * 0.3580,"zasoby/licznikpodswietlony.png",0,0,0,tocolor(r,g,b,255))
dxDrawImage(w * 0.8185, h * 0.7000, w * 0.1500, h * 0.3100, "zasoby/wskazowkargb.png", 220-6, 0, 0, tocolor(r,g,b, 255), true)
dxDrawImage(w * 0.7950, h * 0.6850, w * 0.2000, h * 0.2880, "zasoby/licznik.png", 0, 0, 0, tocolor(r4, g4, b4, 255), false)
dxDrawImage(w * 0.8185, h * 0.7000, w * 0.1500, h * 0.3100, "zasoby/wskazowka.png", 220-6, 0, 0, tocolor(255, 255, 255, 255), true)
dxDrawRectangle(w * 0.8859, h * 0.9000, w * 0.1141, h * 0.0361, tocolor(0, 0, 0, 155), false)
dxDrawText(string.format("%d", kmhs2).. " km/h", screenW * 0.8852, screenH * 0.8972, screenW * 1.0000, screenH * 0.9347, tocolor(255, 255, 255, 255), 0.5, dxfont0, "center", "center", false, false, true, false, false)
end
else
dxDrawImage(w * 0.7950, h * 0.6850, w * 0.2000, h * 0.2880, "zasoby/licznik.png", 0, 0, 0, tocolor(r4, g4, b4, 255), false)
dxDrawImage(w * 0.8185, h * 0.7000, w * 0.1500, h * 0.3100, "zasoby/wskazowka.png", 220-6, 0, 0, tocolor(255, 255, 255, 255), true)
dxDrawRectangle(w * 0.8859, h * 0.9000, w * 0.1141, h * 0.0361, tocolor(0, 0, 0, 155), false)
dxDrawText(string.format("%d", kmhs2).. " km/h", screenW * 0.8852, screenH * 0.8972, screenW * 1.0000, screenH * 0.9347, tocolor(255, 255, 255, 255), 0.5, dxfont0, "center", "center", false, false, true, false, false)
end
else
if getElementData(v, "vehicle:licznik") ~= 0 then
if getVehicleOverrideLights(getPedOccupiedVehicle(localPlayer)) ~= 2 then
dxDrawImage(w * 0.7950, h * 0.6850, w * 0.2000, h * 0.2880, "zasoby/licznik.png", 0, 0, 0, tocolor(r4, g4, b4, 255), false)
dxDrawImage(w * 0.8185, h * 0.7000, w * 0.1500, h * 0.3100, "zasoby/wskazowka.png", kmhs-6, 0, 0, tocolor(255, 255, 255, 255), true)
dxDrawRectangle(w * 0.8859, h * 0.9000, w * 0.1141, h * 0.0361, tocolor(0, 0, 0, 155), false)
dxDrawText(string.format("%08d", przebieg).. " km", screenW * 0.8852, screenH * 0.8972, screenW * 1.0000, screenH * 0.9347, tocolor(255, 255, 255, 255), 0.5, dxfont0, "center", "center", false, false, true, false, false)
else
dxDrawImage(w * 0.7730, h * 0.6490, w * 0.2430, h * 0.3580,"zasoby/licznikpodswietlony.png",0,0,0,tocolor(r,g,b,255))
dxDrawImage(w * 0.8185, h * 0.7000, w * 0.1500, h * 0.3100, "zasoby/wskazowkargb.png", kmhs-6, 0, 0, tocolor(r,g,b, 255), true)
dxDrawImage(w * 0.7950, h * 0.6850, w * 0.2000, h * 0.2880, "zasoby/licznik.png", 0, 0, 0, tocolor(r4, g4, b4, 255), false)
dxDrawImage(w * 0.8185, h * 0.7000, w * 0.1500, h * 0.3100, "zasoby/wskazowka.png", kmhs-6, 0, 0, tocolor(255, 255, 255, 255), true)
dxDrawRectangle(w * 0.8859, h * 0.9000, w * 0.1141, h * 0.0361, tocolor(0, 0, 0, 155), false)
dxDrawText(string.format("%08d", przebieg).. " km", screenW * 0.8852, screenH * 0.8972, screenW * 1.0000, screenH * 0.9347, tocolor(255, 255, 255, 255), 0.5, dxfont0, "center", "center", false, false, true, false, false)
end
else
dxDrawImage(w * 0.7950, h * 0.6850, w * 0.2000, h * 0.2880, "zasoby/licznik.png", 0, 0, 0, tocolor(r4, g4, b4, 255), false)
dxDrawImage(w * 0.8185, h * 0.7000, w * 0.1500, h * 0.3100, "zasoby/wskazowka.png", kmhs-6, 0, 0, tocolor(255, 255, 255, 255), true)
dxDrawRectangle(w * 0.8859, h * 0.9000, w * 0.1141, h * 0.0361, tocolor(0, 0, 0, 155), false)
dxDrawText(string.format("%08d", przebieg).. " km", screenW * 0.8852, screenH * 0.8972, screenW * 1.0000, screenH * 0.9347, tocolor(255, 255, 255, 255), 0.5, dxfont0, "center", "center", false, false, true, false, false)
end
end

local xd = getElementData(v,"Pojemnosc:silnika") or "1.4"

dxDrawLine((screenW * 0.8555) - 1, (screenH * 0.9486) - 1, (screenW * 0.8555) - 1, screenH * 0.9764, tocolor(0, 0, 0, 255), 1, false)
dxDrawLine(screenW * 0.9852, (screenH * 0.9486) - 1, (screenW * 0.8555) - 1, (screenH * 0.9486) - 1, tocolor(0, 0, 0, 255), 1, false)
dxDrawLine((screenW * 0.8555) - 1, screenH * 0.9764, screenW * 0.9852, screenH * 0.9764, tocolor(0, 0, 0, 255), 1, false)
dxDrawLine(screenW * 0.9852, screenH * 0.9764, screenW * 0.9852, (screenH * 0.9486) - 1, tocolor(0, 0, 0, 255), 1, false)
dxDrawRectangle(screenW * 0.8555, screenH * 0.9486, screenW * 0.1297, screenH * 0.0278, tocolor(0,0,0, 75), false)
dxDrawRectangle(screenW * 0.8555, screenH * 0.9486, screenW * 0.1297 /100*paliwo, screenH * 0.0278, tocolor(42, 254, 19, 255), false)
dxDrawText("Silnik "..xd.." dm3", (screenW * 0.8547) - 1, (screenH * 0.9458) - 1, (screenW * 0.9852) - 1, (screenH * 0.9764) - 1, tocolor(0, 0, 0, 255), 1, "default-bold", "center", "center", false, false, true, false, false)
dxDrawText("Silnik "..xd.." dm3", (screenW * 0.8547) + 1, (screenH * 0.9458) - 1, (screenW * 0.9852) + 1, (screenH * 0.9764) - 1, tocolor(0, 0, 0, 255), 1, "default-bold", "center", "center", false, false, true, false, false)
dxDrawText("Silnik "..xd.." dm3", (screenW * 0.8547) - 1, (screenH * 0.9458) + 1, (screenW * 0.9852) - 1, (screenH * 0.9764) + 1, tocolor(0, 0, 0, 255), 1, "default-bold", "center", "center", false, false, true, false, false)
dxDrawText("Silnik "..xd.." dm3", (screenW * 0.8547) + 1, (screenH * 0.9458) + 1, (screenW * 0.9852) + 1, (screenH * 0.9764) + 1, tocolor(0, 0, 0, 255), 1, "default-bold", "center", "center", false, false, true, false, false)
dxDrawText("Silnik "..xd.." dm3", screenW * 0.8547, screenH * 0.9458, screenW * 0.9852, screenH * 0.9764, tocolor(255, 255, 255, 255), 1, "default-bold", "center", "center", false, false, true, false, false)

dxDrawImage(screenW * 0.9688, screenH * 0.6389, screenW * 0.0234, screenH * 0.0389, ":DMTA-Licznik/zasoby/swiatla.png", 0, 0, 0, tocolor(r6, g6, b6, 255), false)
dxDrawImage(screenW * 0.9688, screenH * 0.6833, screenW * 0.0234, screenH * 0.0319, ":DMTA-Licznik/zasoby/reczny.png", 0, 0, 0, tocolor(r2, g2, b2, 255), false)
dxDrawImage(screenW * 0.9688, screenH * 0.6042, screenW * 0.0234, screenH * 0.0347, ":DMTA-Licznik/zasoby/silnik.png", 0, 0, 0, tocolor(r3, g3, b3, 255), false)



if isElementFrozen(v) then
r2,g2,b2 = 255,0,0
else
r2,g2,b2 = 35,35,35
end

local silnik = getVehicleEngineState(v)
if silnik == false then
r3,g3,b3 = 255,0,0
else
r3,g3,b3 = 35,35,35
end

if getVehicleOverrideLights(v) ~= 2 then
r4,g4,b4 = 255,255,255
r6,g6,b6 = 35,35,35
else
r4,g4,b4 = 255,255,255
r6,g6,b6 = 0,200,0
end

end
end

mojeW,mojeH = 1280,1024
sw,sh = guiGetScreenSize()
ww, hh = (sw/mojeW), (sh/mojeH)

mojeWW,mojeHH = 1920,1080
sww,shh = guiGetScreenSize()
www, hhh = (sww/mojeWW), (shh/mojeHH)
w1, h1 = (sww/mojeWW), (shh/mojeHH)

function round(num)
if num >= 0 then return math.floor(num+.5)
else return math.ceil(num-.5) end
end


function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
if
type( sEventName ) == 'string' and
isElement( pElementAttachedTo ) and
type( func ) == 'function'
then
local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
for i, v in ipairs( aAttachedFunctions ) do
if v == func then
return true
end
end
end
end

return false
end

addEventHandler("onClientVehicleEnter",root,function(plr)
if plr ~= localPlayer then return end
if not isEventHandlerAdded( 'onClientRender', root, hud ) then
addEventHandler("onClientRender",root,hud)
end
end)

addEventHandler("onClientVehicleExit",root,function(plr,seat)
if plr ~= localPlayer then return end
if seat ~= 0 then return end
removeEventHandler("onClientRender",root,hud)
end)


function getElementSpeed(element,unit)
if (unit == nil) then unit = 0 end
if (isElement(element)) then
local x,y,z = getElementVelocity(element)
if (unit=="mph" or unit==1 or unit =='1') then
return math.floor((x^2 + y^2 + z^2) ^ 0.5 * 100)
else
return math.floor((x^2 + y^2 + z^2) ^ 0.5 * 100 * 1.609344)
end
else
return false
end
end


Jak b?dzie potrzeba, dam jeszcze jak wygl?da baza danych, ale tak jak m?wi satan, ?adnego b??du w konsol, nie ma, wi?c pewnie to wina samego licznika.

Pozdrawiam


My?l? ?e zamiast r, g, b, mo?na by?o by zrobi? zapis w bazie koloru licznika, my?la?em ?e chcesz r??ne liczniki, ale skoro kolory to zapis r,g,b do bazy wystarczy.

Przy monta?u licznika zr?b ustawianie setElementDaty np setElementData(plr, 'vehicle:speedo:color', color={255, 255, 255})
a w liczniku po prostu wyczytywanie elementdaty na r, g,b
ify 'if typ licznika etc' wystarczy usun?? i podpi?? pod r,g,b dx'a i zapis w bazie.

Podpis

Support Team: 04.10.2020 - 01.09.2020
Test Moderator: 03.05.2021 - 01.09.2021
Moderator: 01.09.2021 - 23.10.2021

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
xsuperx122
Wysłany: 2020-12-08, 13:58


xsuperx122







Wiek: 32
Na forum: 3415 dni
Posty: 18



Respekt: 50

Dzi?ki, teraz nie mam czasu, si? w to bawi? ale jak tylko chwile b?d? mie? to zastosuje twoje wskaz?wki.

Leci piwko

Postaw piwo autorowi tego posta
 

 
Tagi: bug :: kolorowym :: licznikiem
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Bug z kolorowym licznikiem Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku