Wysłany: 2019-07-02, 18:26
readreis
Wiek: 37 Na forum: 3908 dni Posty: 62
Piwa : 4
Witam, potrzebuje waszej pomocy 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" , 5 , 0 , 200 , 255 , 255 )
local cuboid = createColCuboid ( 1718.10 , 1851.32 , 9.5 , 39.25 , 192 , 7 )
createBlip ( 1734.64 , 1962.44 , 10.82 , 25 , 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.74 , 0.33 , 0.25 , 0.50 , "Gielda" , true )
guiWindowSetSizable ( wm . window , false )
guiWindowSetMovable ( wm . window , false )
guiSetVisible ( wm . window , false )
wm . label = guiCreateLabel ( 0.06 , 0.07 , 0.89 , 0.07 , "Wpisz cen? kt?ra ma widnie? na poje?dzie." , true , wm . window )
guiLabelSetHorizontalAlign ( wm . label , "center" , false )
guiLabelSetVerticalAlign ( wm . label , "center" )
wm . label2 = guiCreateLabel ( 0.06 , 0.21 , 0.89 , 0.07 , "Po odj?ciu podatku cena wyniesie: 0 PLN" , true , wm . window )
guiLabelSetHorizontalAlign ( wm . label2 , "center" , false )
guiLabelSetVerticalAlign ( wm . label2 , "center" )
wm . edit = guiCreateEdit ( 0.06 , 0.40 , 0.91 , 0.10 , "" , true , wm . window )
wm . submit2 = guiCreateButton ( 0.06 , 0.55 , 0.90 , 0.16 , "Zgadzam si?" , true , wm . window )
wm . submit = guiCreateButton ( 0.06 , 0.75 , 0.90 , 0.20 , "Akceptuj" , true , wm . 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." , 255 , 0 , 0 )
return
end
if getElementData ( veh , "vehicle:ownedPlayer" ) ~= getElementData ( localPlayer , "player:sid" ) then return end
showCursor ( true , false )
guiSetVisible ( wm . window , true )
guiSetVisible ( wm . label2 , false )
guiSetVisible ( wm . submit2 , false )
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 . window , false )
end )
addEventHandler ( "onClientGUIClick" , resourceRoot , function()
if not wstep then return end
local cena = tonumber ( guiGetText ( wm . edit ))
if not cena or cena < 1 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 . submit2 , true )
guiSetVisible ( wm . label2 , true )
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 . window , false )
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 )
Wysłany: 2019-07-02, 23:17
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
Eksport masz dla klienta czy serwera? Bo pewnie tamto jest po stronie serwera, a tu masz klienta.
Wysłany: 2019-07-02, 23:45
readreis
Wiek: 37 Na forum: 3908 dni Posty: 62
Piwa : 4
"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
Wysłany: 2019-07-02, 23:50
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
Poka? met? skryptu pystories-db, "tamto" m?wi?c na eksport do bazy.
Wysłany: 2019-07-02, 23:56
readreis
Wiek: 37 Na forum: 3908 dni Posty: 62
Piwa : 4
"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?
Wysłany: 2019-07-03, 08:36
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
Proponuj? zastosowanie elementDaty
albo zwyk?ej tabeli, do kt?rej wykonujesz eksporty w kodzie pojazd?w.
Wysłany: 2019-07-03, 17:12
readreis
Wiek: 37 Na forum: 3908 dni Posty: 62
Piwa : 4
"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" , 5 , 0 , 200 , 255 , 255 )
local cuboid = createColCuboid ( 1718.10 , 1851.32 , 9.5 , 39.25 , 192 , 7 )
createBlip ( 1734.64 , 1962.44 , 10.82 , 25 , 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.74 , 0.33 , 0.25 , 0.50 , "Gielda" , true )
guiWindowSetSizable ( wm . window , false )
guiWindowSetMovable ( wm . window , false )
guiSetVisible ( wm . window , false )
wm . label = guiCreateLabel ( 0.06 , 0.07 , 0.89 , 0.07 , "Wpisz cen? kt?ra ma widnie? na poje?dzie." , true , wm . window )
guiLabelSetHorizontalAlign ( wm . label , "center" , false )
guiLabelSetVerticalAlign ( wm . label , "center" )
wm . label2 = guiCreateLabel ( 0.06 , 0.21 , 0.89 , 0.07 , "Po odj?ciu podatku cena wyniesie: 0 PLN" , true , wm . window )
guiLabelSetHorizontalAlign ( wm . label2 , "center" , false )
guiLabelSetVerticalAlign ( wm . label2 , "center" )
wm . edit = guiCreateEdit ( 0.06 , 0.40 , 0.91 , 0.10 , "" , true , wm . window )
wm . submit2 = guiCreateButton ( 0.06 , 0.55 , 0.90 , 0.16 , "Zgadzam si?" , true , wm . window )
wm . submit = guiCreateButton ( 0.06 , 0.75 , 0.90 , 0.20 , "Akceptuj" , true , wm . 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." , 255 , 0 , 0 )
return
end
if getElementData ( veh , "vehicle:ownedPlayer" ) ~= getElementData ( localPlayer , "player:sid" ) then return end
showCursor ( true , false )
guiSetVisible ( wm . window , true )
guiSetVisible ( wm . label2 , false )
guiSetVisible ( wm . submit2 , false )
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 . window , false )
end )
addEventHandler ( "onClientGUIClick" , resourceRoot , function()
if not wstep then return end
local cena = tonumber ( guiGetText ( wm . edit ))
if not cena or cena < 1 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 . submit2 , true )
guiSetVisible ( wm . label2 , true )
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 . window , false )
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 )
Wysłany: 2019-07-03, 17:14
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
Sprawdzasz czy dana elementdata rowna si? 1, wtedy zapisujesz pod zmienn? "Tak".
if mk1 == 1 then mk1 = "Tak" else mk1 = "Nie" end
Wysłany: 2019-07-03, 17:40
readreis
Wiek: 37 Na forum: 3908 dni Posty: 62
Piwa : 4
"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)
Wysłany: 2019-07-03, 17:46
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
Zwraca Ci tabel?, co tu trudnego do przeczytania?
Wysłany: 2019-07-03, 17:52
readreis
Wiek: 37 Na forum: 3908 dni Posty: 62
Piwa : 4
rozumiem ze zwraca ale nie wiem jak to naprawic ;/
Wysłany: 2019-07-03, 18:18
Wilq
Wiek: 24 Na forum: 4428 dni Posty: 3410
Piwa : 739
Poka? kod, co chcesz wyci?gn?? z tego getVehicleHandling?
Mo?esz u?y? takiej funkcji:
function getVehicleHandlingProperty ( element , property )
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 element , not a vehicle or no valid property string . Return failure
end
Wtedy tak j? wykonujesz:
getVehicleHandlingProperty ( zmienna_auta , nazwa_handlingu )
To Ci zwr?ci odpowiedni? warto?? danego handlingu.
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
dziala jestes mistrzem leci piwko i respekt
Tagi: pobieranie :: bazy :: danych
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: