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

Wysłany: 2023-09-18, 16:51


K4M7K







Wiek: 34
Na forum: 1326 dni
Posty: 9
Nick w MP: 7EVEN

Piwa: 6

Respekt: 50

Witam potrzebowal bym pomocy odnosnie dodania tego licznika do bazy danych jestem zielony autor skryptu dokladnie tego https://gtao.pl/skrypt-megarpg-licznik-100-tak-vt142539.htm?view=next napisac ze "Licznik posiada mo?liwo?? zamontowania motyw?w (W tym RGB) - w tym celu wystarczy dostosowa? elementdate pod siebie." lecz nie wiem jak to zrobic jak dodac to do bazy danych jesli chodzi o pojazdy mam pystories-verihles i mam prosbe czy mogl by ktos napisac dokladnie jak to dodac? oto kod
sx, sy = guiGetScreenSize()
local zoom = 1 
if sx < 2048 then
    zoom = math.min(2.2, 2048/sx)
end 
font1 = dxCreateFont("fonts/bold.ttf", 15/zoom)
font2 = dxCreateFont("fonts/normal.ttf", 14/zoom)
font3 = dxCreateFont("fonts/bold.ttf", 35/zoom)
motywy = {}

function createThemes()
    local number = #motywy + 1
    motywy[number] = dxCreateTexture('motywy/'..number..'.png')
end
setTimer(createThemes, 50, 32)

function drawSpeedo()
    local veh = getPedOccupiedVehicle(localPlayer)
    if veh then
        local speex, speey, speez = getElementVelocity(veh)
        local speedVehicle = (speex ^ 2 + speey ^ 2 + speez ^ 2) ^ (0.5)
        local vmax = speedVehicle * 200
        local r, g, b = getVehicleHeadLightColor(veh)
        local bieg = getVehicleCurrentGear(veh)
        local fuel = getElementData(veh, "vehicle:fuel") or 0
        local fuel = string.format("%.1f", fuel)

        if getElementData(veh, "vehicle:upgrades") and getElementData(veh, "vehicle:upgrades")['motyw'] then
            dxDrawImage(sx - 440/zoom, sy - 420/zoom, 400/zoom, 400/zoom, (motywy[tonumber(getElementData(veh, "vehicle:upgrades")['motyw'])] or "images/disk.png"), 0, 0, 0, tocolor(255,255,255, 255), false)
        else
            dxDrawImage(sx - 440/zoom, sy - 420/zoom, 400/zoom, 400/zoom, "images/disk.png", 0, 0, 0, tocolor(255,255,255, 255), false)
        end

        if getElementData(veh, "vehicle:upgrades") and getElementData(veh, "vehicle:upgrades")['licznikrgb'] then
            dxDrawImage(sx - 440/zoom, sy - 420/zoom, 400/zoom, 400/zoom, "images/rgb.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        else
            dxDrawImage(sx - 440/zoom, sy - 420/zoom, 400/zoom, 400/zoom, "images/overlay.png", 0, 0, 0, tocolor(r, g, b, 255), false)
        end
        
        dxDrawImage(sx - 440/zoom, sy - 420/zoom, 400/zoom, 400/zoom, "images/needle.png", getVehicleRPM(veh)/40, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawText(bieg == 0 and "R" or bieg, sx - 239/zoom, sy - 220/zoom, nil, nil, tocolor(255, 255, 255, 255), 1, font1, "center", "center", false, false, false, false, false)

        local mileage = string.format("%09d", math.floor(getElementData(veh, "vehicle:mileage") or 0))
        drawShadowText(mileage, sx - 40/zoom, sy - 170/zoom, nil, nil, tocolor(255, 255, 255, 255), 1, font2, "right", "center", false, false, false, false, false)

        local nitro = getVehicleUpgradeOnSlot(veh, 8)
        if nitro then
            local nitroProgress = getVehicleNitroLevel(veh)

            if nitroProgress then
                dxDrawImage(sx - 37/zoom, sy - 245/zoom, 28/zoom, 44/zoom, "images/nitro.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
                dxDrawImage(sx - 100/zoom, sy - 388/zoom, 94/zoom, 144/zoom, "images/nitro_background.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
                dxDrawImageSection(sx - 100/zoom, sy - 388/zoom + 144/zoom*(1-nitroProgress), 94/zoom, 144/zoom*nitroProgress, 0, 0, 94, 144*nitroProgress, "images/nitro_filled.png", 180, 0, 0, tocolor(255, 255, 255, 255), false)
            end
        end

        local vmax = string.format("%03d", math.floor(math.min(vmax, 999)))
        drawShadowText(vmax, sx - 40/zoom, sy - 100/zoom, nil, nil, tocolor(255, 255, 255, 255), 1, font3, "right", "bottom", false, false, false, false, false)
        drawShadowText("km/h", sx - 135/zoom, sy - 112/zoom, nil, nil, tocolor(255, 255, 255, 255), 1, font1, "right", "bottom", false, false, false, false, false)

        local toggleLPG = getElementData(veh, "vehicle:togglelpg") or false

        drawShadowText(toggleLPG == false and "&#9679; #ffffffPB: "..fuel.." / 100L" or "#ffffffPB: "..fuel.." / 100L", sx - 40/zoom, sy - 80/zoom, nil, nil, tocolor(255, 255, 0, 255), 1, font1, "right", "bottom", false, false, false, true, false)
        if getElementData(veh, "vehicle:upgrades") and getElementData(veh, "vehicle:upgrades")['lpg'] then
            local fuellpg = getElementData(veh, "vehicle:fuellpg") or 0
            local fuellpg = string.format("%.1f", fuellpg)

            drawShadowText(toggleLPG == true and "&#9679; #ffffffLPG: "..fuellpg.." / 100L" or "#ffffffLPG: "..fuellpg.." / 100L", sx - 40/zoom, sy - 55/zoom, nil, nil, tocolor(255, 255, 0, 255), 1, font1, "right", "bottom", false, false, false, true, false)
        end
    end
end
addEventHandler("onClientRender", root, drawSpeedo)

function getVehicleRPM(vehicle)
    local vehicleRPM = 0
    if (vehicle) then
        if (getVehicleEngineState(vehicle) == true) then
            if getVehicleCurrentGear(vehicle) > 0 then
                vehicleRPM = math.floor(((getElementSpeed(vehicle, "km/h") / getVehicleCurrentGear(vehicle)) * 100) + 0.5)
                if (vehicleRPM < 650) then
                    vehicleRPM = math.random(650, 750)
                elseif (vehicleRPM >= 9000) then
                    vehicleRPM = math.random(9000, 9900)
                end
            else
                vehicleRPM = math.floor((getElementSpeed(vehicle, "km/h") * 200) + 0.5)
                if (vehicleRPM < 650) then
                    vehicleRPM = math.random(650, 750)
                elseif (vehicleRPM >= 9000) then
                    vehicleRPM = math.random(9000, 9900)
                end
            end
        else
            vehicleRPM = 0
        end

        return tonumber(vehicleRPM)
    else
        return 0
    end
end

function getElementSpeed(theElement, unit)
    assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")")
    local elementType = getElementType(theElement)
    assert(elementType == "player" or elementType == "ped" or elementType == "object" or elementType == "vehicle" or elementType == "projectile", "Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got " .. elementType .. ")")
    assert((unit == nil or type(unit) == "string" or type(unit) == "number") and (unit == nil or (tonumber(unit) and (tonumber(unit) == 0 or tonumber(unit) == 1 or tonumber(unit) == 2)) or unit == "m/s" or unit == "km/h" or unit == "mph"), "Bad argument 2 @ getElementSpeed (invalid speed unit)")
    unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit))
    local mult = (unit == 0 or unit == "m/s") and 50 or ((unit == 1 or unit == "km/h") and 180 or 111.84681456)
    return (Vector3(getElementVelocity(theElement)) * mult).length
end

function drawShadowText(text, x, y, w, h, color, size, font, ...)
    local text = tostring(text)
    dxDrawText(text:gsub("#%x%x%x%x%x%x", ""), x - 1, y, w, h, tocolor(0, 0, 0, 255), size, font, ...)
    dxDrawText(text:gsub("#%x%x%x%x%x%x", ""), x, y - 1, w, h, tocolor(0, 0, 0, 255), size, font, ...)
    dxDrawText(text:gsub("#%x%x%x%x%x%x", ""), x - 1, y - 1, w, h, tocolor(0, 0, 0, 255), size, font, ...)
    dxDrawText(text, x, y, w, h, color, size, font, ...)
end

za pomoc daje zimne :piwo:

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Wysłany: 2023-09-18, 20:42


MlodyRafonix







Wiek: 26
Na forum: 2040 dni
Posty: 103

Piwa: 958

Respekt: 60

1. Pobranie danych z bazy (zapytanie),
2. Ustawienie pobranej wartości z danej tabeli jako elementDate dla konkretnego pojazdu.

czyli:

local wynik = exports["ZASOB"]:zapytanie("SELECT `co_ma_pobrac` FROM `skad` WHERE `idpojazdu` = ?", idpojazdu)
setElementData(pojazd, "nazwa_elementdaty", wynik.co_ma_pobrac)


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 2 piw(a):
K4M7K, borsuk
Wysłany: 2023-09-18, 21:18


K4M7K







Wiek: 34
Na forum: 1326 dni
Posty: 9
Nick w MP: 7EVEN

Piwa: 6

Respekt: 50

Cytat:

gdzie mam to umiescic jesli to o to chodzi to gdy to umieszcze gdzies tam,to bedzie mi sie to zapisywac w bazie danych(chodzi o motyw licznika i rgb) bo nie mam w bazie zadnej tabelki odnosnie motywu i rgb a i tam jak jest "ZASOB" albo "co ma pobrac" to co mam dokaldnie dac?


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Wysłany: 2023-09-19, 08:34


MlodyRafonix







Wiek: 26
Na forum: 2040 dni
Posty: 103

Piwa: 958

Respekt: 60

Ten kod jedynie odczytuje wynik z bazy danych, który później ustawiasz jako element date dla konkretnego elementu. Zapisu nie zawiera.

"ZASOB" to zasób (łączenie z bazą danych) z którego exportujesz funkcje. Nie wiem jak to wygląda w twojej paczce, w xyzzyrp masz np. DB i DB2, czyli exports["DB2"]:...

https://gtao.pl/poradnik-sql-sqlite-vt102402.htm

Może to cię trochę nakieruje.

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Wysłany: 2023-09-19, 15:47


K4M7K







Wiek: 34
Na forum: 1326 dni
Posty: 9
Nick w MP: 7EVEN

Piwa: 6

Respekt: 50

mam paczke pys 3.0 czyli wtedy wpisac pystories-db czy DB2? ten caly kod"local wynik = exports["ZASOB"]:zapytanie("SELECT `co_ma_pobrac` FROM `skad` WHERE `idpojazdu` = ?", idpojazdu)
setElementData(pojazd, "nazwa_elementdaty", wynik.co_ma_pobrac)" nalezy umiescic gdzies w skrypcie? i ostatnie pytanie jak jest "co ma pobrac" albo "skad ma pobrac" to co dac w tamte miejsca i ustawianie element daty czyli ta nazwa w skrypcie tylko moge usatwic jaka chce czy ma byc to cos odpowiedniego z bazy danych oraz jak juz po zrobieniu tego jak ustawic rgb do licznik a lub motyw?

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Wysłany: 2023-09-19, 18:39


MlodyRafonix







Wiek: 26
Na forum: 2040 dni
Posty: 103

Piwa: 958

Respekt: 60

1. exports["pystories-db"]:...
2. https://gtao.pl/poradnik-sql-sqlite-vt102402.htm

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Tagi: witam :: jak :: dodac :: licznik :: bazy :: danych?
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

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