Advertisement
Chique

CITdrishtiClient

Nov 7th, 2012
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 16.76 KB | None | 0 0
  1. ------------------------------------------------------------------------------------
  2. --  PROJECT:     Community of Integrity and Transparency 2.0
  3. --  RIGHTS:      All rights reserved by developers
  4. --  FILE:        CIThuds
  5. --  PURPOSE:     HUD system
  6. --  DEVELOPER:   Chique
  7. ------------------------------------------------------------------------------------
  8.  
  9.  
  10. local screenWidth, screenHeight = guiGetScreenSize()
  11. local originx, originy = screenWidth/2, screenHeight/2
  12. local baser, baseg, baseb = 250, 250, 250
  13. local indir, indig, indib = 0, 255, 0
  14. local needr, needg, needb = 0, 150, 255
  15. local shadr, shadg, shadb = 50, 50, 50
  16. local txtsize = 1
  17. local soff = 0.25
  18. local show1 = true
  19. local show2 = true
  20. local show3 = true
  21. local show4 = true
  22. local showHud = false
  23.  
  24. function hudDrishti()
  25.     if (not showHud) then return end
  26.    
  27.     local px,py,pz = getElementPosition(localPlayer)
  28.     px, py, pz = (math.floor(px*10))/10, (math.floor(py*10))/10, math.floor(pz)
  29.     local _, _, prz = getElementRotation(localPlayer)
  30.     prz = math.floor(prz)
  31.     if (prz == 360) then prz = 0 end
  32.        
  33.     -- Common
  34.     if (show1) then
  35.         dxDrawRectangle(screenWidth-465, screenHeight - 22.5, 160, 15, tocolor(0, 0, 0, 100))
  36.         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")
  37.     end
  38.    
  39.    
  40.     -- Vehicles
  41.     local playerVehicle = getPedOccupiedVehicle(localPlayer)
  42.     if (playerVehicle) then
  43.         local vtype = getVehicleType(playerVehicle)
  44.    
  45.    
  46.         if (show2) then
  47.             -- Cars
  48.             if (vtype == "Automobile" or vtype == "Monster Truck") then
  49.            
  50.                 for index = 0,6 do
  51.                     local state = getVehiclePanelState (playerVehicle, index)
  52.                     if (state==0) then hr,hg,hb=255,255,255
  53.                     elseif (state==1) then hr,hg,hb=255,204,0
  54.                     elseif (state==2) then hr,hg,hb=255,180,0
  55.                     elseif (state==3) then hr,hg,hb=200,50,0
  56.                     end
  57.                
  58.                     if (index==0) then
  59.                         plotx,ploty,plotw,ploth=screenWidth/2-20,screenHeight-57.5,5,25
  60.                     end
  61.                     if (index==1) then
  62.                         plotx,ploty,plotw,ploth=screenWidth/2+20,screenHeight-57.5,5,25
  63.                     end
  64.                     if (index==2) then
  65.                         plotx,ploty,plotw,ploth=screenWidth/2-20,screenHeight-32.5,5,20
  66.                     end
  67.                     if (index==3) then
  68.                         plotx,ploty,plotw,ploth=screenWidth/2+20,screenHeight-32.5,5,20
  69.                     end
  70.                     if (index==4) then
  71.                         plotx,ploty,plotw,ploth=screenWidth/2-15,screenHeight-47.5,35,15
  72.                     end
  73.                     if (index==5) then
  74.                         plotx,ploty,plotw,ploth=screenWidth/2-15,screenHeight-62.5,35,10
  75.                     end
  76.                     if (index==6) then
  77.                         plotx,ploty,plotw,ploth=screenWidth/2-15,screenHeight-17.5,35,10
  78.                     end
  79.                     dxDrawRectangle (plotx, ploty, plotw, ploth, tocolor(hr, hg, hb, 180))
  80.                 end
  81.                
  82.                 local wfl, wrl, wfr, wrr = getVehicleWheelStates(playerVehicle)
  83.                 wfl, wrl, wfr, wrr = wfl+1, wrl+1, wfr+1, wrr+1
  84.                 local color = {[1]={20,200,20}, [2]={255,20,20}, [3]={80,0,0}, [4]={255,255,255}}
  85.                 dxDrawRectangle (screenWidth/2-27, screenHeight-52.5, 5, 7, tocolor(color[wfl][1], color[wfl][2], color[wfl][3], 180))
  86.                 dxDrawRectangle (screenWidth/2-27, screenHeight-27.5, 5, 7, tocolor(color[wrl][1], color[wrl][2], color[wrl][3], 180))
  87.                 dxDrawRectangle (screenWidth/2+27, screenHeight-52.5, 5, 7, tocolor(color[wfr][1], color[wfr][2], color[wfr][3], 180))
  88.                 dxDrawRectangle (screenWidth/2+27, screenHeight-27.5, 5, 7, tocolor(color[wrr][1], color[wrr][2], color[wrr][3], 180))
  89.                
  90.             end
  91.         end
  92.        
  93.         if (show3) then
  94.             -- Helicopter
  95.             if (vtype == "Helicopter") then
  96.                 -- Gathering Data
  97.                 local rx,ry,rz = getElementRotation(playerVehicle)
  98.                 rx = math.floor(rx)
  99.                 if (rx>180) then rx = - (360 - rx) end
  100.                 rx = -rx
  101.                
  102.                 dxDrawRectangle(screenWidth-465, screenHeight-62.5, 160, 15, tocolor(0, 0, 0, 100))
  103.                 dxDrawText("Alt: "..tostring(pz).." | Att : "..tostring(rx), screenWidth-455, screenHeight-62, screenWidth-455+140, 50, tocolor(255, 255, 255, 255), txtsize, "clear", "center")
  104.             end
  105.         end
  106.        
  107.        
  108.         if (show4) then
  109.             -- Plane
  110.             if (vtype == "Plane") then
  111.                 -- Gathering Data
  112.                 local vx,vy,vz = getElementVelocity(playerVehicle)
  113.                 local vxy = math.floor((vx^2 + vy^2) ^ 0.5 * 180 * 0.54) --Knot
  114.                 vz = math.floor(vz * 50) --m/s
  115.                 vxyz = math.floor((vxy^2 + vz^2) ^ 0.5) --Knot
  116.                
  117.                 local rx,ry,rz = getElementRotation(playerVehicle)
  118.                 rx = math.floor(rx)
  119.                 if (rx>180) then rx = - (360 - rx) end
  120.                 ry = math.floor(ry)
  121.                 if (ry>180) then ry = - (360 - ry) end
  122.                 rz = math.floor(rz)
  123.                 if (rz==360) then rz = 0 end
  124.                
  125.                 local sinry = math.sin(math.rad(ry))
  126.                 local cosry = math.cos(math.rad(ry))
  127.                
  128.                
  129.                 -- Turn and Slip Indicator 
  130.                 for i = 0, 90, 15 do
  131.                     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)
  132.                    
  133.                     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)
  134.                 end
  135.                 dxDrawLine ((originx) + (110 * sinry), (originy) + (110 * cosry), (originx) + (120 * sinry), (originy) + (120 * cosry), tocolor(needr,needg,needb,255), 3)
  136.                 dxDrawText (tostring(math.abs(ry)), (originx) + (120 * sinry)+soff, (originy) + (120 * cosry)+soff, 50, 50, tocolor(shadr, shadg, shadb, 255), txtsize, "clear") --Shadow
  137.                 dxDrawText (tostring(math.abs(ry)), (originx) + (120 * sinry), (originy) + (120 * cosry), 50, 50, tocolor(indir, indig, indib, 255), txtsize, "clear")
  138.                
  139.                
  140.                 -- Attitude Indicator
  141.                 for i = 0, 60, 30 do
  142.                     dxDrawText(tostring(i), (originx) + 40, (originy) + rx + i + (10*sinry), 50, 50, tocolor(baser,baseg,baseb,200), 0.7, "clear")
  143.                     dxDrawText(tostring(i), (originx) + 40, (originy) + rx - i + (10*sinry), 50, 50, tocolor(baser,baseg,baseb,200), 0.7, "clear")
  144.                    
  145.                     dxDrawLine (originx-30, originy + rx + i - (10*sinry), (originx) + 30, originy + rx + i + (10*sinry), tocolor(baser,baseg,baseb,200), 1)
  146.                     dxDrawLine (originx-30, originy + rx - i - (10*sinry), (originx) + 30, originy + rx - i + (10*sinry), tocolor(baser,baseg,baseb,200), 1)
  147.                 end
  148.                 dxDrawLine (originx-30, originy + rx - 45 - (10*sinry), (originx) + 30, originy + rx - 45 + (10*sinry), tocolor(baser,baseg,baseb,200), 1)
  149.                
  150.                 dxDrawLine (originx-30, originy+5, (originx-8), originy+5, tocolor(needr,needg,needb,255), 2)
  151.                 dxDrawLine (originx+30, originy+5, (originx+8), originy+5, tocolor(needr,needg,needb,255), 2)
  152.                 dxDrawText (tostring(rx), (originx) - 55+soff, (originy)+soff, 50, 50, tocolor(shadr, shadg, shadb, 255), txtsize, "clear") --Shadow
  153.                 dxDrawText (tostring(rx), (originx) - 55, (originy), 50, 50, tocolor(indir, indig, indib, 255), txtsize, "clear")
  154.                
  155.                 -- Heading Indicator
  156.                 dxDrawText (tostring(rz), (originx) - 5+soff, (originy)-40+soff, 50, 50, tocolor(shadr, shadg, shadb, 255), txtsize, "clear") --Shadow
  157.                 dxDrawText (tostring(rz), (originx) - 5, (originy)-40, 50, 50, tocolor(indir, indig, indib, 255), txtsize, "clear")
  158.                
  159.                
  160.                 -- Vertical Speed Indicator
  161.                 dxDrawLine (originx+60, originy+60, originx+60, originy-60, tocolor(baser,baseg,baseb,200), 1)
  162.                 dxDrawLine (originx+57, originy-vz, originx+63, originy-vz, tocolor(needr,needg,needb,255), 2)
  163.                 dxDrawText (tostring(vz), originx+65+soff, originy-5-vz+soff, 50, 50, tocolor(shadr, shadg, shadb, 255), txtsize, "clear") --Shadow
  164.                 dxDrawText (tostring(vz), originx+65, originy-5-vz, 50, 50, tocolor(indir, indig, indib, 255), txtsize, "clear")
  165.                
  166.                
  167.                 -- Speedometer / Altimeter
  168.                 dxDrawText ("IAS: "..tostring(vxyz), originx-120+soff, originy-60+soff, 50, 50, tocolor(shadr, shadg, shadb, 255), txtsize, "clear") --Shadow
  169.                 dxDrawText ("IAS: "..tostring(vxyz), originx-120, originy-60, 50, 50, tocolor(indir, indig, indib, 255), txtsize, "clear")
  170.                 dxDrawText ("GS: "..tostring(vxy), originx-120+soff, originy-40+soff, 50, 50, tocolor(shadr, shadg, shadb, 255), txtsize, "clear") --Shadow
  171.                 dxDrawText ("GS: "..tostring(vxy), originx-120, originy-40, 50, 50, tocolor(indir, indig, indib, 255), txtsize, "clear")
  172.                 dxDrawText ("Alt: "..tostring(pz), originx+85+soff, originy-60+soff+soff, 50, 50, tocolor(shadr, shadg, shadb, 255), txtsize, "clear") --Shadow
  173.                 dxDrawText ("Alt: "..tostring(pz), originx+85, originy-60, 50, 50, tocolor(indir, indig, indib, 255), txtsize, "clear")
  174.                
  175.             end
  176.         end
  177.     end
  178. end
  179. addEventHandler("onClientRender", root, hudDrishti)
  180.  
  181.  
  182. -- Settings Window
  183. local windowHud = guiCreateWindow(screenWidth/2-200, screenHeight/2-250, 400, 500, "HUD Settings", false)
  184.     guiSetAlpha(windowHud, 0.9)
  185.     guiWindowSetSizable(windowHud, false)
  186.     guiWindowSetMovable(windowHud, true)
  187.     guiSetVisible(windowHud, false)
  188.     local buttonSave = guiCreateButton(20, 470, 170, 30, "Save", false, windowHud)
  189.     local buttonReset = guiCreateButton(210, 470, 170, 30, "Reset", false, windowHud)
  190.    
  191.     local chkbox0 = guiCreateCheckBox(20, 30, 150, 30, " Enable Advanced HUD", false, false, windowHud)
  192.     local chkbox1 = guiCreateCheckBox(20, 70, 80, 20, "GPS", true, false, windowHud)
  193.     local chkbox2 = guiCreateCheckBox(120, 70, 80, 20, "Car", true, false, windowHud)
  194.     local chkbox3 = guiCreateCheckBox(220, 70, 80, 20, "Heli", true, false, windowHud)
  195.     local chkbox4 = guiCreateCheckBox(320, 70, 80, 20, "Plane", true, false, windowHud)
  196.  
  197.     guiCreateLabel(20, 110, 120, 30, "Panel Position (A/c)", false, windowHud)
  198.     local toriginx = guiCreateEdit(180, 110, 60, 30, "0", false, windowHud)
  199.     local toriginy = guiCreateEdit(250, 110, 60, 30, "0", false, windowHud)
  200.  
  201.     guiCreateLabel(185, 150, 30, 30, "R", false, windowHud)
  202.     guiCreateLabel(255, 150, 30, 30, "G", false, windowHud)
  203.     guiCreateLabel(325, 150, 30, 30, "B", false, windowHud)
  204.     guiCreateLabel(20, 170, 150, 30, "Dial Base Color", false, windowHud)
  205.     local tbasecolorr = guiCreateEdit(180, 170, 60, 30, tostring(baser), false, windowHud)
  206.     local tbasecolorg = guiCreateEdit(250, 170, 60, 30, tostring(baseg), false, windowHud)
  207.     local tbasecolorb = guiCreateEdit(320, 170, 60, 30, tostring(baseb), false, windowHud)
  208.  
  209.     guiCreateLabel(20, 210, 150, 30, "Needle Color", false, windowHud)
  210.     local tneedcolorr = guiCreateEdit(180, 210, 60, 30, tostring(needr), false, windowHud)
  211.     local tneedcolorg = guiCreateEdit(250, 210, 60, 30, tostring(needg), false, windowHud)
  212.     local tneedcolorb = guiCreateEdit(320, 210, 60, 30, tostring(needb), false, windowHud)
  213.  
  214.     guiCreateLabel(20, 250, 150, 30, "Indicator Color", false, windowHud)
  215.     local tindicolorr = guiCreateEdit(180, 250, 60, 30, tostring(indir), false, windowHud)
  216.     local tindicolorg = guiCreateEdit(250, 250, 60, 30, tostring(indig), false, windowHud)
  217.     local tindicolorb = guiCreateEdit(320, 250, 60, 30, tostring(indib), false, windowHud)
  218.  
  219.     guiCreateLabel(20, 320, 150, 30, "Shadow Color", false, windowHud)
  220.     local tshadcolorr = guiCreateEdit(180, 320, 60, 30, tostring(shadr), false, windowHud)
  221.     local tshadcolorg = guiCreateEdit(250, 320, 60, 30, tostring(shadg), false, windowHud)
  222.     local tshadcolorb = guiCreateEdit(320, 320, 60, 30, tostring(shadb), false, windowHud)
  223.    
  224.     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"
  225.     guiCreateMemo(20, 370, 360, 80, txthelp, false, windowHud)
  226. -- /Settings Window
  227.  
  228. addCommandHandler("hud", function()
  229.     guiSetVisible(windowHud, true)
  230.     showCursor(true)
  231. end)
  232.  
  233. addEventHandler("onClientGUIClick", buttonSave, function()
  234.     local v = {}
  235.     v["originx"] = tonumber(guiGetText(toriginx))
  236.     v["originy"] = tonumber(guiGetText(toriginy))
  237.    
  238.     if (tonumber(guiGetText(tbasecolorr))>=0 and tonumber(guiGetText(tbasecolorr))<=255
  239.     and tonumber(guiGetText(tbasecolorg))>=0 and tonumber(guiGetText(tbasecolorg))<=255
  240.     and tonumber(guiGetText(tbasecolorb))>=0 and tonumber(guiGetText(tbasecolorb))<=255) then
  241.         v["baser"], v["baseg"], v["baseb"] = tonumber(guiGetText(tbasecolorr)), tonumber(guiGetText(tbasecolorg)), tonumber(guiGetText(tbasecolorb))
  242.     else
  243.         v["baser"], v["baseg"], v["baseb"] = 250, 250, 250
  244.     end
  245.    
  246.     if (tonumber(guiGetText(tindicolorr))>=0 and tonumber(guiGetText(tindicolorr))<=255
  247.     and tonumber(guiGetText(tindicolorg))>=0 and tonumber(guiGetText(tindicolorg))<=255
  248.     and tonumber(guiGetText(tindicolorb))>=0 and tonumber(guiGetText(tindicolorb))<=255) then
  249.         v["indir"], v["indig"], v["indib"] = tonumber(guiGetText(tindicolorr)), tonumber(guiGetText(tindicolorg)), tonumber(guiGetText(tindicolorb))
  250.     else
  251.         v["indir"], v["indig"], v["indib"] = 0, 250, 0
  252.     end
  253.    
  254.     if (tonumber(guiGetText(tneedcolorr))>=0 and tonumber(guiGetText(tneedcolorr))<=255
  255.     and tonumber(guiGetText(tneedcolorg))>=0 and tonumber(guiGetText(tneedcolorg))<=255
  256.     and tonumber(guiGetText(tneedcolorb))>=0 and tonumber(guiGetText(tneedcolorb))<=255) then
  257.         v["needr"], v["needg"], v["needb"] = tonumber(guiGetText(tneedcolorr)), tonumber(guiGetText(tneedcolorg)), tonumber(guiGetText(tneedcolorb))
  258.     else
  259.         v["needr"], v["needg"], v["needb"] = 0, 150, 250
  260.     end
  261.    
  262.     if (tonumber(guiGetText(tshadcolorr))>=0 and tonumber(guiGetText(tshadcolorr))<=255
  263.     and tonumber(guiGetText(tshadcolorg))>=0 and tonumber(guiGetText(tshadcolorg))<=255
  264.     and tonumber(guiGetText(tshadcolorb))>=0 and tonumber(guiGetText(tshadcolorb))<=255) then
  265.         v["shadr"], v["shadg"], v["shadb"] = tonumber(guiGetText(tshadcolorr)), tonumber(guiGetText(tshadcolorg)), tonumber(guiGetText(tshadcolorb))
  266.     else
  267.         v["shadr"], v["shadg"], v["shadb"] = 50, 50, 50
  268.     end
  269.    
  270.     v["show1"] = guiCheckBoxGetSelected(chkbox1)
  271.     v["show2"] = guiCheckBoxGetSelected(chkbox2)
  272.     v["show3"] = guiCheckBoxGetSelected(chkbox3)
  273.     v["show4"] = guiCheckBoxGetSelected(chkbox4)
  274.     v["showHud"] = guiCheckBoxGetSelected(chkbox0)
  275.  
  276.     triggerServerEvent("CIThud.saveHudSettingsData", getLocalPlayer(), v)
  277.     guiSetVisible(windowHud, false)
  278.     showCursor(false)
  279. end)
  280.  
  281. addEventHandler("onClientGUIClick", buttonReset, function()
  282.     guiSetVisible(windowHud, false)
  283.     showCursor(false)
  284.     triggerServerEvent("CIThud.saveHudSettingsData", getLocalPlayer(), false)
  285. end)
  286.  
  287.  
  288. function setData(v)
  289.     originx, originy = screenWidth/2 + v["originx"], screenHeight/2 + v["originy"]
  290.     baser, baseg, baseb = v["baser"], v["baseg"], v["baseb"]
  291.     indir, indig, indib = v["indir"], v["indig"], v["indib"]
  292.     needr, needg, needb = v["needr"], v["needg"], v["needb"]
  293.     shadr, shadg, shadb = v["shadr"], v["shadg"], v["shadb"]
  294.     show1, show2, show3, show4 = v["show1"], v["show2"], v["show3"], v["show4"]
  295.     showHud = v["showHud"]
  296.    
  297.     guiCheckBoxSetSelected(chkbox0, showHud)
  298.     guiCheckBoxSetSelected(chkbox1, show1)
  299.     guiCheckBoxSetSelected(chkbox2, show2)
  300.     guiCheckBoxSetSelected(chkbox3, show3)
  301.     guiCheckBoxSetSelected(chkbox4, show4)
  302.    
  303.     guiSetText(toriginx, tostring(originx-screenWidth/2))
  304.     guiSetText(toriginy, tostring(originy-screenHeight/2))
  305.    
  306.     guiSetText(tbasecolorr, baser)
  307.     guiSetText(tbasecolorg, baseg)
  308.     guiSetText(tbasecolorb, baseb)
  309.    
  310.     guiSetText(tneedcolorr, needr)
  311.     guiSetText(tneedcolorg, needg)
  312.     guiSetText(tneedcolorb, needb)
  313.    
  314.     guiSetText(tindicolorr, indir)
  315.     guiSetText(tindicolorg, indig)
  316.     guiSetText(tindicolorb, indib)
  317.    
  318.     guiSetText(tshadcolorr, shadr)
  319.     guiSetText(tshadcolorg, shadg)
  320.     guiSetText(tshadcolorb, shadb)
  321. end
  322. addEvent("CIThud.setHudSettingsData", true)
  323. addEventHandler("CIThud.setHudSettingsData", root, setData)
  324.  
  325.  
  326. --[[Foot Notes
  327. HUD System
  328. Script by Satadru Chique, Dedicated to CIT, CIT IG A/c, Forum A/c : Satadru Electra, Chique Electra
  329. Better known as Chique (IG/Forum Name)
  330. 10th November 2012
  331.  
  332. www.facebook.com/www.satadru or www.satadru@facebook.com
  333. ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement