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

Wysłany: 2018-10-30, 16:16


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Witam ot?? pom?g?by kto? z zapisywaniem paliwa, przebiegu oraz tunningu vizualnego ? Bardzo bym prosi? i? nie mog? zbytnio tego ogarn?? kod:

c.lua

local showed false
local actualVeh 1
local target nil
local data = {}


function isRendering()
    if target then
        dxSetRenderTarget(targettrue)
        dxDrawRectangle(00640480tocolor(000225))
        dxDrawRectangle(046064020tocolor(36175178255))
        dxDrawText("Informacje dt. pojazdu:\n"..getVehicleNameFromModel(data[actualVeh][2]).." (ID: "..data[actualVeh][1]..")\nZarejestrowany: "..data[actualVeh][5].."\n\nPojemno??: "..data[actualVeh][6].." dm3\nPrzebieg: "..string.format("%.02f"data[actualVeh][3]).."km\nStan paliwa: "..data[actualVeh][4].."l"00640480tocolor(255255255255), 3"default-bold""center""center")
        dxSetRenderTarget()
        
        dxDrawMaterialLine3D(1353.08 0.08, -1644.6415 0.71353.08 0.08, -1644.6415 0.7target2.4tocolor(255255255255), 1353.08, -1644.6415)
    end
end

addEvent("onParkingGetVehicles"true)
addEventHandler("onParkingGetVehicles"root, function(result)
    if result then
        for i,v in pairs(result) do
            table.insert(data, {v.idv.modelv.mileagev.fuel, (v.registered == "true" and "TAK" or "NIE"), v.capacity})
        end
    
        Timer(function()
            showed true
            showChat(false)
            localPlayer.frozen true
            target DxRenderTarget(640480true)
            localPlayer:setData("player:hud_visible"true)
            addEventHandler("onClientRender"rootisRendering)
            triggerServerEvent("parkingPojazd"localPlayerdata[actualVeh][1])
            triggerEvent("onClientAddNotification"localPlayer"Aby wybra? pojazd - manewruj strza?kami, aby wybra? pojazd kliknij enter lub powr?? do gry przyciskiem backspace.""info")
            Camera.setMatrix(1358.0087890625, -1646.956787109414.3198003768921357.2611083984, -1646.343505859414.064926147461092)
            setPlayerHudComponentVisible("radar"false)
        end2001)
    end
end)

bindKey("arrow_l""both", function(keystate)
    if state ~= "down" or showed ~= true then return false end
    if actualVeh == #data then actualVeh = 1 else actualVeh = actualVeh + 1 end
    triggerServerEvent("parkingPojazd"localPlayerdata[actualVeh][1])
end)

bindKey("arrow_r""both", function(keystate)
    if state ~= "down" or showed ~= true then return false end
    if actualVeh == 1 then actualVeh #data else actualVeh = actualVeh - 1 end
    triggerServerEvent("parkingPojazd"localPlayerdata[actualVeh][1])
end)

bindKey("backspace""down", function(keystate)
    if showed then
        showChat(true)
        showed false
        localPlayer.frozen false
        setCameraTarget(localPlayerlocalPlayer)
        removeEventHandler("onClientRender"rootisRendering)
        triggerServerEvent("usunPojazd:parking"localPlayer)
        localPlayer:setData("player:hud_visible"false)
        setPlayerHudComponentVisible("radar"true)
        target:destroy()
        target nil
        data = {}
    end
end)

bindKey("enter""down", function()
    if showed then
        if data[actualVeh][5] == "TAK" then
            showChat(true)
            showed false
            localPlayer.frozen false
            setCameraTarget(localPlayerlocalPlayer)
            removeEventHandler("onClientRender"rootisRendering)
            triggerServerEvent("usunPojazd:parking"localPlayer)
            triggerServerEvent("odbierzPojazd"localPlayerlocalPlayerdata[actualVeh][1])
            localPlayer:setData("player:hud_visible"false)
            setPlayerHudComponentVisible("radar"true)
            target:destroy()
            target nil
            data = {}
        else
            triggerEvent("onClientAddNotification"localPlayer"Ten pojazd nie jest zarejestrowany!""error")
        end
    end
end)


s.lua
local pojazd = {}
local odbieranie Marker(1536.122019.5810.82-0.9"cylinder"1.125580040)
local pozostawienie Marker(1534.612037.2910.82-1"cylinder"43617517840)
local cuboid ColShape.Cuboid(1534.75,2003.61,10.55,0.0,360.0,357.96)
local cuboid_two ColShape.Cuboid(1540.75,2003.61,10.55,0.0,360.0,357.96)
local cuboid_three ColShape.Cuboid(1548.75,2003.61,10.55,0.0,360.0,357.96)

local prowadnice = {
    [1] = {1356.8100585938, -1658.939941406314.03},
    [2] = {1356.8299560547, -1651.104003906314.03},
    [3] = {1356.8399658203, -1643.37514.03},
    [4] = {1356.849609375, -1635.570312514.03}
}

for i,v in ipairs(prowadnice) do
    local object Object(2061Vector3(v[1], v[2], v[3]), Vector3(9000))
end

local object4 Object(78911358.1904296875, -1635.570312514.0390090)

local text Element("text")
text:setData("name""Przechowywalnia\nOdbi?r pojazd?w")
text.position Vector3(1536.122019.5810.82+0.2)
createBlipAttachedTo(text35)

local text2 Element("text")
text2:setData("name""Przechowywalnia\nPozostawianie pojazd?w")
text2.position Vector3(1534.612037.2910.82+0.2)

addEventHandler("onMarkerHit"odbieranie, function(playerdimension)
    if player.type ~= "player" or player.inVehicle then return false end
    local result exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_vehicles WHERE (ownedPlayer=? OR ownedGroup=?) AND parking=1"player:getData("player:uid"), player:getData("player:organization:id") or "brak")
    if #result > 0 then triggerClientEvent(player, "onParkingGetVehicles", root, result) else triggerClientEvent(player, "onClientAddNotification", player, "Nie posiadasz ?adnego pojazdu prywatnego dost?pnego w przechowalni!", "error") end
end)

