Advertisement
NanoBob

weapon display

Jul 19th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.82 KB | None | 0 0
  1. -- [25]={true,false,['bone']=,['x']=,['y']=,['z']=,['rx']=,['ry']=,['rz']=,},
  2.  
  3. primaryWeapons={
  4. --Default: 3,-0.1,-0.13,0.1,0,55,0
  5. [25]={true,true},
  6. [27]={true,true},
  7. [35]={true,false,['bone']=3,['x']=-0.1,['y']=-0.13,['z']=-0.2,['rx']=0,['ry']=55,['rz']=0,},
  8. [37]={true,true},
  9. [36]={true,true},
  10. [38]={true,true},
  11. [33]={true,true},
  12. [34]={true,true},
  13. [29]={true,true},
  14. [30]={true,true},
  15. [31]={true,true},
  16. }
  17. secondaryWeapons={
  18. --Default: 13,-0.045,0,0,0,-90,90
  19. [3]={true,false,['bone']=13,['x']=0.35,['y']=0,['z']=0,['rx']=0,['ry']=0,['rz']=90,},
  20. [4]={true,false,['bone']=13,['x']=0.35,['y']=0,['z']=0,['rx']=0,['ry']=0,['rz']=90,},
  21. [5]={true,false,['bone']=13,['x']=0.35,['y']=0,['z']=0,['rx']=0,['ry']=0,['rz']=90,},
  22. [8]={true,true},
  23. [22]={true,true},
  24. [23]={true,true},
  25. [24]={true,true},
  26. [28]={true,true},
  27. [32]={true,true},
  28. [26]={true,true},
  29. }
  30. equipment={
  31. --Default:
  32. [16]={true,true},
  33. [17]={true,true},
  34. [18]={true,true},
  35. [39]={true,true},
  36. [43]={true,true},
  37. [44]={true,true},
  38. [45]={true,true},
  39. [46]={true,true},
  40. }
  41.  
  42. weaponModels={
  43. [1]=331,
  44. [2]=333,
  45. [3]=334,
  46. [4]=335,
  47. [5]=336,
  48. [6]=337,
  49. [7]=338,
  50. [8]=339,
  51. [9]=341,
  52. [10]=321,
  53. [11]=322,
  54. [12]=323,
  55. [13]=nil,
  56. [14]=325,
  57. [15]=326,
  58. [16]=342,
  59. [17]=343,
  60. [18]=344,
  61. [19]=nil,
  62. [20]=nil,
  63. [21]=nil,
  64. [22]=346,
  65. [23]=347,
  66. [24]=348,
  67. [25]=349,
  68. [26]=350,
  69. [27]=351,
  70. [28]=352,
  71. [29]=353,
  72. [30]=355,
  73. [31]=356,
  74. [32]=372,
  75. [33]=357,
  76. [34]=358,
  77. [35]=359,
  78. [36]=360,
  79. [37]=361,
  80. [38]=362,
  81. [39]=363,
  82. [40]=364,
  83. [41]=365,
  84. [42]=366,
  85. [43]=367,
  86. [44]=368,
  87. [45]=369,
  88. [46]=371,
  89. }
  90.  
  91. local visibleWeapons={}
  92.  
  93. function displayWeapons()
  94.     local player=source
  95.     setTimer(function()    
  96.         for id,element in pairs(visibleWeapons) do
  97.             if isElement(element) then
  98.                 destroyElement(element)
  99.             end
  100.         end
  101.         visibleWeapons={}
  102.         currentWeapons={}
  103.         for i=1,12 do
  104.             weapon=getPedWeapon(player,i)
  105.             ammo=getPedTotalAmmo(player,i)
  106.             if weapon==getPedWeapon(player) then
  107.                 currentWeapon=weapon
  108.             else
  109.                 if ammo>0 then
  110.                     currentWeapons[weapon]=true
  111.                 end
  112.             end
  113.         end
  114.        
  115.         for weapon,_ in pairs(currentWeapons) do
  116.             if primaryWeapons[weapon]~=nil then
  117.                 if primaryWeapons[weapon][1] then
  118.                     visibleObject=createObject(weaponModels[weapon],0,0,0)
  119.                     if primaryWeapons[weapon][2] then
  120.                         exports.bone_attach:attachElementToBone(visibleObject,player,3,-0.1,-0.13,0.1,0,235-180,0)
  121.                     else
  122.                         positioning=primaryWeapons[weapon]
  123.                         exports.bone_attach:attachElementToBone(visibleObject,player,positioning["bone"],positioning["x"],positioning["y"],positioning["z"],positioning["rx"],positioning["ry"],positioning["rz"])
  124.                     end
  125.                 end
  126.             end
  127.             if secondaryWeapons[weapon]~=nil then
  128.                 if secondaryWeapons[weapon][1] then
  129.                     visibleObject=createObject(weaponModels[weapon],0,0,0)
  130.                     if secondaryWeapons[weapon][2] then
  131.                         attached=exports.bone_attach:attachElementToBone(visibleObject,player,13,-0.045,0,0,0,-90,90)
  132.                     else
  133.                         positioning=secondaryWeapons[weapon]
  134.                         exports.bone_attach:attachElementToBone(visibleObject,player,positioning["bone"],positioning["x"],positioning["y"],positioning["z"],positioning["rx"],positioning["ry"],positioning["rz"])
  135.                     end
  136.                 end
  137.             end
  138.             if equipment[weapon]~=nil then
  139.                 if equipment[weapon][1] then
  140.                     visibleObject=createObject(weaponModels[weapon],0,0,0)
  141.                     if equipment[weapon][2] then
  142.                         exports.bone_attach:attachElementToBone(visibleObject,player,5,0,0,0,0,-90,0)
  143.                     else
  144.                         positioning=equipment[weapon]
  145.                         exports.bone_attach:attachElementToBone(visibleObject,player,positioning["bone"],positioning["x"],positioning["y"],positioning["z"],positioning["rx"],positioning["ry"],positioning["rz"])
  146.                     end
  147.                 end
  148.             end
  149.             visibleWeapons[#visibleWeapons+1]=visibleObject
  150.         end
  151.     end,50,1)  
  152. end
  153.  
  154. addEventHandler("onPlayerWeaponSwitch",getRootElement(),displayWeapons)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement