Wysłany: 2016-07-17, 16:52
SamsungPLL
Programista lodówek
Wiek: 23 Na forum: 3805 dni Posty: 123
Nick w MP: SamsungPLL
Piwa : 135
Witam, chcia?bym zrobi? przechowywalnie pojazd?w na moim serwerze ale mam troche prooblem?w. Wi?c tak mam prooblem z markerem do wsadzania pojazd?w do przechowywalni, nigdzie nie mog? znale?? kodu do tego markeru. Marker do odbioru pojazd?w mam ale tego do wsadzania nie moge znale?? wi?c na dole wsadzam kod i prosz? o pomoc.
przechowalnia.lua
local cs_wydawanie = createColCuboid ( 2870.7 ,- 1820.3 , 10 , 7.2 , 6 , 3 )
local function pojazdNaParkingu ( vid )
local query = string . format ( "SELECT 1 FROM lss_vehicles WHERE id=%d AND przechowalnia=1" , vid )
local wynik = exports . DB : pobierzWyniki ( query )
return ( wynik and true or false )
end
local function czyStrefaWydawaniaWolna ()
local p = getElementsWithinColShape ( cs_wydawanie , "vehicle" )
for i , v in ipairs ( p ) do
setElementFrozen ( v , false )
end
if #p>0 then return false end
return true
end
-- triggerServerEvent ( "doOdbiorPojazdu" , resourceRoot , localPlayer , kid )
addEvent ( "doOdbiorPojazdu" , true )
addEventHandler ( "doOdbiorPojazdu" , resourceRoot , function( plr , vid )
if not vid or not tonumber ( vid ) then
outputChatBox ( "* Na wy?wietlaczu urz?dzenia pojawia si? napis ERROR" , plr )
return
end
if not pojazdNaParkingu ( vid ) then
outputChatBox ( "* Na wy?wietlaczu pojawia si? informacja: tego pojazdu nie ma na parkingu." , plr )
return
end
if not czyStrefaWydawaniaWolna () then
outputChatBox ( "* Na wy?wietlaczu pojawia si? informacja: brak miejsca przed bram?. Nie mo?na wyda? pojazdu." , plr )
return
end
takePlayerMoney ( plr , 500 )
-- no to jedziemy z koksem !
local query = string . format ( "UPDATE lss_vehicles SET przechowalnia=0,frozen=0,loc='2874.10,-1817.74,13.08',rot='0,0,90' WHERE id=%d LIMIT 1" , vid )
exports . DB : zapytanie ( query )
exports [ "lss-vehicles" ]: veh_load ( tonumber ( vid ))
outputChatBox ( "* Na wy?wietlaczu pojawia si? napis: pojazd wydany!" , plr )
triggerClientEvent ( plr , "doHideWindows" , resourceRoot )
end )
local function czyGraczMozeZostawicPojazd ( plr , vid , veh )
-- 1 nie przyjmujemy pojazdow frakcyjnych
if ( getElementData ( veh , "owning_faction" )) then
return false
end
-- 2 policja / sm moze oddac kazdy pojazd
local fid = getElementData ( plr , "faction:id" )
if fid then
if tonumber ( fid )== 2 or tonumber ( fid )== 4 then
return true
end
end
-- 3. tylko wlasciciel moze oddac pojazd
local c = getElementData ( plr , "character" )
if not c then return false end
local cid = tonumber ( c . id )
if not cid then return false end
local query = string . format ( "SELECT 1 FROM lss_vehicles WHERE id=%d AND owning_player=%d" , vid , cid )
local wynik = exports . DB : pobierzWyniki ( query )
if wynik then return true else return false end
end
local function znajdzPojazd ( id )
for i , v in ipairs ( getElementsByType ( "vehicle" )) do
local dbid = getElementData ( v , "dbid" )
if dbid and tonumber ( dbid )== tonumber ( id ) then
return v
end
end
return nil
end
-- triggerServerEvent ( "doZostawieniePojazdu" , resourceRoot , localPlayer , kid )
addEvent ( "doZostawieniePojazdu" , true )
addEventHandler ( "doZostawieniePojazdu" , resourceRoot , function( plr , vid )
vid = tonumber ( vid )
local veh = znajdzPojazd ( vid )
if not veh then
outputChatBox ( "* Na wy?wietlaczu pojawia si? napis: ERROR." , plr )
return
end
if not czyGraczMozeZostawicPojazd ( plr , vid , veh ) then
outputChatBox ( "* Na wy?wietlaczu pojawia si? napis: pojazd moze oddac tylko wlasciciel lub Policja oraz Straz Miejska" , plr )
return
end
-- zostawiamy
destroyElement ( veh )
local query = string . format ( "UPDATE lss_vehicles SET przechowalnia=1 WHERE id=%d" , vid )
exports . DB : zapytanie ( query )
outputChatBox ( "* Na wy?wietlaczu pojawia si? napis: pojazd zosta? przyj?ty." , plr )
triggerClientEvent ( plr , "doHideWindows" , resourceRoot )
end )
przechowalnia_c.lua
local cs_automat = createColSphere (- 1949.9822998047 , 1000.6187744141 , 35.175628662109 )
local m = createMarker (- 1968.8327636719 , 619.51745605469 , 35.171875 , "cylinder" , 1 )
local w1 ={}
w1 . win = guiCreateWindow ( 0.7412 , 0.34 , 0.2313 , 0.4133 , "Przechowalnia pojazd?w" , true )
-- w1 . btn_zostaw = guiCreateButton ( 0.0541 , 0.1371 , 0.8919 , 0.379 , "Zostaw pojazd" , true , w1 . win )
w1 . btn_odbierz = guiCreateButton ( 0.0541 , 0.5565 , 0.8919 , 0.379 , "Odbierz pojazd" , true , w1 . win )
guiSetVisible ( w1 . win , false )
local wo ={}
wo . win = guiCreateWindow ( 0.7531 , 0.3479 , 0.2109 , 0.3792 , "Odbi?r auta" , true )
wo . lbl = guiCreateLabel ( 0.037 , 0.1209 , 0.9185 , 0.1352 , "Wska? klucz do pojazdu, kt?ry chcesz odebra?" , true , wo . win )
wo . cmb = guiCreateComboBox ( 0.037 , 0.3 , 0.9185 , 0.6352 , "Klucz" , true , wo . win )
wo . btn = guiCreateButton ( 0.037 , 0.6 , 0.9185 , 0.3 , "Odbierz" , true , wo . win )
guiLabelSetHorizontalAlign ( wo . lbl , "center" , true )
guiSetFont ( wo . lbl , "default-small" )
guiSetVisible ( wo . win , false )
addEventHandler ( "onClientColShapeHit" , cs_automat , function( he , md )
if not md then return end
if he ~= localPlayer then return end
guiSetVisible ( w1 . win , true )
guiSetVisible ( wo . win , false )
showCursor ( true , false )
end )
addEventHandler ( "onClientColShapeLeave" , cs_automat , function( he , md )
if he ~= localPlayer then return end
guiSetVisible ( w1 . win , false )
guiSetVisible ( wo . win , false )
showCursor ( false )
end )
local function pojazdyWStrefieZostawiania ()
local pojazdy = getElementsWithinColShape ( cs_zostawianie , "vehicle" )
local pojazdy2 ={}
for i , v in ipairs ( pojazdy ) do
if ( getElementData ( v , "dbid" ) and not getVehicleController ( v )) then
table . insert ( pojazdy2 , v )
end
end
return pojazdy2
end
-- ODBIERANIE
addEventHandler ( "onClientGUIClick" , w1 . btn_odbierz , function()
-- if ( getPlayerName ( localPlayer )~= "Bob_Euler" ) then
-- outputChatBox ( "* Na wy?wietlaczu automatu pojawia si? migocz?cy napis 'ERROR'." )
-- guiSetVisible ( w1 . win , false )
-- return
-- end
guiSetVisible ( w1 . win , false )
guiSetVisible ( wo . win , true )
guiComboBoxClear ( wo . cmb )
triggerServerEvent ( "fetchStoredVehicles" , resourceRoot )
end , false )
-- triggerClientEvent ( client , "fillStoredVehicles" , resourceRoot , pojazdy )
addEvent ( "fillStoredVehicles" , true )
addEventHandler ( "fillStoredVehicles" , resourceRoot , function( pojazdy )
guiComboBoxClear ( wo . cmb )
for i , v in ipairs ( pojazdy ) do
-- outputDebugString ( v . id )
guiComboBoxAddItem ( wo . cmb , string . format ( "%d %s%s" , v . id , v . gangowe and "gangowe " or "" , getVehicleNameFromModel ( v . model ) ))
end
end )
addEventHandler ( "onClientGUIClick" , wo . btn , function()
local i = guiComboBoxGetSelected ( wo . cmb )
if not i then return end
local kid = tonumber ( string . match ( guiComboBoxGetItemText ( wo . cmb , i ), "^%d+" ))
triggerServerEvent ( "doOdbiorPojazdu" , resourceRoot , localPlayer , kid )
end )
--
-- triggerClientEvent ( plr , "doHideWindows" , resourceRoot )
addEvent ( "doHideWindows" , true )
addEventHandler ( "doHideWindows" , resourceRoot , function()
guiSetVisible ( w1 . win , false )
guiSetVisible ( wo . win , false )
end )
Wysłany: 2016-07-17, 17:53
NeX.
Calm Story
Wiek: 26 Na forum: 3643 dni Posty: 56
Nick w MP: NeX
Piwa : 36
Na samym pocz?tku powiedz mi co? wi?cej, czy w bazie danych przy stworzeniu tabeli z przechowalni? pojazd?w, jest u?yta taka sama struktura tabel jak i w skrypcie?
Wysłany: 2016-07-17, 18:09
SamsungPLL
Programista lodówek
Wiek: 23 Na forum: 3805 dni Posty: 123
Nick w MP: SamsungPLL
Piwa : 135
A to trzeba pod baze danych to podpi?? :PPP
A ja nie umiem
Podpis
1000 DNI NA FORUM: 28.09.2018r.
100 POSTÓW NA FORUM: 01.12.2017r.
Wysłany: 2016-07-18, 18:02
marcin778
Krytyk serwerów MTA
Wiek: 24 Na forum: 4149 dni Posty: 2268
Nick w MP: Marcineg
Piwa : 4662
SamsungPLL ,
local cs_automat = createColSphere (- 1949.9822998047 , 1000.6187744141 , 35.175628662109 )
co do bazy danych polecam si? nauczy? z poradnik?w itp bo tu nikt za ciebie tego nie zrobi.
Tagi: przechowywalnia :: pojazdów
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: