0 Üye ve 1 Ziyaretçi konuyu incelemekte.
client.lualocal buttons = {}local sx,sy = guiGetScreenSize()local root = getRootElement()local player = getLocalPlayer()local wx,wy = sx-525, sy-395local colors = getElementsByType("carcolors")for k,v in ipairs(colors) do colors[k] = tocolor(getColorFromString(getElementData(v,"hex")))endaddEventHandler( "onClientResourceStart", getResourceRootElement(), function () window = guiCreateWindow ( sx-525, sy-395, 520, 390, "Varal Roleplay - Rengleme", false ) smallwindow = guiCreateWindow ( 0, 0, 150, 185, "What color to use...", false ) c1butt = guiCreateButton(8,20,134,35,"Color 1",false,smallwindow) c2butt = guiCreateButton(8,60,134,35,"Color 2",false,smallwindow) c3butt = guiCreateButton(8,100,134,35,"Color 3",false,smallwindow) c4butt = guiCreateButton(8,140,134,35,"Color 4",false,smallwindow) guiWindowSetSizable ( window, false ) guiWindowSetMovable ( window, true ) guiWindowSetSizable ( smallwindow, false ) guiWindowSetMovable ( smallwindow, false ) savebutt = guiCreateButton(9,355,250,26,"Save",false,window) cancelbutt = guiCreateButton(262,355,248,26,"Cancel",false,window) progressalpha = guiCreateProgressBar(302,319,210,28,false,window) guiProgressBarSetProgress(progressalpha,100) alphalabel = guiCreateLabel(302,319,210,28,"Vehicle Alpha (Click to change)",false,window) guiLabelSetColor(alphalabel,000,000,000) guiLabelSetVerticalAlign(alphalabel,"center") guiLabelSetHorizontalAlign(alphalabel,"center",false) color1label = guiCreateLabel(0,0,39,27,"1",false,window) color2label = guiCreateLabel(0,0,39,27," 2",false,window) color3label = guiCreateLabel(0,0,39,27," 3",false,window) color4label = guiCreateLabel(0,0,39,27," 4",false,window) local x,y = 10, 20 for id = 0,126 do buttons[id] = guiCreateButton ( x, y, 39, 27, "", false, window ) guiSetAlpha ( buttons[id], 0.7 ) x = x+42 if x>500 then x,y = 10, y+30 end end guiSetVisible ( smallwindow, false ) guiSetVisible ( window, false ) addEventHandler("onClientGUIMove",window,function() wx,wy = guiGetPosition ( window, false ) end) addbuttons() addbuttons2()end) local marker = createMarker(-2050.5,145.9,28.9 +0.61,"cylinder", 2.4, 45, 74, 23, 220) addEventHandler("onClientMarkerHit", marker,function(giren) if getElementType(giren) == "player" and giren == localPlayer then -- eğer girenin tipi oyuncu ise ve localPlayer ise local takim = getPlayerTeam(giren) -- girenin takımını çek if takim then -- eğer takım varsa local takimisim = getTeamName(takim) -- takım ismini çek if takimisim == "Bakım ve Servis İşletmeleri" then -- eğer takım ismi "TSK" ise local takimisim = guiGetVisible ( window ) vehicle = getPedOccupiedVehicle(player) if (vehicle) then guiSetVisible(window, true) -- pencereyi aç guiSetVisible(smallwindow, true) -- pencereyi aç showCursor(true) -- imleci aç oldc1,oldc2,oldc3,oldc4 = getVehicleColor(vehicle) c1,c2,c3,c4 = false posgui = true guiSetPosition(color1label,guiGetPosition(buttons[oldc1],false),false) guiSetPosition(color2label,guiGetPosition(buttons[oldc2],false),false) guiSetPosition(color3label,guiGetPosition(buttons[oldc3],false),false) guiSetPosition(color4label,guiGetPosition(buttons[oldc4],false),false) addEventHandler ( "onClientRender", root, showRectangles ) end end endendend)function showRectangles() local x,y = 11, 26 for k,v in ipairs(colors) do dxDrawRectangle(wx+x,wy+y,37,15,colors[k],posgui) x = x+42 if x>500 then x,y = 11, y+30 end endendfunction addbuttons() addEventHandler("onClientGUIClick",window,function(button,state,cx,cy) if button == "left" and state == "up" then if getElementType(source) == "gui-button" then text = guiGetText(source) if text == "" then local x,y = cx-wx-10,cy-wy-22 local row = math.floor(y/30) local column = math.floor(x/42) posgui = false pressedcolor = row*12+column guiSetVisible(smallwindow,true) if cx+150 > sx then cx = cx-150 end if cy+185 > sy then cy = cy-185 end guiSetPosition(smallwindow,cx,cy,false) guiBringToFront(smallwindow) elseif text == "Save" then c1 = c1 or oldc1 if c4 then c3 = c3 or oldc3 end if c3 then c2 = c2 or oldc2 end triggerServerEvent("colorchange",player,c1,c2,c3,c4) alpha = newalpha or alpha triggerServerEvent("alphachange",root,player,false,alpha) removeEventHandler("onClientRender",root,showRectangles) guiSetVisible(window,false) guiSetVisible(smallwindow,false) showCursor(false) else removeEventHandler("onClientRender",root,showRectangles) guiSetVisible(smallwindow,false) guiSetVisible(window,false) setVehicleColor(vehicle,tonumber(oldc1),tonumber(oldc2),tonumber(oldc3),tonumber(oldc4)) setElementAlpha(vehicle,alpha) showCursor(false) end elseif (source == alphalabel) or (source == progressalpha) then local x = guiGetPosition(window,false) local nx = guiGetPosition(progressalpha,false) local x = x+nx+5 local cx = cx-x local precents = math.ceil(cx/198*1000)/10 newalpha = math.ceil(cx/198*255) if newalpha > 255 then newalpha = 255 end if newalpha < 0 then newalpha = 0 end setElementAlpha(vehicle,newalpha) guiProgressBarSetProgress ( progressalpha, precents ) end end end)endfunction addbuttons2() addEventHandler("onClientGUIClick",smallwindow,function(click,state) if click == "left" and state == "up" then if source == c1butt then if pressedcolor == 1 then guiLabelSetColor(color1label,100,200,0) else guiLabelSetColor(color1label,255,255,255) end c1 = pressedcolor guiSetVisible ( smallwindow, false ) tc1,tc2,tc3,tc4 = c1 or oldc1, c2 or oldc2, c3 or oldc3, c4 or oldc4 setVehicleColor(vehicle,tonumber(tc1),tonumber(tc2),tonumber(tc3),tonumber(tc4))-- outputDebugString(tostring(getPedOccupiedVehicle(player)).." "..tonumber(tc1).." "..tonumber(tc2).." "..tonumber(tc3).." "..tonumber(tc4)) guiSetPosition(color1label,guiGetPosition(buttons[c1],false),false) posgui = true elseif source == c2butt then if pressedcolor == 1 then guiLabelSetColor(color2label,100,200,0) else guiLabelSetColor(color2label,255,255,255) end c2 = pressedcolor guiSetVisible ( smallwindow, false ) tc1,tc2,tc3,tc4 = c1 or oldc1, c2 or oldc2, c3 or oldc3, c4 or oldc4 setVehicleColor(vehicle,tonumber(tc1),tonumber(tc2),tonumber(tc3),tonumber(tc4)) posgui = true guiSetPosition(color2label,guiGetPosition(buttons[c2],false),false) elseif source == c3butt then if pressedcolor == 1 then guiLabelSetColor(color3label,100,200,0) else guiLabelSetColor(color3label,255,255,255) end c3 = pressedcolor guiSetVisible ( smallwindow, false ) tc1,tc2,tc3,tc4 = c1 or oldc1, c2 or oldc2, c3 or oldc3, c4 or oldc4 setVehicleColor(vehicle,tonumber(tc1),tonumber(tc2),tonumber(tc3),tonumber(tc4)) guiSetPosition(color3label,guiGetPosition(buttons[c3],false),false) posgui = true else if pressedcolor == 1 then guiLabelSetColor(color4label,100,200,0) else guiLabelSetColor(color4label,255,255,255) end c4 = pressedcolor tc1,tc2,tc3,tc4 = c1 or oldc1, c2 or oldc2, c3 or oldc3, c4 or oldc4 guiSetVisible ( smallwindow, false ) setVehicleColor(vehicle,tonumber(tc1),tonumber(tc2),tonumber(tc3),tonumber(tc4)) guiSetPosition(color4label,guiGetPosition(buttons[c4],false),false) posgui = true end end end)end
script.luaroot = getRootElement()function executecolor(c1,c2,c3,c4) carcolor(source,true,c1,c2,c3,c4)endfunction executealpha(player,_,alpha) alpha = alpha or 255 setElementAlpha(getPedOccupiedVehicle(player),tonumber(alpha)) outputChatBox("Vehicle Alpha sucessfully changed to: "..alpha.." !",thePlayer)endfunction carcolor(thePlayer,_,arg1,arg2,arg3,arg4) local vehicle=getPedOccupiedVehicle(thePlayer) if (vehicle) then local old,old2,old3,old4=getVehicleColor(vehicle) local arg11,arg22,arg33,arg44=tonumber(arg1),tonumber(arg2) or old2,tonumber(arg3) or old3,tonumber(arg4) or old4 local sucess=setVehicleColor(vehicle,arg11,arg22,arg33,arg44) if (sucess) and arg11<127 and arg11>-1 and (arg22<127 and arg22>-1 or arg22==nil) and (arg33<127 and arg33>-1 or arg33==nil) and (arg44<127 and arg44>-1 or arg44==nil) then if (arg4) then outputChatBox("Vehilce color sucessfully changed to Color-1:"..arg1.."\n, Color-2:"..arg2..", Color-3:"..arg3..", Color-4:"..arg4.."!",thePlayer,0,250,0) elseif (arg3) then outputChatBox("Vehilce color sucessfully changed to Color-1:"..arg1.."\n, Color-2:"..arg2..", Color-3:"..arg3.."!",thePlayer,0,250,0) elseif (arg2) then outputChatBox("Vehilce color sucessfully changed to Color-1:"..arg1.."\n, Color-2:"..arg2.."!",thePlayer,0,250,0) else outputChatBox("Vehilce color sucessfully changed to Color-1:"..arg1.."!",thePlayer,0,250,0) end else outputChatBox("failed to change carcolor! Use /carcolor color1 [color2 color3 color4] !! (colors:0-126)",thePlayer,250,0,0) end else outputChatBox("You must be in vehicle to use this command",thePlayer,0,250,0) endendaddCommandHandler("va",carcolor)addCommandHandler("vehiclealpha",carcolor)addCommandHandler("ccolor",carcolor)addCommandHandler("carcolor",carcolor)addCommandHandler("cc",carcolor)addEvent("colorchange",true)addEventHandler("colorchange",root, executecolor)addEvent("alphachange",true)addEventHandler("alphachange",root, executealpha)