Armus
Wiek: 43 Na forum: 3404 dni Posty: 13
Nick w MP: Armus
Piwa : 1
c_parking.lua
local screenW , screenH = guiGetScreenSize ()
local marker = createMarker (- 1785.15 , 793.49 , 24.89 - 1 , "cylinder" , 1.35 , 0 , 83 , 255 , 100 )
local sphere = createColSphere (- 1787.69 , 785.37 , 24.89 , 5 )
local wm ={}
wm . gridlist = guiCreateGridList ( 0.34 , 0.39 , 0.333 , 0.24 , true )
guiGridListAddColumn ( wm . gridlist , "ID Pojazdu" , 0.3 )
guiGridListAddColumn ( wm . gridlist , "Model" , 0.3 )
guiGridListAddColumn ( wm . gridlist , "Kierowca" , 0.3 )
guiSetVisible ( wm . gridlist , false )
panel = false
function PrzechoGUI ()
local Alpha , Alpha2 = interpolateBetween ( 0 , 0 , 0 , 255 , 180 , 0 , (( getTickCount () - czas ) / 2500 ), "Linear" )
local r2 , g2 , b2 = interpolateBetween ( 255 , 255 , 255 , 20 , 250 , 0 ,( getTickCount ()- czas )/ 1100 , "SineCurve" )
local r , g , b = interpolateBetween ( 255 , 255 , 255 , 255 , 0 , 0 ,( getTickCount ()- czas )/ 1100 , "SineCurve" )
dxDrawImage ( screenW * 0.3016 , screenH * 0.2786 , screenW * 0.4092 , screenH * 0.4805 , "okn.png" , 0 , 0 , 0 , tocolor ( 0 , 0 , 0 , Alpha2 ), false )
if not cursorPosition ( screenW * 0.3367 , screenH * 0.6406 , screenW * 0.1054 , screenH * 0.0469 ) then -- Wyjmij
dxDrawImage ( screenW * 0.3053 , screenH * 0.5768 , screenW * 0.1794 , screenH * 0.1693 , "przycisk.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , Alpha ), false )
dxDrawText ( "Wyjmij pojazd" , ( screenW * 0.3382 ) + 1 , ( screenH * 0.6419 ) + 1 , ( screenW * 0.4422 ) + 1 , ( screenH * 0.6875 ) + 1 , tocolor ( 0 , 0 , 0 , Alpha ), 1.14 , "default-bold" , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Wyjmij pojazd" , screenW * 0.3382 , screenH * 0.6419 , screenW * 0.4422 , screenH * 0.6875 , tocolor ( 2 , 44 , 138 , Alpha ), 1.14 , "default-bold" , "center" , "center" , false , false , false , false , false )
else
dxDrawImage ( screenW * 0.3053 , screenH * 0.5768 , screenW * 0.1794 , screenH * 0.1693 , "przycisk.png" , 0 , 0 , 0 , tocolor ( r2 , g2 , b2 , 255 ), false )
dxDrawText ( "Wyjmij pojazd" , ( screenW * 0.3382 ) + 1 , ( screenH * 0.6419 ) + 1 , ( screenW * 0.4422 ) + 1 , ( screenH * 0.6875 ) + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1.09 , "default-bold" , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Wyjmij pojazd" , screenW * 0.3382 , screenH * 0.6419 , screenW * 0.4422 , screenH * 0.6875 , tocolor ( 0 , 255 , 0 , 254 ), 1.09 , "default-bold" , "center" , "center" , false , false , false , false , false )
end
if not cursorPosition ( screenW * 0.5688 , screenH * 0.6432 , screenW * 0.1054 , screenH * 0.0469 ) then -- Wyjmij
dxDrawImage ( screenW * 0.5351 , screenH * 0.5768 , screenW * 0.1794 , screenH * 0.1693 , "przycisk.png" , 0 , 0 , 0 , tocolor ( 255 , 255 , 255 , Alpha ), false )
dxDrawText ( "Zamknij okno" , ( screenW * 0.5688 ) + 1 , ( screenH * 0.6432 ) + 1 , ( screenW * 0.6728 ) + 1 , ( screenH * 0.6888 ) + 1 , tocolor ( 0 , 0 , 0 , Alpha ), 1.14 , "default-bold" , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Zamknij okno" , screenW * 0.5688 , screenH * 0.6432 , screenW * 0.6728 , screenH * 0.6888 , tocolor ( 2 , 44 , 138 , Alpha ), 1.14 , "default-bold" , "center" , "center" , false , false , false , false , false )
else
dxDrawImage ( screenW * 0.5351 , screenH * 0.5768 , screenW * 0.1794 , screenH * 0.1693 , "przycisk.png" , 0 , 0 , 0 , tocolor ( r2 , g2 , b2 , 255 ), false )
dxDrawText ( "Zamknij okno" , ( screenW * 0.5688 ) + 1 , ( screenH * 0.6432 ) + 1 , ( screenW * 0.6728 ) + 1 , ( screenH * 0.6888 ) + 1 , tocolor ( 0 , 0 , 0 , 255 ), 1.09 , "default-bold" , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Zamknij okno" , screenW * 0.5688 , screenH * 0.6432 , screenW * 0.6728 , screenH * 0.6888 , tocolor ( 0 , 255 , 0 , 254 ), 1.09 , "default-bold" , "center" , "center" , false , false , false , false , false )
end
dxDrawText ( "Przechowalnia Pojazd?w!" , ( screenW * 0.3375 ) + 1 , ( screenH * 0.3503 ) + 1 , ( screenW * 0.6728 ) + 1 , ( screenH * 0.3893 ) + 1 , tocolor ( 0 , 0 , 0 , Alpha ), 1.50 , "default-bold" , "center" , "center" , false , false , false , false , false )
dxDrawText ( "Przechowalnia Pojazd?w!" , screenW * 0.3375 , screenH * 0.3503 , screenW * 0.6728 , screenH * 0.3893 , tocolor ( r , g , b , Alpha ), 1.50 , "default-bold" , "center" , "center" , false , false , false , false , false )
end
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 )
guiGridListSetItemText ( wm . gridlist , row , 3 , v [ "driver" ]: gsub ( "#%x%x%x%x%x%x" , "" ), false , false )
end
end )
addEventHandler ( "onClientMarkerHit" , marker , function( el , md )
if el ~= localPlayer then return end
if isPedInVehicle ( el ) then return end
if guiGetVisible ( wm . gridlist ) == false then
if panel == false then
addEventHandler ( "onClientRender" , root , PrzechoGUI )
czas = getTickCount ()
panel = true
showCursor ( true )
guiSetVisible ( wm . gridlist , true )
triggerServerEvent ( "onParkingGetRekords" , localPlayer )
-- etCameraMatrix (- 2056.26 , 468.77 , 38.49 , - 2048.08 , 467.73 , 35.17 )
end
end
end )
function Przechowyjmij ( button , state )
if panel and button == "left" and state == "down" then
if cursorPosition ( screenW * 0.3367 , screenH * 0.6406 , screenW * 0.1054 , screenH * 0.0469 ) then
local selectedRow = guiGridListGetSelectedItem ( wm . gridlist ) or - 1
if selectedRow < 0 then return end
local vehicles = getElementsWithinColShape ( sphere , "vehicle" )
if #vehicles > 0 then
outputChatBox ( "* Nie ma miejsca aby wyciagnac pojazd!" , 255 , 0 , 0 )
return
end
local id = guiGridListGetItemText ( wm . gridlist , selectedRow , 1 )
guiGridListRemoveRow ( wm . gridlist , selectedRow )
triggerServerEvent ( "onParkingVehicleSpawn" , localPlayer , tonumber ( id ))
end
end
end
addEventHandler ( "onClientClick" , getRootElement (), Przechowyjmij )
function Zamknij ( button , state )
if panel and button == "left" and state == "down" then
if cursorPosition ( screenW * 0.5688 , screenH * 0.6432 , screenW * 0.1054 , screenH * 0.0469 ) then
panel = false
removeEventHandler ( "onClientRender" , root , PrzechoGUI )
showCursor ( false )
guiSetVisible ( wm . gridlist , false )
end
end
end
addEventHandler ( "onClientClick" , getRootElement (), Zamknij )
function cursorPosition ( x , y , w , h )
if ( not isCursorShowing ()) then
return false
end
local mx , my = getCursorPosition ()
local fullx , fully = guiGetScreenSize ()
cursorx , cursory = mx * fullx , my * fully
if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
return true
else
return false
end
end
function filedelet ()
if fileExists ( "c_parking.lua" ) then
fileDelete ( "c_parking.lua" )
end
end
addEventHandler ( "onClientResourceStart" , getResourceRootElement ( getThisResource ()), filedelet )
addEventHandler ( "onClientPlayerQuit" , getRootElement (), filedelet )
addEventHandler ( "onClientPlayerJoin" , getRootElement (), filedelet )
s_parking.lua
local marker = createMarker (- 1787.69 , 785.37 , 24.89 - 5.0 , "cylinder" , 5 , 143 , 0 , 255 , 100 )
createBlip (- 1800.91 , 802.22 , 24.89 , 35 , 2 , 0 , 0 , 0 , 0 , 0 , 250 )
local mdestroy = createMarker (- 1787.59 , 801.46 , 24.89 - 5.0 , "cylinder" , 5 , 143 , 0 , 255 , 100 )
local t = createElement ( "text" )
setElementData ( t , "scale" , 1 )
setElementData ( t , "name" , "Pozostawianie pojazd?w" )
setElementPosition ( t ,- 1787.59 , 801.46 , 24.89 + 1.3 )
local tt = createElement ( "text" )
setElementData ( tt , "scale" , 1 )
setElementData ( tt , "name" , "Odbi?r pojazd?w" )
setElementPosition ( tt ,- 1787.69 , 785.37 , 24.89 + 1.3 )
addEvent ( "onParkingGetRekords" , true )
addEventHandler ( "onParkingGetRekords" , root , function()
local uid = getElementData ( source , "player:uid" )
if not uid then return end
local org = getElementData ( source , "player:organization" )
local result = exports [ "ogrpg-db" ]: dbGet ( "SELECT * FROM ogrpg_vehicles WHERE (ownedPlayer=? OR ownedGroup=?) AND parking=1" , uid , org or "Brak" )
if #result > 0 then
triggerClientEvent ( source , "onParkingGetVehicles" , source , result )
end
end )
addEventHandler ( "onMarkerHit" , mdestroy , function( el , md )
if getElementType ( el ) == "player" then
local veh = getPedOccupiedVehicle ( el )
if not veh then return end
if getVehicleController ( veh ) ~= el then return end
local id = getElementData ( veh , "vehicle:id" )
if not id then return end
if isTimer ( timeroddania ) then return end
setElementFrozen ( veh , true )
outputChatBox ( "* Trwa oddawanie pojazdu do przechowalni..." , el , 255 , 255 , 255 , true )
toggleControl ( el , "enter_exit" , false )
timeroddania = setTimer (function()
setElementFrozen ( veh , false )
local id = getElementData ( veh , "vehicle:id" )
if not id then return end
exports [ "ogrpg-vehicles" ]: onSaveVehicle ( veh )
destroyElement ( veh )
exports [ "ogrpg-db" ]: dbSet ( "UPDATE ogrpg_vehicles SET parking=1 WHERE id=?" , id )
toggleControl ( el , "enter_exit" , true )
outputChatBox ( "* Pomy?lnie zapisano pojazd." , el , 255 , 255 , 255 , true )
end , 3000 , 1 )
elseif getElementType ( el ) == "vehicle" then
local peds = getVehicleOccupants ( el )
if #peds > 0 then return end
local id = getElementData ( el , "vehicle:id" )
if not id then return end
if isTimer ( timeroddania ) then return end
timeroddania = setTimer (function()
setElementFrozen ( el , false )
local id = getElementData ( el , "vehicle:id" )
if not id then return end
exports [ "ogrpg-vehicles" ]: onSaveVehicle ( el )
destroyElement ( el )
exports [ "ogrpg-db" ]: dbSet ( "UPDATE ogrpg_vehicles SET parking=1 WHERE id=?" , id )
end , 3000 , 1 )
setElementFrozen ( el , true )
setVehicleLocked ( el , true )
end
end )
addEvent ( "onParkingVehicleSpawn" , true )
addEventHandler ( "onParkingVehicleSpawn" , root , function( id )
if not id then return end
local spawn = exports [ "ogrpg-vehicles" ]: onRespawnVehicles ( _ , id ,{- 1787.88 , 785.32 , 24.67 , 0.0 , 360.0 , 89.5 })
outputChatBox ( "* Pomy?lnie przywr?cono pojazd." , source , 255 , 255 , 255 , true )
if spawn then
end
end )
Ostatnio zmieniony przez marcin778 2017-06-29, 13:42, w całości zmieniany 1 raz