-- Ustawienia MySQL
addEventHandler("onResourceStart", resourceRoot, function()
local baza = "******"
local host = "******"
local user = "******"
local pass = "******"
db = dbConnect("mysql", "dbname="..baza..";host="..host, user, pass, "share=1") -- Po??czenie z serwerem MySQL.
end)
local connect = dbConnect ( "sqlite", "db_21655" )
if connect then
outputDebugString( "Po??czenie z baz? SQLite zako?czy?o si? powodzeniem.")
else
outputDebugString( "Po??czenie z baz? SQLite zako?czy?o si? nie powodzeniem.")
stopResource(getThisResource())
end
--SQL LITE
handler = dbConnect("sqlite", "db_21655")
dbExec(handler, "CREATE TABLE IF NOT EXISTS `przechowywalnia` (id INTEGER, model INTEGER, wlasciciel INTEGER)")
function onStartPrzechowywalnia()
--marker
local maly = createMarker( 1937.29,2333.67,10.82-0.9, "cylinder", 1, 255, 0, 0, 45)
local maly2 = createMarker( 1547.18,-2416.65,13.55-0.9, "cylinder", 1, 255, 0, 0, 45)
addEventHandler("onMarkerHit", maly, onPrzechowywalniaHit)
addEventHandler("onMarkerHit", maly2, onPrzechowywalniaHit2)
duzy = createMarker( 1936.92,2337.58,10.82-0.8, "cylinder", 9.5, 0, 71, 255, 75)
duzy2 = createMarker( 1556.92,-2416.05,13.55-0.8, "cylinder", 9.5, 0, 71, 255, 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 query = dbQuery(handler, "INSERT INTO przechowywalnia ( name, id, model ) VALUES ( ?,?,? )", name, id, model)
local result, rows = dbPoll (query, -1)
triggerClientEvent(hitElement, "showPrzechowywalniaGUI", root, result or {})
end
end
end
end
function onPrzechowywalniaHit2(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, "showPrzechowywalniaGUI2", 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)
local hajs = getPlayerMoney(source)
koszt = 200
if #result > 0 then
dbExec(handler, "DELETE FROM przechowywalnia WHERE id='"..id.."'")
local x, y, z = getElementPosition(duzy)
local zrob = exports.zapis_aut_s:vehicle(id, x, y, z)
if zrob then
takePlayerMoney ( source, tonumber(koszt) )
outputChatBox("Z twojego konta pobrano "..koszt.."$ za przechowywanie pojazdu, ?yczymy mi?ej jazdy!", source)
warpPedIntoVehicle(source, zrob)
setVehiclePlateText( zrob, id )
else
outputChatBox("Podane auto nie istnieje.", source, 255, 255, 255, true)
end
end
end)
addEvent("onPrzywrocPojazdZPrzechowywalni2", true)
addEventHandler("onPrzywrocPojazdZPrzechowywalni2", getRootElement(),
function(id)
local query = dbQuery(handler, "SELECT * FROM przechowywalnia WHERE id='"..id.."'")
local result, rows = dbPoll (query, -1)
local hajs = getPlayerMoney(source)
koszt = 200
if #result > 0 then
dbExec(handler, "DELETE FROM przechowywalnia WHERE id='"..id.."'")
local x, y, z = getElementPosition(duzy2)
local zrob = exports.zapis_aut_s:vehicle(id, x, y, z)
if zrob then
takePlayerMoney ( source, tonumber(koszt) )
outputChatBox("Z twojego konta pobrano "..koszt.."$ za przechowywanie pojazdu, ?yczymy mi?ej jazdy!", source)
warpPedIntoVehicle(source, zrob)
setVehiclePlateText( zrob, id )
else
outputChatBox("Podane auto nie istnieje.", source, 255, 255, 255, true)
end
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 isElementWithinMarker(source, duzy) then
if seat == 0 then
local id = getElementData(source, "car_id")
if id then
timery[id] = setTimer(oddajPojazdDoPrzechowywalni, 5000, 1, source, player, id, true)
end
end
end
end
addEventHandler("onVehicleExit", getRootElement(), onPrzechoVehExit)
function onPrzechoVehExit(player, seat)
if isElementWithinMarker(source, duzy2) then
if seat == 0 then
local id = getElementData(source, "car_id")
if id 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 or source then
local wlasciciel = getElementData(veh, "car_owner")
local model = getElementModel(veh)
dbExec(handler, "INSERT INTO przechowywalnia VALUES('id' INTEGER, 'model' INTEGER, 'wlasciciel' INTEGER)")
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 ( hasObjectPermissionTo ( player, "function.kickPlayer", true ) ) 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 notifyAboutExplosion(player)
local acc = getElementData(source, "car_owner")
local id = getElementData(source, "car_id")
if acc then
if id then
oddajPojazdDoPrzechowywalni(source, player, id)
outputChatBox("Tw?j pojazd wybuch?, znajdziesz go w przechowywalni.", source)
end
end
end
addEventHandler("onVehicleExplode", getRootElement(), notifyAboutExplosion)
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)
prosz? o pomoc
[ Dodano: 2017-01-22, 15:21 ]
a to jest b??d z debugscript 3
[ Dodano: 2017-01-22, 16:57 ]
prosz? o szybk? pomoc
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