BlackTen
LUA Dev.
Wiek: 28 Na forum: 4329 dni Posty: 698
Piwa : 2080
Witajcie u?ydkownicy forum jak zrobi? CUBOID ?
mam taki sobie skrypt
Server
local strefyLakiernicze = {
LakierniaDoherty = {
cuboid = { 1093.47 , 1767.82 , 10.48 , 359.8 , 0.0 , 268.7 },-- cuboid w ktorym musi znalezc sie pojazd
marker = { 1085.90 , 1764.81 , 10.82 }, -- pozycja markera w ktorym gracz bedzie stal aby w ?? czy ? lakierni ?
dostep_frakcja = 1 , -- id frakcji ktora ma do tego dostep
},
}
for i , v in pairs ( strefyLakiernicze ) do
setGarageOpen ( 21 , true )
l_cuboid = createColCuboid ( unpack ( v . cuboid ))
l_wybor = createMarker ( v . marker [ 1 ], v . marker [ 2 ], v . marker [ 3 ], "cylinder" , 1 , 0 , 0 , 0 , 100 )
setElementData ( l_wybor , "dostep_frakcja" , v . dostep_frakcja )
setElementData ( l_wybor , "lakiernia_cs" , l_cuboid )
end
addEventHandler ( "onMarkerHit" , root , function( el , md )
if getElementData ( source , "lakiernia_cs" ) then
local accName = getAccountName ( getPlayerAccount ( el ))
if isObjectInACLGroup ( "user." .. accName , aclGetGroup ( "Mechanik" )) then
if getElementType ( el ) == "player" then
local pojazd = getElementsWithinColShape ( l_cuboid , "vehicle" )
if #pojazd<1 then
outputChatBox ( "Na stanowisku lakierniczym nie ma ?adnego pojazdu!" , el )
return
end
if #pojazd>1 then
outputChatBox ( "Na stanowisku lakierniczym jest zbyt du?o pojazd?w!" , el )
return
end
for _ , v in ipairs ( getElementsByType ( "vehicle" )) do
if isElementWithinColShape ( v , l_cuboid ) then
if getVehicleOccupant ( v ) then
triggerClientEvent ( el , "onWyborLakieru" , root )
else
outputChatBox ( "Nikogo nie ma w poje?dzie wi?c lakierowanie jest niedost?pne!" , el )
end
end
end
end
else
outputChatBox ( "Nie jeste? zatrudniony jako Mechanik Doherty San Fierro, mo?esz z?o?y? podanie na forum!" , el , 255 , 0 , 0 )
end
end
end )
addEvent ( "onLakierujPojazd" , true )
addEventHandler ( "onLakierujPojazd" , root , function( kolor )
if kolor == 0 then
for _ , v in ipairs ( getElementsByType ( "vehicle" )) do
if isElementWithinColShape ( v , l_cuboid ) then
setGarageOpen ( 21 , false )
playSoundFrontEnd ( v , 46 )
setTimer ( setVehicleColor , 3000 , 1 , v , 255 , 0 , 0 )
setTimer ( setGarageOpen , 4000 , 1 , 21 , true )
end
end
end
if kolor == 1 then
for _ , v in ipairs ( getElementsByType ( "vehicle" )) do
if isElementWithinColShape ( v , l_cuboid ) then
setGarageOpen ( 21 , false )
setTimer ( setVehicleColor , 3000 , 1 , v , 255 , 255 , 0 )
setTimer ( setGarageOpen , 4000 , 1 , 21 , true )
end
end
end
if kolor == 2 then
for _ , v in ipairs ( getElementsByType ( "vehicle" )) do
if isElementWithinColShape ( v , l_cuboid ) then
setGarageOpen ( 21 , false )
setTimer ( setVehicleColor , 3000 , 1 , v , 0 , 39 , 194 )
setTimer ( setGarageOpen , 4000 , 1 , 21 , true )
end
end
end
if kolor == 3 then
for _ , v in ipairs ( getElementsByType ( "vehicle" )) do
if isElementWithinColShape ( v , l_cuboid ) then
setGarageOpen ( 21 , false )
setTimer ( setVehicleColor , 3000 , 1 , v , 0 , 0 , 0 )
setTimer ( setGarageOpen , 4000 , 1 , 21 , true )
end
end
end
if kolor == 4 then
for _ , v in ipairs ( getElementsByType ( "vehicle" )) do
if isElementWithinColShape ( v , l_cuboid ) then
setGarageOpen ( 21 , false )
setTimer ( setVehicleColor , 3000 , 1 , v , 255 , 255 , 255 )
setTimer ( setGarageOpen , 4000 , 1 , 21 , true )
end
end
end
if kolor == 5 then
for _ , v in ipairs ( getElementsByType ( "vehicle" )) do
if isElementWithinColShape ( v , l_cuboid ) then
setGarageOpen ( 21 , false )
setTimer ( setVehicleColor , 3000 , 1 , v , 128 , 128 , 128 )
setTimer ( setGarageOpen , 4000 , 1 , 21 , true )
end
end
end
if kolor == 6 then
for _ , v in ipairs ( getElementsByType ( "vehicle" )) do
if isElementWithinColShape ( v , l_cuboid ) then
setGarageOpen ( 21 , false )
setTimer ( setVehicleColor , 3000 , 1 , v , 150 , 75 , 0 )
setTimer ( setGarageOpen , 4000 , 1 , 21 , true )
end
end
end
if kolor == 7 then
for _ , v in ipairs ( getElementsByType ( "vehicle" )) do
if isElementWithinColShape ( v , l_cuboid ) then
setGarageOpen ( 21 , false )
setTimer ( setVehicleColor , 3000 , 1 , v , 225 , 165 , 0 )
setTimer ( setGarageOpen , 4000 , 1 , 21 , true )
end
end
end
if kolor == 8 then
for _ , v in ipairs ( getElementsByType ( "vehicle" )) do
if isElementWithinColShape ( v , l_cuboid ) then
setGarageOpen ( 21 , false )
setTimer ( setVehicleColor , 3000 , 1 , v , 65 , 105 , 225 )
setTimer ( setGarageOpen , 4000 , 1 , 21 , true )
end
end
end
if kolor == 9 then
for _ , v in ipairs ( getElementsByType ( "vehicle" )) do
if isElementWithinColShape ( v , l_cuboid ) then
setGarageOpen ( 21 , false )
setTimer ( setVehicleColor , 3000 , 1 , v , 255 , 204 , 221 )
setTimer ( setGarageOpen , 4000 , 1 , 21 , true )
end
end
end
if kolor == 10 then
for _ , v in ipairs ( getElementsByType ( "vehicle" )) do
if isElementWithinColShape ( v , l_cuboid ) then
setGarageOpen ( 21 , false )
setTimer ( setVehicleColor , 3000 , 1 , v , 0 , 255 , 0 )
setTimer ( setGarageOpen , 4000 , 1 , 21 , true )
end
end
end
end )
Client
-- local sw , sh = guiGetScreenSize ()
function Skaluj ( sw , sh , sw2 , sh2 )
local sWidth , sHeight = guiGetScreenSize ()
local scaleX , scaleY =( sWidth / 1280 ), ( sHeight / 720 )
return ( sw * scaleX ), ( sh * scaleY ), ( sw2 * scaleX ), ( sh2 * scaleY )
end
x , y , w , h = Skaluj ( 359.8 , 0.0 , 268.7 )
x1 , y1 , w1 , h1 = Skaluj ( 15 , 17 , 942 , 17 )
x2 , y2 , w2 , h2 = Skaluj ( 14 , 34 , 943 , 318 )
x3 , y3 , w3 , h3 = Skaluj ( 14 , 356 , 203 , 42 )
x4 , y4 , w4 , h4 = Skaluj ( 754 , 356 , 203 , 42 )
x5 , y5 , w5 , h5 = Skaluj ( 380 , 357 , 203 , 41 )
function wybierzKolor ()
wl_okno = guiCreateWindow ( x , y , w , h , "WYB?R LAKIERU" , false )
guiWindowSetSizable ( wl_okno , false )
guiSetVisible ( wl_okno , true )
showCursor ( true )
wl_info = guiCreateLabel ( x1 , y1 , w1 , h1 , "" , false , wl_okno )
guiLabelSetHorizontalAlign ( wl_info , "center" , false )
guiLabelSetColor ( wl_info , 254 , 0 , 0 )
wl_gridlist = guiCreateGridList ( x2 , y2 , w2 , h2 , false , wl_okno )
guiGridListAddColumn ( wl_gridlist , "Nazwa koloru" , 0.3 )
guiGridListAddColumn ( wl_gridlist , "Cena" , 0.3 )
guiGridListAddColumn ( wl_gridlist , "Dla pojazd?w" , 0.3 )
for i = 1 , 10 do
guiGridListAddRow ( wl_gridlist )
end
guiGridListSetItemText ( wl_gridlist , 0 , 1 , "Czerwony" , false , false )
guiGridListSetItemText ( wl_gridlist , 0 , 2 , 10 , false , false )
guiGridListSetItemText ( wl_gridlist , 0 , 3 , "Wszystkich" , false , false )
guiGridListSetItemText ( wl_gridlist , 1 , 1 , "Z??ty" , false , false )
guiGridListSetItemText ( wl_gridlist , 1 , 2 , 10 , false , false )
guiGridListSetItemText ( wl_gridlist , 1 , 3 , "Wszystkich" , false , false )
guiGridListSetItemText ( wl_gridlist , 2 , 1 , "Niebieski C" , false , false )
guiGridListSetItemText ( wl_gridlist , 2 , 2 , 10 , false , false )
guiGridListSetItemText ( wl_gridlist , 2 , 3 , "Wszystkich" , false , false )
guiGridListSetItemText ( wl_gridlist , 3 , 1 , "Czarny" , false , false )
guiGridListSetItemText ( wl_gridlist , 3 , 2 , 10 , false , false )
guiGridListSetItemText ( wl_gridlist , 3 , 3 , "Wszystkich" , false , false )
guiGridListSetItemText ( wl_gridlist , 4 , 1 , "Bialy" , false , false )
guiGridListSetItemText ( wl_gridlist , 4 , 2 , 10 , false , false )
guiGridListSetItemText ( wl_gridlist , 4 , 3 , "Wszystkich" , false , false )
guiGridListSetItemText ( wl_gridlist , 5 , 1 , "Szary" , false , false )
guiGridListSetItemText ( wl_gridlist , 5 , 2 , 10 , false , false )
guiGridListSetItemText ( wl_gridlist , 5 , 3 , "Wszystkich" , false , false )
guiGridListSetItemText ( wl_gridlist , 6 , 1 , "Br?zowy" , false , false )
guiGridListSetItemText ( wl_gridlist , 6 , 2 , 10 , false , false )
guiGridListSetItemText ( wl_gridlist , 6 , 3 , "Wszystkich" , false , false )
guiGridListSetItemText ( wl_gridlist , 7 , 1 , "Pomara?czowy" , false , false )
guiGridListSetItemText ( wl_gridlist , 7 , 2 , 10 , false , false )
guiGridListSetItemText ( wl_gridlist , 7 , 3 , "Wszystkich" , false , false )
guiGridListSetItemText ( wl_gridlist , 8 , 1 , "Niebieski J" , false , false )
guiGridListSetItemText ( wl_gridlist , 8 , 2 , 10 , false , false )
guiGridListSetItemText ( wl_gridlist , 8 , 3 , "Wszystkich" , false , false )
guiGridListSetItemText ( wl_gridlist , 9 , 1 , "R??owy" , false , false )
guiGridListSetItemText ( wl_gridlist , 9 , 2 , 10 , false , false )
guiGridListSetItemText ( wl_gridlist , 9 , 3 , "Wszystkich" , false , false )
guiGridListSetItemText ( wl_gridlist , 10 , 1 , "Zielony" , false , false )
guiGridListSetItemText ( wl_gridlist , 10 , 2 , 10 , false , false )
guiGridListSetItemText ( wl_gridlist , 10 , 3 , "Wszystkich" , false , false )
wl_uruchom = guiCreateButton ( x3 , y3 , w3 , h3 , "Uruchom lakierowanie" , false , wl_okno )
addEventHandler ( "onClientGUIClick" , wl_uruchom , onUruchomLakierowanie , false )
wl_zamknij = guiCreateButton ( x4 , y4 , w4 , h4 , "Zamknij" , false , wl_okno )
addEventHandler ( "onClientGUIClick" , wl_zamknij , onZamknijOkno , false )
wl_blad = guiCreateButton ( x5 , y5 , w5 , h5 , "Zg?o? b??d(w przygotowaniu)" , false , wl_okno )
end
function onZamknijOkno ()
guiSetVisible ( wl_okno , false )
showCursor ( false )
end
addEvent ( "onWyborLakieru" , true )
addEventHandler ( "onWyborLakieru" , root , function()
wybierzKolor ()
end )
function onUruchomLakierowanie ()
local id = guiGridListGetSelectedItem ( wl_gridlist )
local kolor = guiGridListGetSelectedItem ( wl_gridlist )
local cena = guiGridListGetItemText ( wl_gridlist , id , 2 )
if id == id then
if tonumber ( cena ) <= getPlayerMoney ( getLocalPlayer ()) then
takePlayerMoney ( cena )
triggerServerEvent ( "onLakierujPojazd" , root , kolor )
else
guiSetText ( wl_info , "Nie posiadasz wystarczaj?cej ilo?ci pieni?dzy!" )
end
end
end
addCommandHandler ( "devmode" ,
function ()
setDevelopmentMode ( true )
end
)
Chodzi o to ?e jak kto? wjedzie w cuboid , i mechanik chce mu pokolorowac pojazd to pisze ze pojazdu nie ma