parking c - local screenW, screenH = guiGetScreenSize()
local mdestroy=createMarker(313.32, -186.20, 1.60-1, "cylinder",3,200,25,25,0)
local marker=createMarker(307.75, -185.75, 1.58-1.20, "cylinder",1.5,0,50,205,50)
local t=createElement("text")
setElementData(t,"scale",1.5)
setElementData(t,"name","Odbi?r pojazd?w")
setElementPosition(t,307.75, -185.75, 1.58)
local wm={}
wm.window = guiCreateWindow(321, 168, 719, 386, "Przechowalnia!", false)
guiWindowSetSizable(wm.window, false)
wm.submit = guiCreateButton(0.01, 0.84, 0.41, 0.13, "Wyci?gnij pojazd", true, wm.window)
guiSetFont(wm.submit, "default-bold-small")
wm.close = guiCreateButton(0.58, 0.84, 0.41, 0.13, "Zamknij okno", true, wm.window)
guiSetFont(wm.close, "default-bold-small")
wm.gridlist = guiCreateGridList(0.03, 0.26, 0.93, 0.51, true, wm.window)
guiGridListAddColumn(wm.gridlist, "ID", 0.4)
guiGridListAddColumn(wm.gridlist, "Model", 0.6)
wm.label = guiCreateLabel(0.07, 0.08, 0.93, 0.18, "Przechowalnia pojazd?w.\nAby w?o?y? pojazd wjedz w pozostawianie pojazd?w i kliknij 'W??? Pojazd'\nAby wyci?gna? pojazd kliknij Wyjmij pojazd", true, wm.window)
guiSetFont(wm.label, "default-bold-small")
guiSetVisible(wm.window, false)
local w={}
w.window = guiCreateWindow(421, 208, 519, 286, "Przechowalnia!", false)
guiWindowSetSizable(w.window, false)
w.submit = guiCreateButton(0.01, 0.84, 0.41, 0.13, "W??? pojazd", true, w.window)
guiSetFont(w.submit, "default-bold-small")
w.close = guiCreateButton(0.58, 0.84, 0.41, 0.13, "Zamknij okno", true, w.window)
guiSetFont(w.close, "default-bold-small")
w.label = guiCreateLabel(0.17, 0.38, 0.93, 0.18, "Aby w?o?y? pojazd do przechowywalni kliknij 'W??? pojazd'\nAby zamkn?? okno przechowywalni kliknij 'Zamknij okno'", true, w.window)
guiSetFont(w.label, "default-bold-small")
guiSetVisible(w.window, false)
addEvent("onParkingGetVehicles", true)
addEventHandler("onParkingGetVehicles", root, function(result)
guiGridListClear(wm.gridlist)
if not result then return end
for i,v in pairs(result) do
local row=guiGridListAddRow(wm.gridlist)
guiGridListSetItemText(wm.gridlist, row, 1, v["id"], false, false)
guiGridListSetItemText(wm.gridlist, row, 2, getVehicleNameFromModel(v["model"]), false, false)
end
end)
function czychceszoddac(el,md)
if not md or getElementType(el) ~= "player" then return end
if el ~= localPlayer then return end
local veh = getPedOccupiedVehicle(el)
if getVehicleController(veh) ~= localPlayer then return end
if not isPedInVehicle(el) then return end
setElementFrozen(veh,true)
guiSetVisible(w.window, true)
showCursor(true)
end
addEventHandler('onClientMarkerHit',mdestroy,czychceszoddac)
function wloz (plr)
triggerServerEvent("wjedzAutemNaParking", localPlayer)
guiSetVisible(w.window, false)
showCursor(false)
end
addEventHandler("onClientGUIClick", w.submit, wloz)
function zamknij ()
local veh = getPedOccupiedVehicle(localPlayer)
guiSetVisible(w.window, false)
showCursor(false)
setElementFrozen(veh,false)
end
addEventHandler("onClientGUIClick", w.close, zamknij)
addEventHandler("onClientMarkerHit", marker, function(el,md)
if not md or getElementType(el) ~= "player" then return end
if el ~= localPlayer then return end
if isPedInVehicle(el) then return end
if guiGetVisible(wm.window) == false then
showCursor(true)
guiSetVisible(wm.window, true)
triggerServerEvent("onParkingGetRekords", localPlayer)
end
end)
addEventHandler("onClientGUIClick", resourceRoot, function()
if source == wm.close then
if guiGetVisible(wm.close) == true then
showCursor(false)
guiSetVisible(wm.window, false)
end
end
if source == wm.submit then
local selectedRow=guiGridListGetSelectedItem(wm.gridlist) or -1
if selectedRow < 0 then return end
local vehicles=getElementsWithinColShape(sphere,"vehicle")
local id=guiGridListGetItemText(wm.gridlist, selectedRow, 1)
guiGridListRemoveRow(wm.gridlist, selectedRow)
guiSetVisible(wm.window, false)
showCursor(false)
setElementPosition(localPlayer,302.40, -191.54, 1.60)
triggerServerEvent("onParkingVehicleSpawn", localPlayer, tonumber(id))
end
end)
function filedelet ()
if fileExists("c_parking.lua") then
fileDelete("c_parking.lua")
end
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), filedelet)
Parking -s
local zone = createColSphere(302.42, -187.46, 1.69,4)
local t=createElement("text")
setElementData(t,"scale",1.5)
createBlipAttachedTo(t, 35)
setElementData(t,"name","Pozostawianie pojazd?w")
setElementPosition(t,313.32, -186.20, 1.60)
addEvent("onParkingGetRekords", true)
addEventHandler("onParkingGetRekords", root, function()
local rid=getElementData(source,"player:rid")
if not rid then return end
local org = getElementData(source,"player:organization")
local result=exports["rs-db"]:dbGet("SELECT * FROM rs_pojazdy WHERE (ownedPlayer=? OR ownedGroup=?) AND parking=1",rid,org or "Brak")
if #result > 0 then
triggerClientEvent(source, "onParkingGetVehicles", source, result)
end
end)
addEvent("wjedzAutemNaParking", true)
addEventHandler("wjedzAutemNaParking", root, function(el,md)
local veh=getPedOccupiedVehicle(source)
if not veh then return end
if getVehicleController(veh) ~= source then return end
local id=getElementData(veh,"vehicle:id")
if not id then return end
if isTimer(timeroddania) then return end
setElementFrozen(veh,true)
setControlState ( source, "enter_exit", true )
triggerClientEvent(source, "dodaj:powiadomienie", root, "* Pojazd wje?dza do przechowywalni...")
timeroddania=setTimer(function()
exports["rs-pojazdy"]:onSaveVehicle(veh)
destroyElement(veh)
exports["rs-db"]:dbSet("UPDATE rs_pojazdy SET parking=1 WHERE id=?", id)
triggerClientEvent(source, "dodaj:powiadomienie", root, "* Pojazd zosta? zapisany w przechowywalni.")
end, 3000, 1)
end)
addEvent("onParkingVehicleSpawn", true)
addEventHandler("onParkingVehicleSpawn", root, function(id)
if not id then return end
if #getElementsWithinColShape(zone,"vehicle") >= 1 then
outputChatBox("* Spawn pojazdu zastawiony...",source,255,0,0)
return
end
local spawn=exports["rs-pojazdy"]:onRespawnVehicles(_,id,{302.42, -187.46, 1.69, 0.1, 0.0, 180.1})
if spawn then
end
end)