Wysłany: 2016-05-06, 16:50
marcin778
Krytyk serwerów MTA
Wiek: 24 Na forum: 4149 dni Posty: 2268
Nick w MP: Marcineg
Piwa : 4662
Witam, mam pytanie poniewa? edytowa?em sobi? przechowalnie pojazd?w riota. Tak by zapisywa?a palio oraz przebieg pojazdu lecz tak nie jest. To znaczy zapisuje paliwo, lecz przebiegu ju? nie. Tabele w *.db utworzy?em, db3 nic nie pokazuje.
--[[
Code by Riot
--]]
-- SQL LITE
handler = dbConnect ( "sqlite" , "przechowywalnia.db" )
dbExec ( handler , "CREATE TABLE IF NOT EXISTS `przechowywalnia` (`id` INTEGER, `model` INTEGER, `wlasciciel` INTEGER, `przebieg` FLOAT,`paliwo` FLOAT)" )
function onStartPrzechowywalnia ()
-- marker
local maly = createMarker ( 1579.67 , - 1414.42 , 13.56 - 0.8 , "cylinder" , 1 , 255 , 0 , 0 , 45 )
createBlip ( 1583.37 , - 1414.43 , 13.60 - 0.8 , 16 )
addEventHandler ( "onMarkerHit" , maly , onPrzechowywalniaHit )
duzy = createMarker ( 1583.37 , - 1414.43 , 13.60 - 0.8 , "cylinder" , 9.5 , 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 . YNLSystemPojazdow : stworzPojazd ( id , x , y , z )
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 paliwo = getElementData ( veh , "fuel" )
local przebieg = getElementData ( veh , "przebieg" )
local model = getElementModel ( veh )
dbExec ( handler , "INSERT INTO przechowywalnia VALUES('" .. id .. "', '" .. model .. "', '" .. wlasciciel .. "', '" .. przebieg .. "', '" .. paliwo .. "')" )
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 ) Elementdata si? zgadza. Nie wiem dlaczego tak si? dzieje. Paliwo zapisuje, przebiegu nie.
Wysłany: 2016-05-06, 17:56
MIKAELmta
Wiek: 24 Na forum: 3978 dni Posty: 311
Piwa : 10617
Ag gdzie funkcja zmieniaj?ce elementDaty?
Wysłany: 2016-05-06, 17:57
marcin778
Krytyk serwerów MTA
Wiek: 24 Na forum: 4149 dni Posty: 2268
Nick w MP: Marcineg
Piwa : 4662
MIKAELmta , Jaka funkcja zmieniaj?ca elementdaty ?
Wysłany: 2016-05-06, 22:08
TheGuruPolska
Wiek: 36 Na forum: 3766 dni Posty: 65
Nick w MP: TheGuru
Piwa : 47
Ustaw tutaj nadawanie przebiegu:
Kod: --tworze pojazd
local x, y, z = getElementPosition(duzy)
local zrob = exports.YNLSystemPojazdow:stworzPojazd(id, x, y, z)
if zrob then
warpPedIntoVehicle(source, zrob)
------------- TUTAJ
else
Tagi: paliwo :: przebieg
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: