Pyrek24
Wiek: 25 Na forum: 3438 dni Posty: 546
Nick w MP: Pyrek
Piwa : 10
Witam ot?? pom?g?by kto? z zapisywaniem paliwa, przebiegu oraz tunningu vizualnego ? Bardzo bym prosi? i? nie mog? zbytnio tego ogarn?? kod:
c.lua
local showed = false
local actualVeh = 1
local target = nil
local data = {}
function isRendering ()
if target then
dxSetRenderTarget ( target , true )
dxDrawRectangle ( 0 , 0 , 640 , 480 , tocolor ( 0 , 0 , 0 , 225 ))
dxDrawRectangle ( 0 , 460 , 640 , 20 , tocolor ( 36 , 175 , 178 , 255 ))
dxDrawText ( "Informacje dt. pojazdu:\n" .. getVehicleNameFromModel ( data [ actualVeh ][ 2 ]).. " (ID: " .. data [ actualVeh ][ 1 ].. ")\nZarejestrowany: " .. data [ actualVeh ][ 5 ].. "\n\nPojemno??: " .. data [ actualVeh ][ 6 ].. " dm3\nPrzebieg: " .. string . format ( "%.02f" , data [ actualVeh ][ 3 ]).. "km\nStan paliwa: " .. data [ actualVeh ][ 4 ].. "l" , 0 , 0 , 640 , 480 , tocolor ( 255 , 255 , 255 , 255 ), 3 , "default-bold" , "center" , "center" )
dxSetRenderTarget ()
dxDrawMaterialLine3D ( 1353.08 - 0.08 , - 1644.64 , 15 + 0.7 , 1353.08 - 0.08 , - 1644.64 , 15 - 0.7 , target , 2.4 , tocolor ( 255 , 255 , 255 , 255 ), 1353.08 , - 1644.64 , 15 )
end
end
addEvent ( "onParkingGetVehicles" , true )
addEventHandler ( "onParkingGetVehicles" , root , function( result )
if result then
for i , v in pairs ( result ) do
table . insert ( data , { v . id , v . model , v . mileage , v . fuel , ( v . registered == "true" and "TAK" or "NIE" ), v . capacity })
end
Timer (function()
showed = true
showChat ( false )
localPlayer . frozen = true
target = DxRenderTarget ( 640 , 480 , true )
localPlayer : setData ( "player:hud_visible" , true )
addEventHandler ( "onClientRender" , root , isRendering )
triggerServerEvent ( "parkingPojazd" , localPlayer , data [ actualVeh ][ 1 ])
triggerEvent ( "onClientAddNotification" , localPlayer , "Aby wybra? pojazd - manewruj strza?kami, aby wybra? pojazd kliknij enter lub powr?? do gry przyciskiem backspace." , "info" )
Camera . setMatrix ( 1358.0087890625 , - 1646.9567871094 , 14.319800376892 , 1357.2611083984 , - 1646.3435058594 , 14.064926147461 , 0 , 92 )
setPlayerHudComponentVisible ( "radar" , false )
end , 200 , 1 )
end
end )
bindKey ( "arrow_l" , "both" , function( key , state )
if state ~= "down" or showed ~= true then return false end
if actualVeh == #data then actualVeh = 1 else actualVeh = actualVeh + 1 end
triggerServerEvent ( "parkingPojazd" , localPlayer , data [ actualVeh ][ 1 ])
end )
bindKey ( "arrow_r" , "both" , function( key , state )
if state ~= "down" or showed ~= true then return false end
if actualVeh == 1 then actualVeh = #data else actualVeh = actualVeh - 1 end
triggerServerEvent ( "parkingPojazd" , localPlayer , data [ actualVeh ][ 1 ])
end )
bindKey ( "backspace" , "down" , function( key , state )
if showed then
showChat ( true )
showed = false
localPlayer . frozen = false
setCameraTarget ( localPlayer , localPlayer )
removeEventHandler ( "onClientRender" , root , isRendering )
triggerServerEvent ( "usunPojazd:parking" , localPlayer )
localPlayer : setData ( "player:hud_visible" , false )
setPlayerHudComponentVisible ( "radar" , true )
target : destroy ()
target = nil
data = {}
end
end )
bindKey ( "enter" , "down" , function()
if showed then
if data [ actualVeh ][ 5 ] == "TAK" then
showChat ( true )
showed = false
localPlayer . frozen = false
setCameraTarget ( localPlayer , localPlayer )
removeEventHandler ( "onClientRender" , root , isRendering )
triggerServerEvent ( "usunPojazd:parking" , localPlayer )
triggerServerEvent ( "odbierzPojazd" , localPlayer , localPlayer , data [ actualVeh ][ 1 ])
localPlayer : setData ( "player:hud_visible" , false )
setPlayerHudComponentVisible ( "radar" , true )
target : destroy ()
target = nil
data = {}
else
triggerEvent ( "onClientAddNotification" , localPlayer , "Ten pojazd nie jest zarejestrowany!" , "error" )
end
end
end )
s.lua
local pojazd = {}
local odbieranie = Marker ( 1536.12 , 2019.58 , 10.82 - 0.9 , "cylinder" , 1.1 , 255 , 80 , 0 , 40 )
local pozostawienie = Marker ( 1534.61 , 2037.29 , 10.82 - 1 , "cylinder" , 4 , 36 , 175 , 178 , 40 )
local cuboid = ColShape . Cuboid ( 1534.75 , 2003.61 , 10.55 , 0.0 , 360.0 , 357.9 , 6 )
local cuboid_two = ColShape . Cuboid ( 1540.75 , 2003.61 , 10.55 , 0.0 , 360.0 , 357.9 , 6 )
local cuboid_three = ColShape . Cuboid ( 1548.75 , 2003.61 , 10.55 , 0.0 , 360.0 , 357.9 , 6 )
local prowadnice = {
[ 1 ] = { 1356.8100585938 , - 1658.9399414063 , 14.03 },
[ 2 ] = { 1356.8299560547 , - 1651.1040039063 , 14.03 },
[ 3 ] = { 1356.8399658203 , - 1643.375 , 14.03 },
[ 4 ] = { 1356.849609375 , - 1635.5703125 , 14.03 }
}
for i , v in ipairs ( prowadnice ) do
local object = Object ( 2061 , Vector3 ( v [ 1 ], v [ 2 ], v [ 3 ]), Vector3 ( 90 , 0 , 0 ))
end
local object4 = Object ( 7891 , 1358.1904296875 , - 1635.5703125 , 14.03 , 90 , 0 , 90 )
local text = Element ( "text" )
text : setData ( "name" , "Przechowywalnia\nOdbi?r pojazd?w" )
text . position = Vector3 ( 1536.12 , 2019.58 , 10.82 + 0.2 )
createBlipAttachedTo ( text , 35 )
local text2 = Element ( "text" )
text2 : setData ( "name" , "Przechowywalnia\nPozostawianie pojazd?w" )
text2 . position = Vector3 ( 1534.61 , 2037.29 , 10.82 + 0.2 )
addEventHandler ( "onMarkerHit" , odbieranie , function( player , dimension )
if player . type ~= "player" or player . inVehicle then return false end
local result = exports [ "ogrpg-db" ]: dbGet ( "SELECT * FROM ogrpg_vehicles WHERE (ownedPlayer=? OR ownedGroup=?) AND parking=1" , player : getData ( "player:uid" ), player : getData ( "player:organization:id" ) or "brak" )
if #result > 0 then triggerClientEvent(player, "onParkingGetVehicles", root, result) else triggerClientEvent(player, "onClientAddNotification", player, "Nie posiadasz ?adnego pojazdu prywatnego dost?pnego w przechowalni!", "error") end
end )
addEventHandler ( "onMarkerHit" , pozostawienie , function( hitElement , md )
if isElement ( hitElement ) and getElementType ( hitElement ) == "player" and getPedOccupiedVehicle ( hitElement ) then
local id = getPedOccupiedVehicle ( hitElement ): getData ( "vehicle:id" )
if not id then return false end
exports [ "ogrpg-vehicles" ]: onSaveVehicle ( getPedOccupiedVehicle ( hitElement ))
exports [ "ogrpg-db" ]: dbSet ( "UPDATE ogrpg_vehicles SET parking=1, tp_to_parking=? WHERE id=?" , "Schowany przez kierowc? (" .. hitElement . name .. ")." , id )
setTimer ( destroyElement , 50 , 1 , getPedOccupiedVehicle ( hitElement ))
end
end )
local function store ()
local cuboid = getElementsWithinColShape ( cuboid , "vehicle" )
if #cuboid > 0 and not cuboid[1].controller then
exports [ "ogrpg-vehicles" ]: onSaveVehicle ( cuboid [ 1 ])
exports [ "ogrpg-db" ]: dbSet ( "UPDATE ogrpg_vehicles SET parking=1 WHERE id=?" , cuboid [ 1 ]: getData ( "vehicle:id" ))
cuboid [ 1 ]: destroy ()
end
end
local function store2 ()
local cuboid = getElementsWithinColShape ( cuboid_two , "vehicle" )
if #cuboid > 0 and not cuboid[1].controller then
exports [ "ogrpg-vehicles" ]: onSaveVehicle ( cuboid [ 1 ])
exports [ "ogrpg-db" ]: dbSet ( "UPDATE ogrpg_vehicles SET parking=1 WHERE id=?" , cuboid [ 1 ]: getData ( "vehicle:id" ))
cuboid [ 1 ]: destroy ()
end
end
local function store3 ()
local cuboid = getElementsWithinColShape ( cuboid_three , "vehicle" )
if #cuboid > 0 and not cuboid[1].controller then
exports [ "ogrpg-vehicles" ]: onSaveVehicle ( cuboid [ 1 ])
exports [ "ogrpg-db" ]: dbSet ( "UPDATE ogrpg_vehicles SET parking=1 WHERE id=?" , cuboid [ 1 ]: getData ( "vehicle:id" ))
cuboid [ 1 ]: destroy ()
end
end
addEvent ( "odbierzPojazd" , true )
addEventHandler ( "odbierzPojazd" , root , function( player , id )
--if #getElementsWithinColShape(cuboid, "vehicle") > 0 and #getElementsWithinColShape(cuboid_two, "vehicle") == 0 then
-- exports [ "ogrpg-vehicles" ]: onRespawnVehicles ( _ , id , {- 1959.90 , 390.21 , 35.76 , 0 , 0 , 0 }, player , true )
-- Timer ( store , 5000 , 1 )
--elseif #getElementsWithinColShape(cuboid_two, "vehicle") > 0 and #getElementsWithinColShape(cuboid, "vehicle") == 0 then
-- exports [ "ogrpg-vehicles" ]: onRespawnVehicles ( _ , id , {- 1959.90 , 390.21 , 35.76 , 0 , 0 , 0 }, player , true )
-- Timer ( store2 , 5000 , 1 )
if #getElementsWithinColShape(cuboid, "vehicle") == 0 then
exports [ "ogrpg-vehicles" ]: onRespawnVehicles ( _ , id , { 1534.75 , 2003.61 , 10.55 , 0.0 , 360.0 , 357.9 }, player , true )
Timer ( store , 5000 , 1 )
return
end
if #getElementsWithinColShape(cuboid_two, "vehicle") == 0 then
exports [ "ogrpg-vehicles" ]: onRespawnVehicles ( _ , id , { 1534.40 , 2011.40 , 10.55 , 0.0 , 360.0 , 356.3 }, player , true )
Timer ( store2 , 5000 , 1 )
return
end
if #getElementsWithinColShape(cuboid_three, "vehicle") == 0 then
exports [ "ogrpg-vehicles" ]: onRespawnVehicles ( _ , id , { 1534.53 , 2027.06 , 10.55 , 0.0 , 0.0 , 177.0 }, player , true )
Timer ( store3 , 5000 , 1 )
return
end
if #getElementsWithinColShape(cuboid, "vehicle") > 0 and #getElementsWithinColShape(cuboid_two, "vehicle") > 0 and #getElementsWithinColShape(cuboid_three, "vehicle") > 0 then
return triggerClientEvent ( player , "onClientAddNotification" , player , "Brak miejsca do przywr?cenia pojazdu!" , "error" )
end
end )
addEvent ( "usunPojazd:parking" , true )
addEventHandler ( "usunPojazd:parking" , root , function()
setElementDimension ( source , 0 )
if pojazd [ source . name ] and isElement ( source . name ) then
pojazd [ source . name ]: destroy ()
pojazd [ source . name ] = false
end
end )
addEvent ( "parkingPojazd" , true )
addEventHandler ( "parkingPojazd" , root , function( id )
local result = exports [ "ogrpg-db" ]: dbGet ( "SELECT * FROM ogrpg_vehicles WHERE id=?" , id )
if result and #result > 0 then
if pojazd [ getPlayerName ( source )] and isElement ( pojazd [ getPlayerName ( source )]) then
destroyElement ( pojazd [ getPlayerName ( source )])
pojazd [ getPlayerName ( source )] = false
end
local color = split ( result [ 1 ]. color , "," )
local tuning = split ( result [ 1 ]. tuning , "," )
pojazd [ getPlayerName ( source )] = Vehicle ( result [ 1 ]. model , 1354.01 , - 1643.93 , 13.5 , 0 , 0 , 270 )
pojazd [ getPlayerName ( source )]. alpha = 255
setElementFrozen ( pojazd [ getPlayerName ( source )], true )
setVehicleColor ( pojazd [ getPlayerName ( source )], color [ 1 ], color [ 2 ], color [ 3 ], color [ 4 ], color [ 5 ], color [ 6 ])
for i = 1 , #tuning do addVehicleUpgrade(pojazd[getPlayerName(source)], tuning[i]) end
setElementDimension ( pojazd [ getPlayerName ( source )], getElementData ( source , "player:uid" ))
setElementDimension ( source , getElementData ( source , "player:uid" ))
end
end )
addEventHandler ( "onPlayerQuit" , root , function()
if pojazd [ source . name ] and isElement ( pojazd [ source . name ]) then
pojazd [ source . name ]: destroy ()
end
end )