Advertisement
Combreal

massWeap.lua

Dec 17th, 2014
798
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.90 KB | None | 0 0
  1. -- Test 4 weapons  ·¿· inspired from Wizard's awsomifique work on Phasor --
  2. -- It uses a Generic Weapon type also set to Normal             --
  3. -- Tested only on a Slayer gametype                  --
  4.  
  5. weapon = {}
  6. weapon[1] = "weapons\\pistol\\pistol"
  7. weapon[2] = "weapons\\shotgun\\shotgun"
  8. weapon[3] = "weapons\\sniper rifle\\sniper rifle"
  9. weapon[4] = "weapons\\rocket launcher\\rocket launcher" -- a fourth weapon can brings issue if you're holding the flag or the skull
  10.  
  11. frag_count = 3
  12. plasma_count = 3
  13. clipcount = 9999
  14. ammocount = 9999
  15. batterycount = 1 -- 0 to 1
  16.  
  17. function GetRequiredVersion()
  18.     return 200
  19. end
  20.  
  21. function OnPlayerSpawnEnd(player)
  22.     local m_objectId = getplayerobjectid(player)
  23.     if m_objectId then
  24.         local m_object = getobject(m_objectId)
  25.         if m_object then
  26.             writebyte(m_object + 0x31E, frag_count)
  27.             writebyte(m_object + 0x31F, plasma_count)
  28.             for i = 0,3 do
  29.                 local m_weaponId = readdword(m_object + 0x2F8 + i*4)
  30.                 if m_weaponId then
  31.                     local m_weapon = getobject(m_weaponId)
  32.                     if m_weapon then
  33.                         destroyobject(m_weaponId)
  34.                     end
  35.                 end
  36.             end
  37.             if (weapon[1] and weapon[1] ~= "") then -- make sure the script user isn't retarded
  38.                 if getplayer(player) then
  39.                     table = {player, clipcount, ammocount, batterycount}
  40.                     registertimer(0, "AssignLeftoverWeapons", table)
  41.                 end
  42.             end
  43.         end
  44.     end
  45. end
  46.  
  47. function AssignLeftoverWeapons(id, count, table)
  48.     local player = table[1]
  49.     local clipcount = table[2]
  50.     local ammocount = table[3]
  51.     local batterycount = table[4]
  52.     if getplayer(player) == nil then
  53.         return
  54.     end
  55.     local m_objectId = getplayerobjectid(player)
  56.     if m_objectId then
  57.         local m_object = getobject(m_objectId)
  58.         if m_object then
  59.             local m_weaponId = createobject(gettagid("weap", weapon[1]), 0, 0, false, 5, 5, 2)
  60.             if m_weaponId then
  61.                 assignweapon(player, m_weaponId)
  62.                 local m_weapon = getobject(m_weaponId)
  63.                 if m_weapon then
  64.                     writeword(m_weapon, 0x2B6, ammocount)
  65.                     writeword(m_weapon, 0x2B8, clipcount)
  66.                     writefloat(m_weapon, 0x240, math.abs(batterycount - 1))
  67.                     updateammo(m_weaponId)
  68.                 end
  69.             end
  70.             if weapon[2] and weapon[2] ~= "" then
  71.                 local m_weaponId = createobject(gettagid("weap", weapon[2]), 0, 0, false, 5, 5, 2)
  72.                 if m_weaponId then
  73.                     assignweapon(player, m_weaponId)
  74.                     local m_weapon = getobject(m_weaponId)
  75.                     if m_weapon then
  76.                         writeword(m_weapon, 0x2B6, ammocount)
  77.                         writeword(m_weapon, 0x2B8, clipcount)
  78.                         writefloat(m_weapon, 0x240, math.abs(batterycount - 1))
  79.                         updateammo(m_weaponId)
  80.                     end
  81.                 end
  82.             end
  83.             if weapon[3] and weapon[3] ~= "" then
  84.                 local m_weaponId = createobject(gettagid("weap", weapon[3]), 0, 0, false, 5, 5, 2)
  85.                 if m_weaponId then
  86.                     assignweapon(player, m_weaponId)
  87.                     local m_weapon = getobject(m_weaponId)
  88.                     if m_weapon then
  89.                         writeword(m_weapon, 0x2B6, ammocount)
  90.                         writeword(m_weapon, 0x2B8, clipcount)
  91.                         writefloat(m_weapon, 0x240, math.abs(batterycount - 1))
  92.                         updateammo(m_weaponId)
  93.                     end
  94.                 end
  95.             end
  96.             if weapon[4] and weapon[4] ~= "" then
  97.                 local m_weaponId = createobject(gettagid("weap", weapon[4]), 0, 0, false, 5, 5, 2)
  98.                 if m_weaponId then
  99.                     assignweapon(player, m_weaponId)
  100.                     local m_weapon = getobject(m_weaponId)
  101.                     if m_weapon then
  102.                         writeword(m_weapon, 0x2B6, ammocount)
  103.                         writeword(m_weapon, 0x2B8, clipcount)
  104.                         writefloat(m_weapon, 0x240, math.abs(batterycount - 1))
  105.                         updateammo(m_weaponId)
  106.                     end
  107.                 end
  108.             end
  109.         end
  110.     end
  111.     return false
  112. end
  113.  
  114. function OnDamageLookup(receiving, causing, mapId, tagdata)
  115.     local tagname, tagtype = gettaginfo(mapId)
  116.     if nofalldamage == 1 then
  117.         if tagname == "globals\\falling" then
  118.             return false
  119.         end
  120.     end
  121.     return true
  122. end
  123.  
  124. function OnObjectInteraction(player, objId, mapId)
  125.     local tag_name, tag_type = gettaginfo(mapId)
  126.     if tag_type == "weap" then
  127.         return false
  128.     end
  129.     return true
  130. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement