Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------------------------------------------
- -- PROJECT: Community of Integrity and Transparency 2.0
- -- RIGHTS: All rights reserved by developers
- -- FILE: CIThuds
- -- PURPOSE: HUD system
- -- DEVELOPER: Chique
- ------------------------------------------------------------------------------------
- local screenWidth, screenHeight = guiGetScreenSize()
- local originx, originy = screenWidth/2, screenHeight/2
- local baser, baseg, baseb = 250, 250, 250
- local indir, indig, indib = 0, 255, 0
- local needr, needg, needb = 0, 150, 255
- local shadr, shadg, shadb = 50, 50, 50
- local txtsize = 1
- local soff = 0.25
- local show1 = true
- local show2 = true
- local show3 = true
- local show4 = true
- local showHud = false
- function hudDrishti()
- if (not showHud) then return end
- local px,py,pz = getElementPosition(localPlayer)
- px, py, pz = (math.floor(px*10))/10, (math.floor(py*10))/10, math.floor(pz)
- local _, _, prz = getElementRotation(localPlayer)
- prz = math.floor(prz)
- if (prz == 360) then prz = 0 end
- -- Common
- if (show1) then
- dxDrawRectangle(screenWidth-465, screenHeight - 22.5, 160, 15, tocolor(0, 0, 0, 100))
- dxDrawText(tostring(string.format("%1.1f", px))..", "..tostring(string.format("%1.1f", py)).." | "..tostring(prz), screenWidth-455, screenHeight - 22, screenWidth-455+140, screenHeight - 22, tocolor(255, 255, 255, 255), txtsize, "clear", "center")
- end
- -- Vehicles
- local playerVehicle = getPedOccupiedVehicle(localPlayer)
- if (playerVehicle) then
- local vtype = getVehicleType(playerVehicle)
- if (show2) then
- -- Cars
- if (vtype == "Automobile" or vtype == "Monster Truck") then
- for index = 0,6 do
- local state = getVehiclePanelState (playerVehicle, index)
- if (state==0) then hr,hg,hb=255,255,255
- elseif (state==1) then hr,hg,hb=255,204,0
- elseif (state==2) then hr,hg,hb=255,180,0
- elseif (state==3) then hr,hg,hb=200,50,0
- end
- if (index==0) then
- plotx,ploty,plotw,ploth=screenWidth/2-20,screenHeight-57.5,5,25
- end
- if (index==1) then
- plotx,ploty,plotw,ploth=screenWidth/2+20,screenHeight-57.5,5,25
- end
- if (index==2) then
- plotx,ploty,plotw,ploth=screenWidth/2-20,screenHeight-32.5,5,20
- end
- if (index==3) then
- plotx,ploty,plotw,ploth=screenWidth/2+20,screenHeight-32.5,5,20
- end
- if (index==4) then
- plotx,ploty,plotw,ploth=screenWidth/2-15,screenHeight-47.5,35,15
- end
- if (index==5) then
- plotx,ploty,plotw,ploth=screenWidth/2-15,screenHeight-62.5,35,10
- end
- if (index==6) then
- plotx,ploty,plotw,ploth=screenWidth/2-15,screenHeight-17.5,35,10
- end
- dxDrawRectangle (plotx, ploty, plotw, ploth, tocolor(hr, hg, hb, 180))
- end
- local wfl, wrl, wfr, wrr = getVehicleWheelStates(playerVehicle)
- wfl, wrl, wfr, wrr = wfl+1, wrl+1, wfr+1, wrr+1
- local color = {[1]={20,200,20}, [2]={255,20,20}, [3]={80,0,0}, [4]={255,255,255}}
- dxDrawRectangle (screenWidth/2-27, screenHeight-52.5, 5, 7, tocolor(color[wfl][1], color[wfl][2], color[wfl][3], 180))
- dxDrawRectangle (screenWidth/2-27, screenHeight-27.5, 5, 7, tocolor(color[wrl][1], color[wrl][2], color[wrl][3], 180))
- dxDrawRectangle (screenWidth/2+27, screenHeight-52.5, 5, 7, tocolor(color[wfr][1], color[wfr][2], color[wfr][3], 180))
- dxDrawRectangle (screenWidth/2+27, screenHeight-27.5, 5, 7, tocolor(color[wrr][1], color[wrr][2], color[wrr][3], 180))
- end
- end
- if (show3) then
- -- Helicopter
- if (vtype == "Helicopter") then
- -- Gathering Data
- local rx,ry,rz = getElementRotation(playerVehicle)
- rx = math.floor(rx)
- if (rx>180) then rx = - (360 - rx) end
- rx = -rx
- dxDrawRectangle(screenWidth-465, screenHeight-62.5, 160, 15, tocolor(0, 0, 0, 100))
- dxDrawText("Alt: "..tostring(pz).." | Att : "..tostring(rx), screenWidth-455, screenHeight-62, screenWidth-455+140, 50, tocolor(255, 255, 255, 255), txtsize, "clear", "center")
- end
- end
- if (show4) then
- -- Plane
- if (vtype == "Plane") then
- -- Gathering Data
- local vx,vy,vz = getElementVelocity(playerVehicle)
- local vxy = math.floor((vx^2 + vy^2) ^ 0.5 * 180 * 0.54) --Knot
- vz = math.floor(vz * 50) --m/s
- vxyz = math.floor((vxy^2 + vz^2) ^ 0.5) --Knot
- local rx,ry,rz = getElementRotation(playerVehicle)
- rx = math.floor(rx)
- if (rx>180) then rx = - (360 - rx) end
- ry = math.floor(ry)
- if (ry>180) then ry = - (360 - ry) end
- rz = math.floor(rz)
- if (rz==360) then rz = 0 end
- local sinry = math.sin(math.rad(ry))
- local cosry = math.cos(math.rad(ry))
- -- Turn and Slip Indicator
- for i = 0, 90, 15 do
- dxDrawLine ((originx) + (110 * math.sin(math.rad(i))), (originy) + (110 * math.cos(math.rad(i))), (originx) + (120 * math.sin(math.rad(i))), (originy) + (120 * math.cos(math.rad(i))), tocolor(baser,baseg,baseb,200), 1)
- dxDrawLine ((originx) + (110 * math.sin(math.rad(-i))), (originy) + (110 * math.cos(math.rad(-i))), (originx) + (120 * math.sin(math.rad(-i))), (originy) + (120 * math.cos(math.rad(-i))), tocolor(baser,baseg,baseb,200), 1)
- end
- dxDrawLine ((originx) + (110 * sinry), (originy) + (110 * cosry), (originx) + (120 * sinry), (originy) + (120 * cosry), tocolor(needr,needg,needb,255), 3)
- dxDrawText (tostring(math.abs(ry)), (originx) + (120 * sinry)+soff, (originy) + (120 * cosry)+soff, 50, 50, tocolor(shadr, shadg, shadb, 255), txtsize, "clear") --Shadow
- dxDrawText (tostring(math.abs(ry)), (originx) + (120 * sinry), (originy) + (120 * cosry), 50, 50, tocolor(indir, indig, indib, 255), txtsize, "clear")
- -- Attitude Indicator
- for i = 0, 60, 30 do
- dxDrawText(tostring(i), (originx) + 40, (originy) + rx + i + (10*sinry), 50, 50, tocolor(baser,baseg,baseb,200), 0.7, "clear")
- dxDrawText(tostring(i), (originx) + 40, (originy) + rx - i + (10*sinry), 50, 50, tocolor(baser,baseg,baseb,200), 0.7, "clear")
- dxDrawLine (originx-30, originy + rx + i - (10*sinry), (originx) + 30, originy + rx + i + (10*sinry), tocolor(baser,baseg,baseb,200), 1)
- dxDrawLine (originx-30, originy + rx - i - (10*sinry), (originx) + 30, originy + rx - i + (10*sinry), tocolor(baser,baseg,baseb,200), 1)
- end
- dxDrawLine (originx-30, originy + rx - 45 - (10*sinry), (originx) + 30, originy + rx - 45 + (10*sinry), tocolor(baser,baseg,baseb,200), 1)
- dxDrawLine (originx-30, originy+5, (originx-8), originy+5, tocolor(needr,needg,needb,255), 2)
- dxDrawLine (originx+30, originy+5, (originx+8), originy+5, tocolor(needr,needg,needb,255), 2)
- dxDrawText (tostring(rx), (originx) - 55+soff, (originy)+soff, 50, 50, tocolor(shadr, shadg, shadb, 255), txtsize, "clear") --Shadow
- dxDrawText (tostring(rx), (originx) - 55, (originy), 50, 50, tocolor(indir, indig, indib, 255), txtsize, "clear")
- -- Heading Indicator
- dxDrawText (tostring(rz), (originx) - 5+soff, (originy)-40+soff, 50, 50, tocolor(shadr, shadg, shadb, 255), txtsize, "clear") --Shadow
- dxDrawText (tostring(rz), (originx) - 5, (originy)-40, 50, 50, tocolor(indir, indig, indib, 255), txtsize, "clear")
- -- Vertical Speed Indicator
- dxDrawLine (originx+60, originy+60, originx+60, originy-60, tocolor(baser,baseg,baseb,200), 1)
- dxDrawLine (originx+57, originy-vz, originx+63, originy-vz, tocolor(needr,needg,needb,255), 2)
- dxDrawText (tostring(vz), originx+65+soff, originy-5-vz+soff, 50, 50, tocolor(shadr, shadg, shadb, 255), txtsize, "clear") --Shadow
- dxDrawText (tostring(vz), originx+65, originy-5-vz, 50, 50, tocolor(indir, indig, indib, 255), txtsize, "clear")
- -- Speedometer / Altimeter
- dxDrawText ("IAS: "..tostring(vxyz), originx-120+soff, originy-60+soff, 50, 50, tocolor(shadr, shadg, shadb, 255), txtsize, "clear") --Shadow
- dxDrawText ("IAS: "..tostring(vxyz), originx-120, originy-60, 50, 50, tocolor(indir, indig, indib, 255), txtsize, "clear")
- dxDrawText ("GS: "..tostring(vxy), originx-120+soff, originy-40+soff, 50, 50, tocolor(shadr, shadg, shadb, 255), txtsize, "clear") --Shadow
- dxDrawText ("GS: "..tostring(vxy), originx-120, originy-40, 50, 50, tocolor(indir, indig, indib, 255), txtsize, "clear")
- dxDrawText ("Alt: "..tostring(pz), originx+85+soff, originy-60+soff+soff, 50, 50, tocolor(shadr, shadg, shadb, 255), txtsize, "clear") --Shadow
- dxDrawText ("Alt: "..tostring(pz), originx+85, originy-60, 50, 50, tocolor(indir, indig, indib, 255), txtsize, "clear")
- end
- end
- end
- end
- addEventHandler("onClientRender", root, hudDrishti)
- -- Settings Window
- local windowHud = guiCreateWindow(screenWidth/2-200, screenHeight/2-250, 400, 500, "HUD Settings", false)
- guiSetAlpha(windowHud, 0.9)
- guiWindowSetSizable(windowHud, false)
- guiWindowSetMovable(windowHud, true)
- guiSetVisible(windowHud, false)
- local buttonSave = guiCreateButton(20, 470, 170, 30, "Save", false, windowHud)
- local buttonReset = guiCreateButton(210, 470, 170, 30, "Reset", false, windowHud)
- local chkbox0 = guiCreateCheckBox(20, 30, 150, 30, " Enable Advanced HUD", false, false, windowHud)
- local chkbox1 = guiCreateCheckBox(20, 70, 80, 20, "GPS", true, false, windowHud)
- local chkbox2 = guiCreateCheckBox(120, 70, 80, 20, "Car", true, false, windowHud)
- local chkbox3 = guiCreateCheckBox(220, 70, 80, 20, "Heli", true, false, windowHud)
- local chkbox4 = guiCreateCheckBox(320, 70, 80, 20, "Plane", true, false, windowHud)
- guiCreateLabel(20, 110, 120, 30, "Panel Position (A/c)", false, windowHud)
- local toriginx = guiCreateEdit(180, 110, 60, 30, "0", false, windowHud)
- local toriginy = guiCreateEdit(250, 110, 60, 30, "0", false, windowHud)
- guiCreateLabel(185, 150, 30, 30, "R", false, windowHud)
- guiCreateLabel(255, 150, 30, 30, "G", false, windowHud)
- guiCreateLabel(325, 150, 30, 30, "B", false, windowHud)
- guiCreateLabel(20, 170, 150, 30, "Dial Base Color", false, windowHud)
- local tbasecolorr = guiCreateEdit(180, 170, 60, 30, tostring(baser), false, windowHud)
- local tbasecolorg = guiCreateEdit(250, 170, 60, 30, tostring(baseg), false, windowHud)
- local tbasecolorb = guiCreateEdit(320, 170, 60, 30, tostring(baseb), false, windowHud)
- guiCreateLabel(20, 210, 150, 30, "Needle Color", false, windowHud)
- local tneedcolorr = guiCreateEdit(180, 210, 60, 30, tostring(needr), false, windowHud)
- local tneedcolorg = guiCreateEdit(250, 210, 60, 30, tostring(needg), false, windowHud)
- local tneedcolorb = guiCreateEdit(320, 210, 60, 30, tostring(needb), false, windowHud)
- guiCreateLabel(20, 250, 150, 30, "Indicator Color", false, windowHud)
- local tindicolorr = guiCreateEdit(180, 250, 60, 30, tostring(indir), false, windowHud)
- local tindicolorg = guiCreateEdit(250, 250, 60, 30, tostring(indig), false, windowHud)
- local tindicolorb = guiCreateEdit(320, 250, 60, 30, tostring(indib), false, windowHud)
- guiCreateLabel(20, 320, 150, 30, "Shadow Color", false, windowHud)
- local tshadcolorr = guiCreateEdit(180, 320, 60, 30, tostring(shadr), false, windowHud)
- local tshadcolorg = guiCreateEdit(250, 320, 60, 30, tostring(shadg), false, windowHud)
- local tshadcolorb = guiCreateEdit(320, 320, 60, 30, tostring(shadb), false, windowHud)
- local txthelp = " ----Common Component---- \n The bar at the bottom of your screen shows the current location co-ordinates of your position, in (x,y) format, along with the direction you are facing (compass), in degrees. Where 0 is North, 90 is West, and so on. \n\n ----Car Component---- \n The dynamic damage meter shows the individual HP of the panels, also it shows the wheel state of your car, which turns red on flattening. \n\n ----Aircraft Component---- \n IAS : Indicated Air Speed (in knots), GS : Ground Speed (in knots), Alt : Altitude (in meters) \n The large semicircular dial at the bottom is the TSI (Turn and Slip Indicator), which accurately measures your angle of banking. \n Just inside the TSI, you will find the Attitude Indicator, the horizontal bar of lines indicate the angle subtended by your Aircraft nose with the horizontal. Just to its right is a narrow line, which is the VSI (Vertical Speed Indicator), which would show if you are climbing or descending (in meters per second), and also essential to detect a stall. Just a little bit above the Attitude Indicator, right in the middle, you will find a Heading Indicator (magnetic compass), which shows in degrees the direction towards which you are moving. A 0 Degree means North, whereas 90 is for West, 180 for South, and 270 for East. \n\n\n\n Chique, \n Technical Engineer"
- guiCreateMemo(20, 370, 360, 80, txthelp, false, windowHud)
- -- /Settings Window
- addCommandHandler("hud", function()
- guiSetVisible(windowHud, true)
- showCursor(true)
- end)
- addEventHandler("onClientGUIClick", buttonSave, function()
- local v = {}
- v["originx"] = tonumber(guiGetText(toriginx))
- v["originy"] = tonumber(guiGetText(toriginy))
- if (tonumber(guiGetText(tbasecolorr))>=0 and tonumber(guiGetText(tbasecolorr))<=255
- and tonumber(guiGetText(tbasecolorg))>=0 and tonumber(guiGetText(tbasecolorg))<=255
- and tonumber(guiGetText(tbasecolorb))>=0 and tonumber(guiGetText(tbasecolorb))<=255) then
- v["baser"], v["baseg"], v["baseb"] = tonumber(guiGetText(tbasecolorr)), tonumber(guiGetText(tbasecolorg)), tonumber(guiGetText(tbasecolorb))
- else
- v["baser"], v["baseg"], v["baseb"] = 250, 250, 250
- end
- if (tonumber(guiGetText(tindicolorr))>=0 and tonumber(guiGetText(tindicolorr))<=255
- and tonumber(guiGetText(tindicolorg))>=0 and tonumber(guiGetText(tindicolorg))<=255
- and tonumber(guiGetText(tindicolorb))>=0 and tonumber(guiGetText(tindicolorb))<=255) then
- v["indir"], v["indig"], v["indib"] = tonumber(guiGetText(tindicolorr)), tonumber(guiGetText(tindicolorg)), tonumber(guiGetText(tindicolorb))
- else
- v["indir"], v["indig"], v["indib"] = 0, 250, 0
- end
- if (tonumber(guiGetText(tneedcolorr))>=0 and tonumber(guiGetText(tneedcolorr))<=255
- and tonumber(guiGetText(tneedcolorg))>=0 and tonumber(guiGetText(tneedcolorg))<=255
- and tonumber(guiGetText(tneedcolorb))>=0 and tonumber(guiGetText(tneedcolorb))<=255) then
- v["needr"], v["needg"], v["needb"] = tonumber(guiGetText(tneedcolorr)), tonumber(guiGetText(tneedcolorg)), tonumber(guiGetText(tneedcolorb))
- else
- v["needr"], v["needg"], v["needb"] = 0, 150, 250
- end
- if (tonumber(guiGetText(tshadcolorr))>=0 and tonumber(guiGetText(tshadcolorr))<=255
- and tonumber(guiGetText(tshadcolorg))>=0 and tonumber(guiGetText(tshadcolorg))<=255
- and tonumber(guiGetText(tshadcolorb))>=0 and tonumber(guiGetText(tshadcolorb))<=255) then
- v["shadr"], v["shadg"], v["shadb"] = tonumber(guiGetText(tshadcolorr)), tonumber(guiGetText(tshadcolorg)), tonumber(guiGetText(tshadcolorb))
- else
- v["shadr"], v["shadg"], v["shadb"] = 50, 50, 50
- end
- v["show1"] = guiCheckBoxGetSelected(chkbox1)
- v["show2"] = guiCheckBoxGetSelected(chkbox2)
- v["show3"] = guiCheckBoxGetSelected(chkbox3)
- v["show4"] = guiCheckBoxGetSelected(chkbox4)
- v["showHud"] = guiCheckBoxGetSelected(chkbox0)
- triggerServerEvent("CIThud.saveHudSettingsData", getLocalPlayer(), v)
- guiSetVisible(windowHud, false)
- showCursor(false)
- end)
- addEventHandler("onClientGUIClick", buttonReset, function()
- guiSetVisible(windowHud, false)
- showCursor(false)
- triggerServerEvent("CIThud.saveHudSettingsData", getLocalPlayer(), false)
- end)
- function setData(v)
- originx, originy = screenWidth/2 + v["originx"], screenHeight/2 + v["originy"]
- baser, baseg, baseb = v["baser"], v["baseg"], v["baseb"]
- indir, indig, indib = v["indir"], v["indig"], v["indib"]
- needr, needg, needb = v["needr"], v["needg"], v["needb"]
- shadr, shadg, shadb = v["shadr"], v["shadg"], v["shadb"]
- show1, show2, show3, show4 = v["show1"], v["show2"], v["show3"], v["show4"]
- showHud = v["showHud"]
- guiCheckBoxSetSelected(chkbox0, showHud)
- guiCheckBoxSetSelected(chkbox1, show1)
- guiCheckBoxSetSelected(chkbox2, show2)
- guiCheckBoxSetSelected(chkbox3, show3)
- guiCheckBoxSetSelected(chkbox4, show4)
- guiSetText(toriginx, tostring(originx-screenWidth/2))
- guiSetText(toriginy, tostring(originy-screenHeight/2))
- guiSetText(tbasecolorr, baser)
- guiSetText(tbasecolorg, baseg)
- guiSetText(tbasecolorb, baseb)
- guiSetText(tneedcolorr, needr)
- guiSetText(tneedcolorg, needg)
- guiSetText(tneedcolorb, needb)
- guiSetText(tindicolorr, indir)
- guiSetText(tindicolorg, indig)
- guiSetText(tindicolorb, indib)
- guiSetText(tshadcolorr, shadr)
- guiSetText(tshadcolorg, shadg)
- guiSetText(tshadcolorb, shadb)
- end
- addEvent("CIThud.setHudSettingsData", true)
- addEventHandler("CIThud.setHudSettingsData", root, setData)
- --[[Foot Notes
- HUD System
- Script by Satadru Chique, Dedicated to CIT, CIT IG A/c, Forum A/c : Satadru Electra, Chique Electra
- Better known as Chique (IG/Forum Name)
- 10th November 2012
- www.facebook.com/www.satadru or www.satadru@facebook.com
- ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement