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

Wysłany: 2019-07-02, 18:26


readreis







Wiek: 37
Na forum: 3908 dni
Posty: 62

Piwa: 4

Respekt: 50

Witam, potrzebuje waszej pomocy :P Chcia?bym zrobic na gieldzie zeby na aucie bylo widac czy samochod posiada mk1, mk2 itp i nie czyta mi bazy.

Kod:

ERROR: pystories-gielda/c_giela.lua:88: call: failed to call "pystories-db:dbGet" [string "?"]
ERROR: pystories-gielda/c_giela.lua:89: attempt to get lenght of local "mk1" (a boolean value)



c_giela.lua

local marker=createMarker(1728.85,1855.26,10.82-1"cylinder"50200255255)
local cuboid=createColCuboid(1718.10,1851.32,9.539.251927)
createBlip(1734.64,1962.44,10.8225,2,0,0,0,0,0,275)

local wstep=false
local podatek=0

local text=createElement("text")
setElementPosition(text,1728.85,1855.26,10.82)
setElementData(text,"name","Gie?da\nUstawianie ceny.")

local wm={}
wm.window=guiCreateWindow(0.740.330.250.50"Gielda"true)
guiWindowSetSizable(wm.windowfalse)
guiWindowSetMovable(wm.windowfalse)
guiSetVisible(wm.windowfalse)
wm.label=guiCreateLabel(0.060.070.890.07"Wpisz cen? kt?ra ma widnie? na poje?dzie."truewm.window)
guiLabelSetHorizontalAlign(wm.label"center"false)
guiLabelSetVerticalAlign(wm.label"center")
wm.label2=guiCreateLabel(0.060.210.890.07"Po odj?ciu podatku cena wyniesie: 0 PLN"truewm.window)
guiLabelSetHorizontalAlign(wm.label2"center"false)
guiLabelSetVerticalAlign(wm.label2"center"wm.edit=guiCreateEdit(0.060.400.910.10""truewm.window)
wm.submit2=guiCreateButton(0.060.550.900.16"Zgadzam si?"truewm.window)
wm.submit=guiCreateButton(0.060.750.900.20"Akceptuj"truewm.window)

addEventHandler("onClientMarkerHit"resourceRoot, function(el,md)
    if not md or el ~= localPlayer then return end
    if not wstep then return end
    local veh=getPedOccupiedVehicle(localPlayer)
    if not veh then return end
    if getVehicleController(veh) ~= localPlayer then return end
    local spawn=getElementData(veh,"vehicle:id")
    if not spawn then return end
    if getElementHealth(veh) < 850 then
        outputChatBox("* Posiadasz zbyt uszkodzony pojazd, id? go napraw."25500)
        return
    end
    if getElementData(veh,"vehicle:ownedPlayer") ~= getElementData(localPlayer,"player:sid"then return end
    showCursor(true,false)
    guiSetVisible(wm.windowtrue)
    guiSetVisible(wm.label2false)
    guiSetVisible(wm.submit2false)
    guiSetInputMode("no_binds_when_editing")
end)

addEventHandler("onClientMarkerLeave"resourceRoot, function(el,md)
    if el~=localPlayer then return end
    if not wstep then return end
    showCursor(false)
    guiSetVisible(wm.windowfalse)
end)

addEventHandler("onClientGUIClick"resourceRoot, function()
    if not wstep then return end
    local cena=tonumber(guiGetText(wm.edit))
    if not cena or cena or cena ~= math.floor(cena) or cena 99999999 then
        outputChatBox("* Podano nieprawid?ow? cen?.")
        return
    end
    local veh=getPedOccupiedVehicle(localPlayer)
    if not veh then return end
    if getVehicleController(veh) ~= localPlayer then return end
    if not getElementData(veh,"vehicle:id"then return end
    if source == wm.submit then
        --podatek=math.floor(cena/2)
        guiSetVisible(wm.submit2true)
        guiSetVisible(wm.label2true)
        guiSetText(wm.label2"Akceptujesz podan? cen?? "..cena.." PLN")
    end
    if source == wm.submit2 then
        local online=getPlayerFromName(getPlayerName(localPlayer))
        if online then jest="Dost?pny" else jest="Niedost?pny" end
        local mk1 exports['pystories-db']:dbGet("SELECT mk1 FROM pystories_vehicles WHERE id=?",getElementData(veh"vehicle:id")) -- 88 linijka
        local desc=string.format("Pojazd: %s\nCena: %d PLN\nPrzebieg: %dkm\nSprzedaj?cy: %s\nMK1: "..mk1..""getVehicleName(veh), tonumber(cena), getElementData(veh,"vehicle:mileage"), getPlayerName(localPlayer)) --89 linijka
        setElementData(veh,"vehicle:desc",desc)
        guiSetVisible(wm.windowfalse)
        showCursor(false)
    end
end)

addEventHandler("onClientColShapeHit"cuboid, function(el,md)
    if not md or el ~= localPlayer then return end
    if wstep then return end
    wstep=true
    local veh=getPedOccupiedVehicle(el)
    setElementData(veh,"vehicle:tempspeed"60)
end)

addEventHandler("onClientColShapeLeave"cuboid, function(el,md)
    if not md or el ~= localPlayer then return end
    if not wstep then return end
    local veh=getPedOccupiedVehicle(el)
    if not veh then return end
    setElementData(veh,"vehicle:desc",false)
    setElementData(veh,"vehicle:tempspeed"false)
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-02, 23:17


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Eksport masz dla klienta czy serwera? Bo pewnie tamto jest po stronie serwera, a tu masz klienta.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-02, 23:45


readreis







Wiek: 37
Na forum: 3908 dni
Posty: 62

Piwa: 4

Respekt: 50

"Wilq" napisał/a:

Eksport masz dla klienta czy serwera? Bo pewnie tamto jest po stronie serwera, a tu masz klienta.


tamto czyli co, wszystko jest po stronie clienta

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-02, 23:50


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Poka? met? skryptu pystories-db, "tamto" m?wi?c na eksport do bazy.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-02, 23:56


readreis







Wiek: 37
Na forum: 3908 dni
Posty: 62

Piwa: 4

Respekt: 50

"Wilq" napisał/a:

Poka? met? skryptu pystories-db, "tamto" m?wi?c na eksport do bazy.


<meta>
    <!-- EXPORTS -->
    <export function="dbSet" type="server" />
    <export function="dbGet" type="server" />

    <!-- SERVERSIDE -->
    <script src="s_db.lua" type="server" />
</meta>


powoli zaczynam kumac tylko nie wiem jak to pobrac po stronie serwa i przypisac po stronie clienta masz jakis pomysl?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-03, 08:36


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Proponuj? zastosowanie elementDaty
albo zwyk?ej tabeli, do kt?rej wykonujesz eksporty w kodzie pojazd?w.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-03, 17:12


readreis







Wiek: 37
Na forum: 3908 dni
Posty: 62

Piwa: 4

Respekt: 50

"Wilq" napisał/a:

Proponuj? zastosowanie elementDaty
albo zwyk?ej tabeli, do kt?rej wykonujesz eksporty w kodzie pojazd?w.


Mk1,2,3 i rh dziala ale nie moge zrobic zeby pokazywalo jaki naped ma te auto probowalem tak jak reszta i probowalem getVehicleHandling i nie dziala chyba ze cos zle robie. Te? taki maly problem jest, ?e jak posiada auto dana rzecz to pokazuje "1" a jak nie to pokazuje "Nie" a chcialbym zamiast "1" miec "Tak"

local marker=createMarker(1728.85,1855.26,10.82-1"cylinder"50200255255)
local cuboid=createColCuboid(1718.10,1851.32,9.539.251927)
createBlip(1734.64,1962.44,10.8225,2,0,0,0,0,0,275)

local wstep=false
local podatek=0

local text=createElement("text")
setElementPosition(text,1728.85,1855.26,10.82)
setElementData(text,"name","Gie?da\nUstawianie ceny.")

local wm={}
wm.window=guiCreateWindow(0.740.330.250.50"Gielda"true)
guiWindowSetSizable(wm.windowfalse)
guiWindowSetMovable(wm.windowfalse)
guiSetVisible(wm.windowfalse)
wm.label=guiCreateLabel(0.060.070.890.07"Wpisz cen? kt?ra ma widnie? na poje?dzie."truewm.window)
guiLabelSetHorizontalAlign(wm.label"center"false)
guiLabelSetVerticalAlign(wm.label"center")
wm.label2=guiCreateLabel(0.060.210.890.07"Po odj?ciu podatku cena wyniesie: 0 PLN"truewm.window)
guiLabelSetHorizontalAlign(wm.label2"center"false)
guiLabelSetVerticalAlign(wm.label2"center"wm.edit=guiCreateEdit(0.060.400.910.10""truewm.window)
wm.submit2=guiCreateButton(0.060.550.900.16"Zgadzam si?"truewm.window)
wm.submit=guiCreateButton(0.060.750.900.20"Akceptuj"truewm.window)

addEventHandler("onClientMarkerHit"resourceRoot, function(el,md)
    if not md or el ~= localPlayer then return end
    if not wstep then return end
    local veh=getPedOccupiedVehicle(localPlayer)
    if not veh then return end
    if getVehicleController(veh) ~= localPlayer then return end
    local spawn=getElementData(veh,"vehicle:id")
    if not spawn then return end
    if getElementHealth(veh) < 850 then
        outputChatBox("* Posiadasz zbyt uszkodzony pojazd, id? go napraw."25500)
        return
    end
    if getElementData(veh,"vehicle:ownedPlayer") ~= getElementData(localPlayer,"player:sid"then return end
    showCursor(true,false)
    guiSetVisible(wm.windowtrue)
    guiSetVisible(wm.label2false)
    guiSetVisible(wm.submit2false)
    guiSetInputMode("no_binds_when_editing")
end)

addEventHandler("onClientMarkerLeave"resourceRoot, function(el,md)
    if el~=localPlayer then return end
    if not wstep then return end
    showCursor(false)
    guiSetVisible(wm.windowfalse)
end)


addEventHandler("onClientGUIClick"resourceRoot, function()
    if not wstep then return end
    local cena=tonumber(guiGetText(wm.edit))
    if not cena or cena or cena ~= math.floor(cena) or cena 99999999 then
        outputChatBox("* Podano nieprawid?ow? cen?.")
        return
    end
    local veh=getPedOccupiedVehicle(localPlayer)
    if not veh then return end
    if getVehicleController(veh) ~= localPlayer then return end
    if not getElementData(veh,"vehicle:id"then return end
    if source == wm.submit then
        --podatek=math.floor(cena/2)
        guiSetVisible(wm.submit2true)
        guiSetVisible(wm.label2true)
        guiSetText(wm.label2"Akceptujesz podan? cen?? "..cena.." PLN")
    end
    if source == wm.submit2 then
        local online=getPlayerFromName(getPlayerName(localPlayer))
        local mk1 getElementData(veh"mk1") or "Nie"
        local mk2 getElementData(veh"mk2") or "Nie"
        local mk3 getElementData(veh"mk3") or "Nie"
        local rh getElementData(veh"rh") or "Nie"
        local xfour getVehicleHandling(veh"driveType")
        if online then jest="Dost?pny" else jest="Niedost?pny" end -- 88 linijka
        local desc=string.format("Pojazd: %s\nCena: %d PLN\nPrzebieg: %dkm\nSprzedaj?cy: %s\nMK1: "..mk1.."\nMK2: "..mk2.."\nMK3: "..mk3.."\nGwintowane zawieszenie: "..rh.."\nGwintowane zawieszenie: "..xfour..""getVehicleName(veh), tonumber(cena), getElementData(veh,"vehicle:mileage"), getPlayerName(localPlayer)) --89 linijka
        setElementData(veh,"vehicle:desc",desc)
        guiSetVisible(wm.windowfalse)
        showCursor(false)
    end
end)

addEventHandler("onClientColShapeHit"cuboid, function(el,md)
    if not md or el ~= localPlayer then return end
    if wstep then return end
    wstep=true
    local veh=getPedOccupiedVehicle(el)
    --setElementData(veh,"vehicle:tempspeed"60)
end)

addEventHandler("onClientColShapeLeave"cuboid, function(el,md)
    if not md or el ~= localPlayer then return end
    if not wstep then return end
    local veh=getPedOccupiedVehicle(el)
    if not veh then return end
    setElementData(veh,"vehicle:desc",false)
    setElementData(veh,"vehicle:tempspeed"false)
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-03, 17:14


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Sprawdzasz czy dana elementdata rowna si? 1, wtedy zapisujesz pod zmienn? "Tak".

if mk1 == 1 then mk1 = "Tak" else mk1 = "Nie" end

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-03, 17:40


readreis







Wiek: 37
Na forum: 3908 dni
Posty: 62

Piwa: 4

Respekt: 50

"Wilq" napisał/a:

Sprawdzasz czy dana elementdata rowna si? 1, wtedy zapisujesz pod zmienn? "Tak".

if mk1 == 1 then mk1 = "Tak" else mk1 = "Nie" end


dobra to dziala git tylko ten naped bym ogarnal jeszcze ;/ jak probuje przez getvehiclehandling to wyskakuje blad:

attempt to concatenate local 'xfour' (a table value)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-03, 17:46


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Zwraca Ci tabel?, co tu trudnego do przeczytania?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-03, 17:52


readreis







Wiek: 37
Na forum: 3908 dni
Posty: 62

Piwa: 4

Respekt: 50

rozumiem ze zwraca ale nie wiem jak to naprawic ;/

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-07-03, 18:18


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Poka? kod, co chcesz wyci?gn?? z tego getVehicleHandling?

Mo?esz u?y? takiej funkcji:
function getVehicleHandlingProperty elementproperty )
    if isElement element ) and getElementType element ) == "vehicle" and type property ) == "string" then -- Make sure there's a valid vehicle and a property string
        local handlingTable = getVehicleHandling ( element ) -- Get the handling as table and save as handlingTable
        local value = handlingTable[property] -- Get the value from the table
        
        if value then -- If there's a value (valid property)
            return value -- Return it
        end
    end
    
    return false -- Not an elementnot a vehicle or no valid property string. Return failure
end


Wtedy tak j? wykonujesz:
getVehicleHandlingProperty(zmienna_autanazwa_handlingu)

To Ci zwr?ci odpowiedni? warto?? danego handlingu.

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
readreis
Wysłany: 2019-07-03, 19:05


readreis







Wiek: 37
Na forum: 3908 dni
Posty: 62

Piwa: 4

Respekt: 50

dziala jestes mistrzem leci piwko i respekt

Postaw piwo autorowi tego posta
 

 
Tagi: pobieranie :: 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 » Pobieranie bazy danych 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