addEventHandler("onMarkerHit"pozostawienie, function(hitElementmd)
    if isElement(hitElement) and getElementType(hitElement) == "player" and getPedOccupiedVehicle(hitElementthen
        local id getPedOccupiedVehicle(hitElement):getData("vehicle:id")
        if not id then return false end
        exports["ogrpg-vehicles"]:onSaveVehicle(getPedOccupiedVehicle(hitElement))
        exports["ogrpg-db"]:dbSet("UPDATE ogrpg_vehicles SET parking=1, tp_to_parking=? WHERE id=?""Schowany przez kierowc? ("..hitElement.name..")."id)
        setTimer(destroyElement501getPedOccupiedVehicle(hitElement))
    end
end)

local function store()
    local cuboid getElementsWithinColShape(cuboid"vehicle")
    if #cuboid > 0 and not cuboid[1].controller then
        exports["ogrpg-vehicles"]:onSaveVehicle(cuboid[1])
        exports["ogrpg-db"]:dbSet("UPDATE ogrpg_vehicles SET parking=1 WHERE id=?"cuboid[1]:getData("vehicle:id"))
        cuboid[1]:destroy()
    end
end

local function store2()
    local cuboid getElementsWithinColShape(cuboid_two"vehicle")
    if #cuboid > 0 and not cuboid[1].controller then
        exports["ogrpg-vehicles"]:onSaveVehicle(cuboid[1])
        exports["ogrpg-db"]:dbSet("UPDATE ogrpg_vehicles SET parking=1 WHERE id=?"cuboid[1]:getData("vehicle:id"))
        cuboid[1]:destroy()
    end
end

local function store3()
    local cuboid getElementsWithinColShape(cuboid_three"vehicle")
    if #cuboid > 0 and not cuboid[1].controller then
        exports["ogrpg-vehicles"]:onSaveVehicle(cuboid[1])
        exports["ogrpg-db"]:dbSet("UPDATE ogrpg_vehicles SET parking=1 WHERE id=?"cuboid[1]:getData("vehicle:id"))
        cuboid[1]:destroy()
    end
end

addEvent("odbierzPojazd"true)
addEventHandler("odbierzPojazd"root, function(playerid)
    --if #getElementsWithinColShape(cuboid, "vehicle") > 0 and #getElementsWithinColShape(cuboid_two, "vehicle") == 0 then
    --    exports["ogrpg-vehicles"]:onRespawnVehicles(_id, {-1959.90390.2135.76000}, playertrue)
    --    Timer(store50001)
    --elseif #getElementsWithinColShape(cuboid_two, "vehicle") > 0 and #getElementsWithinColShape(cuboid, "vehicle") == 0 then
    --    exports["ogrpg-vehicles"]:onRespawnVehicles(_id, {-1959.90390.2135.76000}, playertrue)
    --    Timer(store250001)
    if #getElementsWithinColShape(cuboid, "vehicle") == 0 then
        exports["ogrpg-vehicles"]:onRespawnVehicles(_id, {1534.75,2003.61,10.55,0.0,360.0,357.9}, playertrue)
        Timer(store50001)
        return 
    end
    if #getElementsWithinColShape(cuboid_two, "vehicle") == 0 then
        exports["ogrpg-vehicles"]:onRespawnVehicles(_id, {1534.40,2011.40,10.55,0.0,360.0,356.3}, playertrue)
        Timer(store250001)
        return 
    end
    if #getElementsWithinColShape(cuboid_three, "vehicle") == 0 then
        exports["ogrpg-vehicles"]:onRespawnVehicles(_id, {1534.53,2027.06,10.55,0.0,0.0,177.0}, playertrue)
        Timer(store350001)
        return 
    end
    if #getElementsWithinColShape(cuboid, "vehicle") > 0 and #getElementsWithinColShape(cuboid_two, "vehicle") > 0 and #getElementsWithinColShape(cuboid_three, "vehicle") > 0 then
        return triggerClientEvent(player"onClientAddNotification"player"Brak miejsca do przywr?cenia pojazdu!""error")
    end
end)

addEvent("usunPojazd:parking"true)
addEventHandler("usunPojazd:parking"root, function()
    setElementDimension(source0)
    if pojazd[source.name] and isElement(source.namethen
        pojazd[source.name]:destroy()
        pojazd[source.name] = false
    end
end)

addEvent("parkingPojazd"true)
addEventHandler("parkingPojazd"root, function(id)
    local result exports["ogrpg-db"]:dbGet("SELECT * FROM ogrpg_vehicles WHERE id=?"id)
    if result and #result > 0 then
        if pojazd[getPlayerName(source)] and isElement(pojazd[getPlayerName(source)]) then
            destroyElement(pojazd[getPlayerName(source)])
            pojazd[getPlayerName(source)] = false
        end
        
        local color split(result[1].color",")
        local tuning split(result[1].tuning",")
        pojazd[getPlayerName(source)] = Vehicle(result[1].model1354.01, -1643.9313.500270)
        pojazd[getPlayerName(source)].alpha 255
        
        setElementFrozen(pojazd[getPlayerName(source)], true)
        setVehicleColor(pojazd[getPlayerName(source)], color[1], color[2], color[3], color[4], color[5], color[6])
        for i=1,#tuning do addVehicleUpgrade(pojazd[getPlayerName(source)], tuning[i]) end
        setElementDimension(pojazd[getPlayerName(source)], getElementData(source"player:uid"))
        setElementDimension(sourcegetElementData(source"player:uid"))
    end
end)

addEventHandler("onPlayerQuit"root, function()
    if pojazd[source.name] and isElement(pojazd[source.name]) then
        pojazd[source.name]:destroy()
    end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-10-30, 16:24


Avenged

Młodszy Szkrypter






Wiek: 23
Na forum: 3510 dni
Posty: 654
Nick w MP: Avenged

Piwa: 1570

Respekt: 326,3
Respekt: 326,3Respekt: 326,3Respekt: 326,3

Paliwo oraz przebieg to funkcja zapewne

Więcej informacji znajdziesz w Wikipedii MTA:

getElementData


, a pobranie tuningu to

Więcej informacji znajdziesz w Wikipedii MTA:

getVehicleUpgrades


i po?niej to co pobierzesz z pojazdu update'ujesz do bazy danych

Podpis
LUA, JS, PHP



Zapraszam do skorzystania z moich usług: Klik

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-10-30, 17:02


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Dzi?kuje ! Mo?na zamnkn?? temat

Podpis
amta
Postaw piwo autorowi tego posta
 

 
Tagi: zapisywanie :: przecho
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Zapisywanie przecho 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