Advertisement
NanoBob

WES' missile gui

Mar 3rd, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.50 KB | None | 0 0
  1. addEvent("drawMissileGUI",true)
  2. addEventHandler("drawMissileGUI",getRootElement(),
  3.     function()
  4.         if getElementData(getLocalPlayer(),"playerType")=="military" or getElementData(getLocalPlayer(),"playerType")=="General" or getElementData(getLocalPlayer(),"playerType")=="SpecialForces" then
  5.             guiDrawn=true  
  6.             showCursor(true)
  7.         end
  8.     end)
  9. addEventHandler("onClientRender",getRootElement(),
  10.     function()
  11.         if guiDrawn then
  12.            
  13.            
  14.             screenx,screeny=guiGetScreenSize()
  15.             halfx=screenx/2
  16.             halfy=screeny/2
  17.            
  18.             x,y=getCursorPosition()
  19.             x=x*screenx
  20.             y=y*screeny
  21.            
  22.            
  23.             if xcoord==nil then
  24.                 xcoord=0
  25.             end
  26.             if ycoord==nil then
  27.                 ycoord=0
  28.             end
  29.             if zcoord==nil then
  30.                 zcoord=halfy-150
  31.             end
  32.            
  33.             if draggingHeigt then
  34.                 --y=y*screeny
  35.                 if y<halfy and y>halfy-300 then  
  36.                     zcoord=y
  37.                 else
  38.                 end
  39.             end
  40.            
  41.            
  42.             backGroundLine=dxDrawRectangle(halfx-320,halfy-320,640,640,tocolor(0,0,0,200),false)
  43.             backGround=dxDrawRectangle(halfx-300,halfy-300,600,600,tocolor(150,150,150,200),false)
  44.            
  45.             mapImage=dxDrawImage(halfx,halfy-300,300,300,"missileSilo/images/map.png")
  46.            
  47.             dxDrawText("X:",halfx-280,halfy-285,40,20,tocolor(255,255,255),1,"default","left","top",false,false,false)
  48.             xEdit=dxDrawRectangle(halfx-260,halfy-285,80,20,tocolor(255,255,255,255),false)
  49.             xCoord=dxDrawText(math.ceil(xcoord),halfx-255,halfy-285,80,20,tocolor(0,0,0,255),1)
  50.            
  51.             dxDrawText("Y:",halfx-280,halfy-260,40,20,tocolor(255,255,255),1,"default","left","top",false,false,false)
  52.             yEdit=dxDrawRectangle(halfx-260,halfy-260,80,20,tocolor(255,255,255,255),false)
  53.             yCoord=dxDrawText(math.ceil(ycoord),halfx-255,halfy-260,80,20,tocolor(0,0,0,255),1)
  54.            
  55.             dxDrawText("Detonation Height:",halfx-280,halfy-220,40,20,tocolor(255,255,255),1,"default","left","top",false,false,false)
  56.             zEdit=dxDrawRectangle(halfx-280,halfy-200,100,20,tocolor(255,255,255,255),false)
  57.             zCoord=dxDrawText(math.ceil((zcoord*-1+halfy)/3),halfx-275,halfy-200,80,20,tocolor(0,0,0,255),1)
  58.            
  59.             dettonationHeightBar2=dxDrawRectangle(halfx-65,halfy-305,50,310,tocolor(0,0,0,100),false)
  60.             dettonationHeightBar=dxDrawRectangle(halfx-60,halfy-300,40,300,tocolor(240,240,240,100),false)
  61.             heighLine=dxDrawLine(halfx-60,zcoord,halfx-20,zcoord,tocolor(255,0,0,255),10,false)
  62.            
  63.             if x>halfx-200 and x<halfx-100 and y>halfy+250 and y<halfy+300 then
  64.                 red=100
  65.                 green=100
  66.                 blue=0
  67.             else
  68.                 red=0
  69.                 green=0
  70.                 blue=0
  71.             end
  72.             dxDrawText("Close",halfx-200,halfy+250,halfx-100,halfy+300,tocolor(red,green,blue),3,"default","center","center",false,false,false)
  73.            
  74.             if x>halfx+100 and x<halfx+200 and y>halfy+250 and y<halfy+300 then
  75.                 red=100
  76.                 green=100
  77.                 blue=0
  78.             else
  79.                 red=0
  80.                 green=0
  81.                 blue=0
  82.             end
  83.             dxDrawText("Fire!",halfx+100,halfy+250,halfx+200,halfy+300,tocolor(red,green,blue),3,"default","center","center",false,false,false)
  84.         elseif bigMapDrawn  then
  85.             screenx,screeny=guiGetScreenSize()
  86.             halfx=screenx/2
  87.             halfy=screeny/2
  88.            
  89.             x,y=getCursorPosition()
  90.             x=x*screenx
  91.             y=y*screeny
  92.            
  93.            
  94.             backGroundLine=dxDrawRectangle(halfx-320,halfy-320,640,740,tocolor(0,0,0,200),false)
  95.             backGround=dxDrawRectangle(halfx-300,halfy-300,600,700,tocolor(150,150,150,200),false)
  96.             mapImage=dxDrawImage(halfx-300,halfy-300,600,600,"missileSilo/images/map.png")
  97.            
  98.             if bigMapChoosing then
  99.                 if x>halfx-300 and x<halfx+300 and y>halfy-300 and y<halfy+300 then
  100.                     tempx=x-(halfx)
  101.                     tempy=y-(halfy)
  102.                     xcoord=tempx*10
  103.                     ycoord=tempy*-10
  104.                     currentx=x-20
  105.                     currenty=y-20
  106.                 end
  107.             end
  108.             if currentx==nil and currenty==nil then
  109.                 currentx=halfx
  110.                 currenty=halfy
  111.             end
  112.             dxDrawImage(currentx,currenty,40,40,"missileSIlo/images/crosshair.png")
  113.             if x>halfx-200 and x<halfx-100 and y>halfy+350 and y<halfy+400 then
  114.                 red=100
  115.                 green=100
  116.                 blue=0
  117.             else
  118.                 red=0
  119.                 green=0
  120.                 blue=0
  121.             end
  122.             dxDrawText("Close",halfx-200,halfy+350,halfx-100,halfy+400,tocolor(red,green,blue),3,"default","center","center",false,false,false)
  123.            
  124.            
  125.            
  126.         end
  127.     end)
  128.    
  129. addEventHandler("onClientClick",getRootElement(),
  130.     function(button,state,cursorx,cursory)
  131.    
  132.         if button=="left" and bigMapDrawn then
  133.             if cursorx>halfx-300 and cursorx<halfx+300 and cursory>halfy-300 and cursory<halfy+300 then
  134.                 if state=="down" then
  135.                     bigMapChoosing=true
  136.                 else   
  137.                     bigMapChoosing=false
  138.                 end
  139.             else
  140.                 bigMapChoosing=false
  141.                 bigMapDrawn=false
  142.                 guiDrawn=true
  143.             end
  144.            
  145.            
  146.            
  147.         elseif button=="left" and guiDrawn then
  148.             if state=="up" then
  149.                 draggingHeigt=false
  150.                 bigMapChoosing=false
  151.                 bigMapDrawn=false
  152.             end
  153.            
  154.             if cursorx>halfx-60 and cursorx<halfx-20 and cursory<halfy and cursory>halfy-300 then --dettonationHeightBar
  155.                 if state=="down" then
  156.                     draggingHeigt=true
  157.                 else
  158.                     draggingHeigt=false
  159.                 end
  160.                
  161.             end
  162.             if cursorx>halfx-200 and cursorx<halfx-100 and cursory>halfy+250 and cursory<halfy+300 then
  163.                 guiDrawn=false
  164.                 showCursor(false)
  165.             end
  166.            
  167.             if cursorx>halfx+100 and cursorx<halfx+200 and cursory>halfy+250 and cursory<halfy+300 and state=="down" then
  168.                 triggerServerEvent("fireMissile",getRootElement(),xcoord,ycoord,(zcoord*-1+halfy)/3)
  169.                 targetBlip=createBlip(xcoord,ycoord,zcoord,41)
  170.                 setTimer(function(targetBlip) destroyElement(targetBlip) missile=nil end,58000,1,targetBlip)
  171.             end
  172.            
  173.             if cursorx>halfx and cursorx<halfx+300 and cursory<halfy and cursory>halfy-300 then
  174.                 guiDrawn=false
  175.                 bigMapDrawn=true
  176.                
  177.             end
  178.         end        
  179.     end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement