Advertisement
Guest User

Untitled

a guest
Oct 20th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.96 KB | None | 0 0
  1. local screenWidth, screenHeight = guiGetScreenSize()
  2.  
  3. local currentWidth, currentHeight = 250, 125
  4. local currentOutline = 4
  5. local gapBetween = 32
  6.  
  7. local left = (screenWidth/2) - (currentWidth/2)
  8. local top = (screenHeight/2) - (currentHeight/2)
  9.  
  10. local controls = { "aim_weapon","radio_next","radio_previous", "fire", "vehicle_fire", "vehicle_secondary_fire" }
  11.  
  12. local kepszam = 0
  13. local weaponUpper = 0
  14. local weaponLower = 0
  15. local mutat = false
  16.  
  17. local weaponslot = 0
  18.  
  19. local nextAmmo = nil
  20. local currentAmmo = nil
  21. local previousAmmo = nil
  22.  
  23. function getNextWeapon(cSlot)
  24.     local tempSlot = {}
  25.     local curSlot
  26.     if cSlot then
  27.         curSlot = cSlot
  28.     else
  29.         curSlot = getPedWeaponSlot(localPlayer)
  30.     end
  31.     if (curSlot == 0) and (getPedWeapon(localPlayer) == 0 or getPedWeapon(localPlayer) == 1) then
  32.         curSlot = 13
  33.     end
  34.      
  35.     tempSlot["ID"] = 13
  36.     repeat
  37.         tempSlot["ID"] = tempSlot["ID"]-1
  38.     until (tempSlot["ID"] < curSlot) and not (tempSlot["ID"] ~= 0 and getPedWeapon(localPlayer, tempSlot["ID"]) == 0)
  39.     return getPedWeapon(localPlayer, tempSlot["ID"])
  40. end
  41.  
  42. function getPreviousWeapon(cSlot)
  43.     local tempSlot = {}
  44.     local curSlot
  45.     if cSlot then
  46.         curSlot = cSlot
  47.     else
  48.         curSlot = getPedWeaponSlot(localPlayer)
  49.     end
  50.     if (curSlot == 12) then
  51.         curSlot = - 1
  52.     end
  53.      
  54.     tempSlot["ID"] = - 1
  55.     repeat
  56.         tempSlot["ID"] = tempSlot["ID"] + 1
  57.         if tempSlot["ID"] == 13 then
  58.             tempSlot["ID"] = -1
  59.             curSlot = -1
  60.         end
  61.     until (tempSlot["ID"] > curSlot) and not (tempSlot["ID"] ~= 0 and getPedWeapon(localPlayer, tempSlot["ID"]) == 0)
  62.     return getPedWeapon(localPlayer, tempSlot["ID"])
  63. end
  64.  
  65. local isRendered
  66.  
  67. local weaps = {
  68.     ["old"] = "",
  69.     ["curr"] = "",
  70.     ["next"] = "",
  71.     ["prev"] = ""
  72. }
  73.  
  74.  
  75. function selectWeapon()
  76.         weaps["next"] = getNextWeapon(getSlotFromWeapon(weaps["curr"]))
  77.         weaps["prev"] = getPreviousWeapon(getSlotFromWeapon(weaps["curr"]))
  78.        
  79.         local textx = left + (currentWidth / 2)
  80.         local texty = (top + (currentHeight / 2))
  81.         dxDrawText( "Fegyvereid",textx, texty - 215, textx, texty - 215, tocolor(200,0,100,255), 2, "default", "center", "center", false,false,true)
  82.        
  83.         if weaps["old"] == weaps["curr"] then
  84.             dxDrawRectangle ( left - currentOutline, top - currentOutline, currentWidth + currentOutline*2, currentHeight + currentOutline*2, tocolor ( 200, 0, 100, 180 ) )
  85.         end
  86.         dxDrawRectangle ( left, top, currentWidth, currentHeight, tocolor ( 0, 0, 0, 180 ) )
  87.        
  88.         dxDrawRectangle ( left + 26, top + 48 - currentHeight - gapBetween, currentWidth - 52, currentHeight - 32, tocolor ( 0, 0, 0, 180 ) )
  89.         dxDrawRectangle ( left + 26, top - 16 + currentHeight + gapBetween, currentWidth - 52, currentHeight - 32, tocolor ( 0, 0, 0, 180 ) )
  90.        
  91.        
  92.         dxDrawImage(left + 26, top - currentHeight + gapBetween, 256-128, 128-64, "weap/".. weaps["next"] ..".png", 0, 0, 0, tocolor(255, 255, 255, 100), true)
  93.         --nextAmmo = getPedTotalAmmo(getLocalPlayer(), getSlotFromWeapon(nextWeap)) - getPedAmmoInClip(getLocalPlayer(), getSlotFromWeapon(nextWeap)) .. " #FFFFFF/ " .. getPedAmmoInClip(getLocalPlayer(), getSlotFromWeapon(nextWeapon))
  94.         if nextAmmo then --and weaponslot > 0 then
  95.             dxDrawText( "".. nextAmmo .."",textx, texty - 156, textx, texty - 156, tocolor(200,0,100,100), 1, "default", "center", "center", false,false,true,true)
  96.         end
  97.        
  98.        
  99.         dxDrawImage(left, top, 256, 128, "weap/".. weaps["curr"] ..".png", 0, 0, 0, tocolor(255, 255, 255, 255), true)
  100.         --currentAmmo = getPedTotalAmmo ( getLocalPlayer(), weaponslot ) - getPedAmmoInClip(getLocalPlayer(), weaponslot) .. " #FFFFFF/ " .. getPedAmmoInClip(getLocalPlayer(), weaponslot)
  101.         if currentAmmo then --and weaponslot > 0 then
  102.             dxDrawText( "".. currentAmmo .."",textx, texty + 48, textx, texty + 48, tocolor(200,0,100,255), 1.5, "default", "center", "center", false,false,true,true)
  103.         end
  104.        
  105.        
  106.         dxDrawImage(left + 26, top + currentHeight + gapBetween, 256-128, 128-64, "weap/".. weaps["prev"] ..".png", 0, 0, 0, tocolor(255, 255, 255, 100), true)
  107.         --previousAmmo = getPedTotalAmmo(getLocalPlayer(), getSlotFromWeapon(prevWeap)) - getPedAmmoInClip(getLocalPlayer(), getSlotFromWeapon(prevWeap)) .. " #FFFFFF/ " .. getPedAmmoInClip(getLocalPlayer(), getSlotFromWeapon(previousWeapon))
  108.         if previousAmmo then --and weaponslot > 0 then
  109.             dxDrawText( "".. previousAmmo .."",textx, texty + 156, textx, texty + 156, tocolor(200,0,100,100), 1, "default", "center", "center", false,false,true,true)
  110.         end
  111.  
  112. end
  113.  
  114. addEventHandler("onClientResourceStart", resourceRoot, function()
  115.  
  116. end)
  117.  
  118. addEventHandler( "onClientResourceStart", getRootElement( ),
  119.     function ( )
  120.         toggleControl ( "next_weapon", false )
  121.         toggleControl ( "previous_weapon", false )
  122.     end
  123. );
  124.  
  125. function changeNextWeapon()
  126.  
  127.     if weaps["curr"] == "" then
  128.         weaps["old"] = getPedWeapon(getLocalPlayer())
  129.         weaps["curr"] = weaps["old"]
  130.     else
  131.         weaps["curr"] = getNextWeapon(getSlotFromWeapon(weaps["curr"]))
  132.     end
  133.    
  134.     if not isRendered then
  135.         addEventHandler("onClientRender", root, selectWeapon)
  136.         isRendered = not isRendered
  137.         toggleControl("fire", false)
  138.         toggleControl("aim", false)
  139.     end
  140. end
  141. function changePrevWeapon()
  142.     if weaps["curr"] == "" then
  143.         weaps["old"] = getPedWeapon(getLocalPlayer())
  144.         weaps["curr"] = weaps["old"]
  145.     else
  146.         weaps["curr"] = getPreviousWeapon(getSlotFromWeapon(weaps["curr"]))
  147.     end
  148.     if not isRendered then
  149.         addEventHandler("onClientRender", root, selectWeapon)
  150.         isRendered = not isRendered
  151.         toggleControl("fire", false)
  152.         toggleControl("aim", false)
  153.     end
  154. end
  155.  
  156. function changeWeap()
  157.    
  158.     setPedWeaponSlot(localPlayer, getSlotFromWeapon(weaps["curr"]))
  159.     toggleControl("fire", true)
  160.     toggleControl("aim", true)
  161.     removeEventHandler("onClientRender", root, selectWeapon)
  162.     isRendered = not isRendered
  163.     weaps["curr"] = ""
  164.  
  165. end
  166.  
  167. bindKey("mouse_wheel_up", "both", changeNextWeapon)
  168. bindKey("mouse_wheel_down", "both", changePrevWeapon)
  169. bindKey("mouse1", "up", changeWeap)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement