local sX, sY = guiGetScreenSize()
umgui = {}
umgui[1] = guiCreateWindow((sX - 400)/2, (sY - 290)/2, 400, 290, "Przechowywalnia pojazd?w", false)
guiWindowSetSizable(umgui[1], false)
umgui[2] = guiCreateLabel(10, 30, 380, 40, "Poni?ej znajduje si? lista Twoich pojazd?w, kt?re umieszczone s? w przechowywalni.", false, umgui[1])
guiLabelSetHorizontalAlign(umgui[2], "center", true)
umgui[3] = guiCreateGridList(10, 70, 380, 172, false, umgui[1])
umgui[4] = guiGridListAddColumn(umgui[3], "Pojazd", 0.6)
umgui[5] = guiGridListAddColumn(umgui[3], "ID", 0.32)
umgui[6] = guiCreateButton(10, 250, 85, 29, "Wyjd?", false, umgui[1])
umgui[7] = guiCreateButton(305, 250, 85, 29, "Przywr??", false, umgui[1])
guiSetVisible(umgui[1], false)
addEvent("showPrzechowywalniaGUI", true)
addEventHandler("showPrzechowywalniaGUI", getRootElement(),
function(pojazdy)
guiSetVisible(umgui[1], true)
showCursor(true)
guiGridListClear(umgui[3])
for i,v in pairs(pojazdy) do
local row = guiGridListAddRow(umgui[3])
guiGridListSetItemText(umgui[3], row, umgui[4], getVehicleNameFromModel(v["model"]), false, false)
guiGridListSetItemText(umgui[3], row, umgui[5], v["id"], false, false)
guiGridListSetItemData (umgui[3], row, umgui[4], v["id"])
end
end)
function onPrzechowywalniaZamknij()
guiSetVisible(umgui[1], false)
showCursor(false)
end
addEventHandler ("onClientGUIClick", umgui[6], onPrzechowywalniaZamknij, false)
function onPrzechowywalniaPrzywroc()
local row = guiGridListGetSelectedItem(umgui[3])
if row >= 0 then
local id = guiGridListGetItemData (umgui[3], row, umgui[4])
triggerServerEvent("onPrzywrocPojazdZPrzechowywalni", localPlayer, id)
onPrzechowywalniaZamknij()
end
end
addEventHandler ("onClientGUIClick", umgui[7], onPrzechowywalniaPrzywroc, false)
s:
--[[
Code by Riot
--]]
--SQL LITE
handler = dbConnect("sqlite", "przechowywalnia.db")
dbExec(handler, "CREATE TABLE IF NOT EXISTS `przechowywalnia` (`id` INTEGER, `model` INTEGER, `wlasciciel` INTEGER)")
function onStartPrzechowywalnia()
--marker
local maly = createMarker(1707.34,-1471.34,12.55, "cylinder", 2, 255, 0, 0, 45)
addEventHandler("onMarkerHit", maly, onPrzechowywalniaHit)
duzy = createMarker(1702.55,-1471.50,12.55, "cylinder", 7, 0, 133, 99, 75)
end
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStartPrzechowywalnia)
function onPrzechowywalniaHit(hitElement)
if getElementType(hitElement) == "player" then
local acc = getPlayerAccount(hitElement)
if acc then
local veh = getPedOccupiedVehicle(hitElement)
if not veh then
local login = getAccountName(acc)
local query = dbQuery(handler, "SELECT * FROM przechowywalnia WHERE wlasciciel='"..login.."'")
local result, rows = dbPoll (query, -1)
triggerClientEvent(hitElement, "showPrzechowywalniaGUI", root, result or {})
end
end
end
end
addEvent("onPrzywrocPojazdZPrzechowywalni", true)
addEventHandler("onPrzywrocPojazdZPrzechowywalni", getRootElement(),
function(id)
local query = dbQuery(handler, "SELECT * FROM przechowywalnia WHERE id='"..id.."'")
local result, rows = dbPoll (query, -1)
if #result > 0 then
dbExec(handler, "DELETE FROM przechowywalnia WHERE id='"..id.."'")
--tworze pojazd
local x, y, z = getElementPosition(duzy)
local zrob = exports.YALSalon:createVehicle(id, 1694.96,-1498.29,13.12,359.5,5.5,3.3)
if zrob then
warpPedIntoVehicle(source, zrob)
else
outputChatBox("Podane auto nie istnieje.", source, 255, 255, 255, true)
end
else
outputChatBox("Podane auto nie istnieje ju? w przechowywalni.", source, 255, 255, 255, true)
end
end)
function czyPojazdJestWPrzechowywalni(id)
local query = dbQuery(handler, "SELECT * FROM przechowywalnia WHERE id='"..id.."'")
local result, rows = dbPoll (query, -1)
if #result > 0 then
return true
else
return false
end
end
--##
timery = {}
function onPrzechoVehExit(player, seat)
if seat == 0 then
local id = getElementData(source, "car_id")
if id then
if isElementWithinMarker(source, duzy) then
timery[id] = setTimer(oddajPojazdDoPrzechowywalni, 5000, 1, source, player, id, true)
end
end
end
end
addEventHandler("onVehicleExit", getRootElement(), onPrzechoVehExit)
function oddajPojazdDoPrzechowywalni(veh, player, id, bool)
if isElement(veh) then
local acc = getPlayerAccount(player)
if acc then
local wlasciciel = getElementData(veh, "car_owner")
local model = getElementModel(veh)
dbExec(handler, "INSERT INTO przechowywalnia VALUES('"..id.."', '"..model.."', '"..wlasciciel.."')")
if isElement(player) then
if bool then
outputChatBox("Tw?j pojazd "..getVehicleName(veh).." zosta? umieszczony w przechowywalni.", player, 255, 255, 255, true)
else
outputChatBox("Odda?e? pojazd "..getVehicleName(veh).." do przechowywalni.", player, 255, 255, 255, true)
end
end
destroyElement(veh)
end
end
end
function komendaDlaAdmina(player)
local acc = getPlayerAccount(player)
if acc then
local login = getAccountName(acc)
if isObjectInACLGroup ("user."..login, aclGetGroup("Admin")) then
local veh = getPedOccupiedVehicle(player)
if veh then
local id = getElementData(veh, "car_id")
if id then
oddajPojazdDoPrzechowywalni(veh, player, id)
end
end
end
end
end
addCommandHandler("oddajauto", komendaDlaAdmina)
function onPrzechoVehEnter(player, seat)
if seat == 0 then
local id = getElementData(source, "car_id")
if id then
if isTimer(timery[id]) then
killTimer(timery[id])
end
end
end
end
addEventHandler("onVehicleEnter", getRootElement(), onPrzechoVehEnter)
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