Gravgor
Wiek: 22 Na forum: 3619 dni Posty: 380
Nick w MP: 1944
Piwa : 702
Mam taki blad
http://imgur.com/a/DP14n
Kod
c.lua
local screenW , screenH = guiGetScreenSize ()
foNte = dxCreateFont ( "font.ttf" , 12 ) or "defaul-bold"
foNte2 = dxCreateFont ( "SLANT.ttf" , 15 ) or "defaul-bold"
foNte3 = dxCreateFont ( "SLANT.ttf" , 13 ) or "defaul-bold"
foNte4 = dxCreateFont ( "font.ttf" , 9 ) or "defaul-bold"
function showDxGUIWarsztatTuning ()
local r1 , g1 , b1 = interpolateBetween ( 33 , 33 , 33 , 0 , 255 , 0 ,( getTickCount ()- GD1 )/ 1500 , "Linear" )
local r2 , g2 , b2 = interpolateBetween ( 33 , 33 , 33 , 0 , 255 , 0 ,( getTickCount ()- GD2 )/ 1500 , "Linear" )
rectangleCircle2 ( screenW * 0.3039 , screenH * 0.2917 , screenW * 0.3922 , screenH * 0.4383 , tocolor ( 0 , 0 , 0 , 199 ), tocolor ( 0 , 0 , 0 , 199 ))
rectangleCircle ( screenW * 0.2883 , screenH * 0.2283 , screenW * 0.4234 , screenH * 0.0633 , tocolor ( 255 , 0 , 40 , 252 ), tocolor ( 255 , 0 , 40 , 252 ))
dxDrawBorderedText ( "Montowanie Tuningu" , screenW * 0.2875 , screenH * 0.2283 , screenW * 0.7117 , screenH * 0.2917 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , foNte2 , "center" , "center" , false , false , false , false , false )
if not cursorPosition ( screenW * 0.6828 , screenH * 0.2283 , screenW * 0.0289 , screenH * 0.0633 ) then -- close
rectangleCircle ( screenW * 0.6828 , screenH * 0.2283 , screenW * 0.0289 , screenH * 0.0633 , tocolor ( 33 , 33 , 33 , 255 ), tocolor ( 33 , 33 , 33 , 255 ), true )
GD1 = getTickCount ()
else
rectangleCircle ( screenW * 0.6828 , screenH * 0.2283 , screenW * 0.0289 , screenH * 0.0633 , tocolor ( r1 , g1 , b1 , 255 ), tocolor ( r1 , g1 , b1 , 255 ), true )
end
if not cursorPosition ( screenW * 0.3508 , screenH * 0.6200 , screenW * 0.1508 , screenH * 0.0767 ) then -- zamontuj
rectangleCircle ( screenW * 0.3508 , screenH * 0.6200 , screenW * 0.1508 , screenH * 0.0767 , tocolor ( 33 , 33 , 33 , 255 ), tocolor ( 33 , 33 , 33 , 255 ), true )
GD2 = getTickCount ()
else
rectangleCircle ( screenW * 0.3508 , screenH * 0.6200 , screenW * 0.1508 , screenH * 0.0767 , tocolor ( r2 , g2 , b2 , 255 ), tocolor ( r2 , g2 , b2 , 255 ), true )
end
dxDrawBorderedText ( "Zamontuj" , screenW * 0.3500 , screenH * 0.6200 , screenW * 0.5016 , screenH * 0.6967 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , foNte3 , "center" , "center" , false , false , false , false , false )
dxDrawBorderedText ( "Koszt tuningu: #00DD00" .. kosztTuningu .. " PLN" , screenW * 0.3039 , screenH * 0.5067 , screenW * 0.5437 , screenH * 0.5967 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , foNte , "center" , "center" , false , false , false , false , false )
dxDrawBorderedText ( "Wybierz kategorie a nast?pnie cz??? jak?\nchcesz zamontowa? do pojazdu. Mo?esz zrobi?\npodgl?d cz?s?i na pojezdzie naciskaj??\n1 raz na dan? cze??." , screenW * 0.3039 , screenH * 0.2933 , screenW * 0.5430 , screenH * 0.5067 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , foNte4 , "center" , "center" , false , false , false , false , false )
dxDrawBorderedText ( "✖" , screenW * 0.6828 , screenH * 0.2283 , screenW * 0.7117 , screenH * 0.2917 , tocolor ( 255 , 255 , 255 , 255 ), 1.00 , foNte , "center" , "center" , false , false , false , false , false )
end
gui_tuning = {}
gui_tuning [ 3 ] = guiCreateGridList ( 0.54 , 0.31 , 0.15 , 0.41 , true )
guiGridListSetSortingEnabled ( gui_tuning [ 3 ], false )
gui_tuning [ 4 ] = guiGridListAddColumn ( gui_tuning [ 3 ], "Kategoria" , 0.9 )
gui_tuning [ 5 ] = guiCreateGridList ( 0.54 , 0.31 , 0.15 , 0.41 , true )
guiGridListSetSortingEnabled ( gui_tuning [ 5 ], false )
gui_tuning [ 6 ] = guiGridListAddColumn ( gui_tuning [ 5 ], "Cze??" , 0.5 )
gui_tuning [ 7 ] = guiGridListAddColumn ( gui_tuning [ 5 ], "Koszt" , 0.4 )
guiSetVisible ( gui_tuning [ 5 ], false )
guiSetVisible ( gui_tuning [ 3 ], false )
function showGUIWarsztatTuning ( veh )
guiGridListClear ( gui_tuning [ 3 ])
saveVeh = veh -- zapis pojazdu
tuning = {} -- zapis kategorii ktore mozemy zainstalowac w naszym pojezdzie
saveTuning = getVehicleUpgrades ( veh ) -- zapis aktualnego tuningu
dodane = {} -- zapis czesi ktore dodalismy
local upgrades = getVehicleCompatibleUpgrades ( veh )
for k , v in ipairs ( upgrades ) do
local slot = getVehicleUpgradeSlotName ( v )
if not tuning [ slot ] then
tuning [ slot ] = {}
local row = guiGridListAddRow ( gui_tuning [ 3 ])
guiGridListSetItemText ( gui_tuning [ 3 ], row , gui_tuning [ 4 ], slot , false , false )
end
table . insert ( tuning [ slot ], v )
end
-- //
aktualizujCene ()
guiSetVisible ( gui_tuning [ 3 ], true )
guiSetVisible ( gui_tuning [ 5 ], false )
showCursor ( true )
panelTuning = true
end
function onKategoriaTuningClick ()
local kategoria = guiGridListGetSelectedItem ( gui_tuning [ 3 ])
if ( kategoria ~= - 1 ) then
local kat = guiGridListGetItemText ( gui_tuning [ 3 ], kategoria , 1 )
wybKatTuningu = kategoria + 1
-- pokazuje mozliwe czesci
guiGridListClear ( gui_tuning [ 5 ])
local row = guiGridListAddRow ( gui_tuning [ 5 ])
guiGridListSetItemText ( gui_tuning [ 5 ], row , gui_tuning [ 6 ], "..." , false , false )
guiGridListSetItemText ( gui_tuning [ 5 ], row , gui_tuning [ 7 ], "" , false , false )
for i , v in pairs ( tuning [ kat ]) do
local v = tonumber ( v )
local row = guiGridListAddRow ( gui_tuning [ 5 ])
local nazwa = saveUpgr [ v ][ 2 ] or v
local cena = saveUpgr [ v ][ 3 ] or 1000
guiGridListSetItemText ( gui_tuning [ 5 ], row , gui_tuning [ 6 ], nazwa , false , false )
guiGridListSetItemData ( gui_tuning [ 5 ], row , gui_tuning [ 6 ], v )
guiGridListSetItemText ( gui_tuning [ 5 ], row , gui_tuning [ 7 ], cena .. " PLN" , false , false )
if dodane [ wybKatTuningu ] then
if tonumber ( dodane [ wybKatTuningu ][ 2 ]) == tonumber ( v ) then
guiGridListSetItemColor ( gui_tuning [ 5 ], row , 1 , 230 , 20 , 20 )
end
end
if isElement ( saveVeh ) then
local upgrades = getVehicleUpgrades ( saveVeh )
for kk , vv in ipairs ( upgrades ) do
if tonumber ( v ) == tonumber ( vv ) then
dodane [ wybKatTuningu ] = { row , vv }
guiGridListSetItemColor ( gui_tuning [ 5 ], row , 1 , 230 , 20 , 20 )
end
end
end
end
-- chowam stare , pokazuje nowe
guiSetVisible ( gui_tuning [ 3 ], false )
guiSetVisible ( gui_tuning [ 5 ], true )
end
end
addEventHandler ( "onClientGUIDoubleClick" , gui_tuning [ 3 ], onKategoriaTuningClick )
function onCzescTuningClick ()
local czesc = guiGridListGetSelectedItem ( gui_tuning [ 5 ])
if ( czesc ~= - 1 ) then
local nazwa = guiGridListGetItemText ( gui_tuning [ 5 ], czesc , 1 )
if nazwa == "..." then -- powrot do listy
guiSetVisible ( gui_tuning [ 3 ], true )
guiSetVisible ( gui_tuning [ 5 ], false )
else -- czesc
local id_czesc = guiGridListGetItemData ( gui_tuning [ 5 ], czesc , gui_tuning [ 6 ])
local r , g , b = guiGridListGetItemColor ( gui_tuning [ 5 ], czesc , 1 )
if ( r == 255 and g == 255 and b == 255 ) then -- montujemy czesc
-- usuwamy ew . inna zaznaczona wczesniej
if dodane [ wybKatTuningu ] then
local row = dodane [ wybKatTuningu ][ 1 ]
local czesc = dodane [ wybKatTuningu ][ 2 ]
triggerServerEvent ( "removeUpgrade" , localPlayer , czesc )
guiGridListSetItemColor ( gui_tuning [ 5 ], row , 1 , 255 , 255 , 255 )
end
-- dodajemy czesc
triggerServerEvent ( "addUpgrade" , localPlayer , id_czesc )
guiGridListSetItemColor ( gui_tuning [ 5 ], czesc , 1 , 230 , 20 , 20 )
dodane [ wybKatTuningu ] = { czesc , id_czesc }
else -- usuwamy czesc
triggerServerEvent ( "removeUpgrade" , localPlayer , id_czesc )
guiGridListSetItemColor ( gui_tuning [ 5 ], czesc , 1 , 255 , 255 , 255 )
dodane [ wybKatTuningu ] = nil
end
aktualizujCene ()
end
end
end
addEventHandler ( "onClientGUIDoubleClick" , gui_tuning [ 5 ], onCzescTuningClick )
function aktualizujCene ()
cena = 0
for i , v in pairs ( dodane ) do
local id_czesci = tonumber ( v [ 2 ])
local koszt = saveUpgr [ id_czesci ][ 3 ]
cena = cena + koszt
end
kosztTuningu = "" .. cena .. ""
end
function onWarsztatTuningZamknij ( button , state )
if panelTuning and button == "left" and state == "down" then
if cursorPosition ( screenW * 0.6828 , screenH * 0.2283 , screenW * 0.0289 , screenH * 0.0633 ) then
triggerServerEvent ( "removeUpgradeOnClose" , localPlayer )
triggerServerEvent ( "addUpgradeOnClose" , localPlayer )
guiSetVisible ( gui_tuning [ 3 ], false )
guiSetVisible ( gui_tuning [ 5 ], false )
showCursor ( false )
panelTuning = false
wyczyszDane ()
removeEventHandler ( "onClientRender" , root , showDxGUIWarsztatTuning )
end
end
end
addEventHandler ( "onClientClick" , getRootElement (), onWarsztatTuningZamknij )
function onWarsztatTuningZamontuj ( button , state )
if panelTuning and button == "left" and state == "down" then
if cursorPosition ( screenW * 0.3508 , screenH * 0.6200 , screenW * 0.1508 , screenH * 0.0767 ) then
if cena > 0 then -- wybralismy chociaz jedna czesc
local kasa = getElementData ( localPlayer , "user:money" )
if tonumber ( kasa ) >= cena then
triggerServerEvent ( "zabierzPieniadzeZaTuning" , getLocalPlayer (), cena )
guiSetVisible ( gui_tuning [ 3 ], false )
guiSetVisible ( gui_tuning [ 5 ], false )
panelTuning = false
removeEventHandler ( "onClientRender" , root , showDxGUIWarsztatTuning )
showCursor ( false )
wyczyszDane ()
else
outputChatBox ( "Nie masz wystarczaj?co pieni?dzy na zamontowanie tych cze?ci!" , 255 , 255 , 255 , true )
end
else
outputChatBox ( "Nie wybra?e? ?adnej cz??ci." , 255 , 255 , 255 , true )
end
end
end
end
addEventHandler ( "onClientClick" , getRootElement (), onWarsztatTuningZamontuj )
function wyczyszDane ()
saveVeh = nil
tuning = nil
saveTuning = nil
dodane = nil
saveUpgr = nil
cena = nil
triggerServerEvent ( "clearDataTuning" , getLocalPlayer ())
end
addEvent ( "pokazGUITuningu" , true )
addEventHandler ( "pokazGUITuningu" , getRootElement (),
function( pojazd , upgr )
saveUpgr = {}
guiSetVisible ( gui_tuning [ 3 ], true )
showGUIWarsztatTuning ( pojazd )
addEventHandler ( "onClientRender" , root , showDxGUIWarsztatTuning )
GD1 = getTickCount ()
GD2 = getTickCount ()
for i , v in pairs ( upgr ) do
local item = v [ 1 ]
local name = v [ 2 ]
local price = v [ 3 ]
saveUpgr [ tonumber ( item )] = { item , name , price }
end
end )
addEvent ( "zamknijGUITuninguTune" , true )
addEventHandler ( "zamknijGUITuninguTune" , getRootElement (),
function()
guiSetVisible ( gui_tuning [ 3 ], false )
guiSetVisible ( gui_tuning [ 5 ], false )
panelTuning = false
removeEventHandler ( "onClientRender" , root , showDxGUIWarsztatTuning )
showCursor ( false )
end )
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 rectangleCircle2 ( hou_x , hou_y , hou_sx , hou_sy , color , color2 )
exports . IL_DxBlure : dxDrawBluredRectangle ( hou_x + 5 , hou_y , hou_sx - 10 , 1 , tocolor ( 255 , 255 , 255 , 255 ))
exports . IL_DxBlure : dxDrawBluredRectangle ( hou_x + 3 , hou_y + 1 , hou_sx - 6 , 1 , tocolor ( 255 , 255 , 255 , 255 ))
exports . IL_DxBlure : dxDrawBluredRectangle ( hou_x + 2 , hou_y + 2 , hou_sx - 4 , 1 , tocolor ( 255 , 255 , 255 , 255 ))
exports . IL_DxBlure : dxDrawBluredRectangle ( hou_x + 1 , hou_y + 3 , hou_sx - 2 , 2 , tocolor ( 255 , 255 , 255 , 255 ))
exports . IL_DxBlure : dxDrawBluredRectangle ( hou_x , hou_y + 5 , hou_sx , 1 , tocolor ( 255 , 255 , 255 , 255 ))
exports . IL_DxBlure : dxDrawBluredRectangle ( hou_x , hou_y + 6 , hou_sx , hou_sy - 11 , tocolor ( 255 , 255 , 255 , 255 ))
exports . IL_DxBlure : dxDrawBluredRectangle ( hou_x + 5 , hou_y + hou_sy , hou_sx - 10 , 1 , tocolor ( 255 , 255 , 255 , 255 ))
exports . IL_DxBlure : dxDrawBluredRectangle ( hou_x + 3 , hou_y + hou_sy - 1 , hou_sx - 6 , 1 , tocolor ( 255 , 255 , 255 , 255 ))
exports . IL_DxBlure : dxDrawBluredRectangle ( hou_x + 2 , hou_y + hou_sy - 2 , hou_sx - 4 , 1 , tocolor ( 255 , 255 , 255 , 255 ))
exports . IL_DxBlure : dxDrawBluredRectangle ( hou_x + 1 , hou_y + hou_sy - 4 , hou_sx - 2 , 2 , tocolor ( 255 , 255 , 255 , 255 ))
exports . IL_DxBlure : dxDrawBluredRectangle ( hou_x , hou_y + hou_sy - 5 , hou_sx , 1 , tocolor ( 255 , 255 , 255 , 255 ))
dxDrawRectangle ( hou_x + 5 , hou_y , hou_sx - 10 , 1 , color )
dxDrawRectangle ( hou_x + 3 , hou_y + 1 , hou_sx - 6 , 1 , color )
dxDrawRectangle ( hou_x + 2 , hou_y + 2 , hou_sx - 4 , 1 , color )
dxDrawRectangle ( hou_x + 1 , hou_y + 3 , hou_sx - 2 , 2 , color )
dxDrawRectangle ( hou_x , hou_y + 5 , hou_sx , 1 , color )
dxDrawRectangle ( hou_x , hou_y + 6 , hou_sx , hou_sy - 11 , color )
dxDrawRectangle ( hou_x + 5 , hou_y + hou_sy , hou_sx - 10 , 1 , color )
dxDrawRectangle ( hou_x + 3 , hou_y + hou_sy - 1 , hou_sx - 6 , 1 , color )
dxDrawRectangle ( hou_x + 2 , hou_y + hou_sy - 2 , hou_sx - 4 , 1 , color )
dxDrawRectangle ( hou_x + 1 , hou_y + hou_sy - 4 , hou_sx - 2 , 2 , color )
dxDrawRectangle ( hou_x , hou_y + hou_sy - 5 , hou_sx , 1 , color )
dxDrawRectangle ( hou_x + 5 , hou_y , hou_sx - 10 , 1 , color2 )
dxDrawRectangle ( hou_x + 3 , hou_y + 1 , 2 , 1 , color2 )
dxDrawRectangle ( hou_x + 2 , hou_y + 2 , 1 , 1 , color2 )
dxDrawRectangle ( hou_x + 1 , hou_y + 3 , 1 , 2 , color2 )
dxDrawRectangle ( hou_x , hou_y + 5 , 1 , 1 , color2 )
dxDrawRectangle ( hou_x , hou_y + 6 , 1 , hou_sy - 11 , color2 )
dxDrawRectangle ( hou_x + hou_sx - 1 , hou_y + 6 , 1 , hou_sy - 11 , color2 )
dxDrawRectangle ( hou_x + hou_sx - 5 , hou_y + 1 , 2 , 1 , color2 )
dxDrawRectangle ( hou_x + hou_sx - 3 , hou_y + 2 , 1 , 1 , color2 )
dxDrawRectangle ( hou_x + hou_sx - 2 , hou_y + 3 , 1 , 2 , color2 )
dxDrawRectangle ( hou_x + hou_sx - 1 , hou_y + 5 , 1 , 1 , color2 )
dxDrawRectangle ( hou_x + 5 , hou_y + hou_sy , hou_sx - 10 , 1 , color2 )
dxDrawRectangle ( hou_x + 3 , hou_y + hou_sy - 1 , 2 , 1 , color2 )
dxDrawRectangle ( hou_x + 2 , hou_y + hou_sy - 2 , 1 , 1 , color2 )
dxDrawRectangle ( hou_x + 1 , hou_y + hou_sy - 4 , 1 , 2 , color2 )
dxDrawRectangle ( hou_x , hou_y + hou_sy - 5 , 1 , 1 , color2 )
dxDrawRectangle ( hou_x + hou_sx - 5 , hou_y + hou_sy - 1 , 2 , 1 , color2 )
dxDrawRectangle ( hou_x + hou_sx - 3 , hou_y + hou_sy - 2 , 1 , 1 , color2 )
dxDrawRectangle ( hou_x + hou_sx - 2 , hou_y + hou_sy - 4 , 1 , 2 , color2 )
dxDrawRectangle ( hou_x + hou_sx - 1 , hou_y + hou_sy - 5 , 1 , 1 , color2 )
end
function rectangleCircle ( hou_x , hou_y , hou_sx , hou_sy , color , color2 )
dxDrawRectangle ( hou_x + 5 , hou_y , hou_sx - 10 , 1 , color )
dxDrawRectangle ( hou_x + 3 , hou_y + 1 , hou_sx - 6 , 1 , color )
dxDrawRectangle ( hou_x + 2 , hou_y + 2 , hou_sx - 4 , 1 , color )
dxDrawRectangle ( hou_x + 1 , hou_y + 3 , hou_sx - 2 , 2 , color )
dxDrawRectangle ( hou_x , hou_y + 5 , hou_sx , 1 , color )
dxDrawRectangle ( hou_x , hou_y + 6 , hou_sx , hou_sy - 11 , color )
dxDrawRectangle ( hou_x + 5 , hou_y + hou_sy , hou_sx - 10 , 1 , color )
dxDrawRectangle ( hou_x + 3 , hou_y + hou_sy - 1 , hou_sx - 6 , 1 , color )
dxDrawRectangle ( hou_x + 2 , hou_y + hou_sy - 2 , hou_sx - 4 , 1 , color )
dxDrawRectangle ( hou_x + 1 , hou_y + hou_sy - 4 , hou_sx - 2 , 2 , color )
dxDrawRectangle ( hou_x , hou_y + hou_sy - 5 , hou_sx , 1 , color )
dxDrawRectangle ( hou_x + 5 , hou_y , hou_sx - 10 , 1 , color2 )
dxDrawRectangle ( hou_x + 3 , hou_y + 1 , 2 , 1 , color2 )
dxDrawRectangle ( hou_x + 2 , hou_y + 2 , 1 , 1 , color2 )
dxDrawRectangle ( hou_x + 1 , hou_y + 3 , 1 , 2 , color2 )
dxDrawRectangle ( hou_x , hou_y + 5 , 1 , 1 , color2 )
dxDrawRectangle ( hou_x , hou_y + 6 , 1 , hou_sy - 11 , color2 )
dxDrawRectangle ( hou_x + hou_sx - 1 , hou_y + 6 , 1 , hou_sy - 11 , color2 )
dxDrawRectangle ( hou_x + hou_sx - 5 , hou_y + 1 , 2 , 1 , color2 )
dxDrawRectangle ( hou_x + hou_sx - 3 , hou_y + 2 , 1 , 1 , color2 )
dxDrawRectangle ( hou_x + hou_sx - 2 , hou_y + 3 , 1 , 2 , color2 )
dxDrawRectangle ( hou_x + hou_sx - 1 , hou_y + 5 , 1 , 1 , color2 )
dxDrawRectangle ( hou_x + 5 , hou_y + hou_sy , hou_sx - 10 , 1 , color2 )
dxDrawRectangle ( hou_x + 3 , hou_y + hou_sy - 1 , 2 , 1 , color2 )
dxDrawRectangle ( hou_x + 2 , hou_y + hou_sy - 2 , 1 , 1 , color2 )
dxDrawRectangle ( hou_x + 1 , hou_y + hou_sy - 4 , 1 , 2 , color2 )
dxDrawRectangle ( hou_x , hou_y + hou_sy - 5 , 1 , 1 , color2 )
dxDrawRectangle ( hou_x + hou_sx - 5 , hou_y + hou_sy - 1 , 2 , 1 , color2 )
dxDrawRectangle ( hou_x + hou_sx - 3 , hou_y + hou_sy - 2 , 1 , 1 , color2 )
dxDrawRectangle ( hou_x + hou_sx - 2 , hou_y + hou_sy - 4 , 1 , 2 , color2 )
dxDrawRectangle ( hou_x + hou_sx - 1 , hou_y + hou_sy - 5 , 1 , 1 , color2 )
end
function dxDrawBorderedText ( text , x , y , w , h , color , scale , font , alignX , alignY , clip , wordBreak , postGUI )
dxDrawText ( text : gsub ( '#%x%x%x%x%x%x' , '' ), x - 1 , y - 1 , w - 1 , h - 1 , tocolor ( 0 , 0 , 0 , 255 ), scale , font , alignX , alignY , clip , wordBreak , false )
dxDrawText ( text : gsub ( '#%x%x%x%x%x%x' , '' ), x + 1 , y - 1 , w + 1 , h - 1 , tocolor ( 0 , 0 , 0 , 255 ), scale , font , alignX , alignY , clip , wordBreak , false )
dxDrawText ( text : gsub ( '#%x%x%x%x%x%x' , '' ), x - 1 , y + 1 , w - 1 , h + 1 , tocolor ( 0 , 0 , 0 , 255 ), scale , font , alignX , alignY , clip , wordBreak , false )
dxDrawText ( text : gsub ( '#%x%x%x%x%x%x' , '' ), x + 1 , y + 1 , w + 1 , h + 1 , tocolor ( 0 , 0 , 0 , 255 ), scale , font , alignX , alignY , clip , wordBreak , false )
dxDrawText ( text : gsub ( '#%x%x%x%x%x%x' , '' ), x - 1 , y , w - 1 , h , tocolor ( 0 , 0 , 0 , 255 ), scale , font , alignX , alignY , clip , wordBreak , false )
dxDrawText ( text : gsub ( '#%x%x%x%x%x%x' , '' ), x + 1 , y , w + 1 , h , tocolor ( 0 , 0 , 0 , 255 ), scale , font , alignX , alignY , clip , wordBreak , false )
dxDrawText ( text : gsub ( '#%x%x%x%x%x%x' , '' ), x , y - 1 , w , h - 1 , tocolor ( 0 , 0 , 0 , 255 ), scale , font , alignX , alignY , clip , wordBreak , false )
dxDrawText ( text : gsub ( '#%x%x%x%x%x%x' , '' ), x , y + 1 , w , h + 1 , tocolor ( 0 , 0 , 0 , 255 ), scale , font , alignX , alignY , clip , wordBreak , false )
dxDrawText ( text , x , y , w , h , color , scale , font , alignX , alignY , clip , wordBreak , postGUI , true )
end
s.lua
vehInCol = {}
tuningTable = {}
local stanowiskaTunera = {
stanowiska ={
mpos ={ 1936.0498046875 , - 1984.4765625 , 13.553544044495 , 0 },
cpos ={ 1934.5571 , - 1986.1259 , 12.553544 , 10 , 0 , 2 },
job_id = "Tuner LS" ,
},
}
for i , v in pairs ( stanowiskaTunera ) do
v . cuboid = createColSphere ( unpack ( v . cpos ))
v . marker = createMarker ( v . mpos [ 1 ], v . mpos [ 2 ], v . mpos [ 3 ], "cylinder" , 1 , 66 , 119 , 244 , 255 )
setElementData ( v . marker , "marker:duty" , v . job_id )
setElementData ( v . marker , "marker:cuboid" , v . cuboid )
addEventHandler ( "onColShapeLeave" , v . cuboid , onColLeave )
t = createElement ( "text" )
setElementData ( t , "text" , v . text )
setElementPosition ( t , v . mpos [ 1 ], v . mpos [ 2 ], v . mpos [ 3 ]+ 0.6 )
addEventHandler ( "onMarkerHit" , v . marker , function( el , md )
if getElementType ( el )~= "player" then return end
local cs = getElementData ( source , "marker:cuboid" )
if not cs then return end
local job = getElementData ( source , "marker:duty" )
local ljob = getElementData ( el , "player:duty" )
local veh = getPedOccupiedVehicle ( el )
if not veh then
--[[
if job ~= ljob then
outputChatBox ( " Nie jeste? zatrudniony w tym warsztacie." , el , 255 , 0 , 0 )
return
end
--]]
local vehicles = getElementsWithinColShape ( cs , "vehicle" )
if #vehicles < 1 then
outputChatBox ( " Na stanowisku monta?u nie ma ?adnego pojazdu." , el , 255 , 0 , 0 )
return
end
if #vehicles > 1 then
outputChatBox ( " Na stanowisku monta?u jest zbyt du?o pojazd?w." , el , 255 , 0 , 0 )
return
end
if getElementHealth ( vehicles [ 1 ]) < 900 then
outputChatBox ( " Pojazd jest zbyt uszkodzony aby zamontowa? ?wiat?a." , el , 255 , 0 , 0 )
return
end
if not tuningTable [ el ] then
local veh = vehicles [ 1 ]
local aktualnyTuning = getVehicleUpgrades ( veh )
tuningTable [ el ] = { veh , aktualnyTuning }
triggerClientEvent ( el , "showDxGUIWarsztatTuning" , root , veh , upgradesVeh )
setElementData ( el , "warsztat" , true )
vehInCol = {}
vehInCol [ veh ] = el
end
end
end )
end
function onColLeave ( hitElement )
if getElementType ( hitElement ) == "pojazd" then
local player = vehInCol [ hitElement ]
if player then
if isElement ( player ) then
removeUpgradeOnClose ( player )
addUpgradeOnClose ( player )
clearData ( player )
triggerClientEvent ( player , "zamknijGUITuninguTune" , root )
end
end
vehInCol [ hitElement ] = nil
end
end
addEvent ( "zabierzPieniadzeZaTuning" , true )
addEventHandler ( "zabierzPieniadzeZaTuning" , getRootElement (),
function( cena )
local kasa = getElementData ( source , "user:money" )
setElementData ( source , "user:money" , kasa - cena )
outputChatBox ( "* Zainstalowa?e? nowe cze?ci w poje?dzie, cena " .. cena .. " $." , source , 255 , 255 , 255 , true )
end )
--[[
dodaje czesc do pojazdu
--]]
function addUpgrade ( czesc )
local veh = tuningTable [ source ][ 1 ]
if not isElement ( veh ) then
return false
end
addVehicleUpgrade ( veh , czesc )
end
addEvent ( "addUpgrade" , true )
addEventHandler ( "addUpgrade" , getRootElement (), addUpgrade )
--[[
usuwa dana czesc z pojazdu
--]]
function removeUpgrade ( czesc )
local veh = tuningTable [ source ][ 1 ]
if not isElement ( veh ) then
return false
end
removeVehicleUpgrade ( veh , czesc )
end
addEvent ( "removeUpgrade" , true )
addEventHandler ( "removeUpgrade" , getRootElement (), removeUpgrade )
--[[
usuwa wszystkie zainstalowane przy tym tuningu czesci
--]]
function removeUpgradeOnClose ( player )
local source = player or source
if getElementData ( source , "warsztat" ) then
local veh = tuningTable [ source ][ 1 ]
local upgrades = getVehicleUpgrades ( veh )
for k , v in ipairs ( upgrades ) do
removeVehicleUpgrade ( veh , v )
end
end
end
addEvent ( "removeUpgradeOnClose" , true )
addEventHandler ( "removeUpgradeOnClose" , getRootElement (), removeUpgradeOnClose )
--[[
dodaje stare czesci do pojazdu
--]]
function addUpgradeOnClose ( player )
local source = player or source
if getElementData ( source , "warsztat" ) then
local veh = tuningTable [ source ][ 1 ]
local tuning = tuningTable [ source ][ 2 ]
for i , v in pairs ( tuning ) do
addVehicleUpgrade ( veh , v )
end
end
end
addEvent ( "addUpgradeOnClose" , true )
addEventHandler ( "addUpgradeOnClose" , getRootElement (), addUpgradeOnClose )
--[[
usuwa dane , przywraca tuning przy wyjsciu z serwera / wyjsciu z gui
--]]
function clearData ( player )
local player = source or player
tuningTable [ player ] = nil
removeElementData ( player , "warsztat" )
end
addEvent ( "clearDataTuning" , true )
addEventHandler ( "clearDataTuning" , getRootElement (), clearData )
function przywrocDane ()
removeUpgradeOnClose ( source )
addUpgradeOnClose ( source )
clearData ( source )
resetLight ( source )
end
addEventHandler ( "onPlayerQuit" , getRootElement (), przywrocDane )
-- laduje itemy do tablicy po stronie serwera , potem to przenosze do klienta
upgradesVeh = {}
function loadItems ()
local file_root = xmlLoadFile ( "moditems.xml" )
local sub_node = xmlFindChild ( file_root , "item" , 0 )
i = 0
while sub_node do
item = xmlNodeGetAttribute ( sub_node , "itemid" )
name = xmlNodeGetAttribute ( sub_node , "name" )
price = xmlNodeGetAttribute ( sub_node , "price" )
upgradesVeh [ i ] = { item , name , price }
i = i + 1
sub_node = xmlFindChild ( file_root , "item" , i )
end
i = nil
sub_node = nil
end
addEventHandler ( "onResourceStart" , getResourceRootElement ( getThisResource ()), loadItems )
-- Blip
-- createBlip ( - 1973.97 , 494.09 , 36.76 , 27 )
Podpis
Portfolio marceliborowczak.me