LUA 197
V2+ Custom Spawn Weapons 2.0 By xdedeone on 26th February 2019 05:26:15 PM
  1. -- Custom Spawn Weapons 2.0
  2.  
  3. -- Description: Have players spawn with 0 to 4 weapons and custom assign the weapons they spawn with on each map, under each gametype. Script also allows players to be able to hold flag or oddball even if they already have 4 weapons in hand (new feauture).
  4.  
  5. -- Thanks to Nuggets, Wizard and Chalonic for their help.
  6. -- Special thanks to Nuggets for his OnWeaponDrop function, without which an important feature of the script would not have been possible.
  7.  
  8. --***************** REFERENCE NAMES, DO NOT EDIT HERE ************************--
  9. -- These are the list of weapon names you can use to specify the weapons you want.
  10. -- again, do NOT edit here.
  11. arifle = "weapons\\assault rifle\\assault rifle"
  12. prifle = "weapons\\plasma rifle\\plasma rifle"
  13. pistol = "weapons\\pistol\\pistol"
  14. ppistol = "weapons\\plasma pistol\\plasma pistol"
  15. needler = "weapons\\needler\\mp_needler"
  16. shotgun = "weapons\\shotgun\\shotgun"
  17. sniper = "weapons\\sniper rifle\\sniper rifle"
  18. fuelrod = "weapons\\plasma_cannon\\plasma_cannon"
  19. rocket = "weapons\\rocket launcher\\rocket launcher"
  20. flamethrower = "weapons\\flamethrower\\flamethrower"
  21.  
  22. --**************************** EDIT HERE **************************************--
  23. -- Change the weapons you want to assign and also the amount of weapons.
  24. -- PLAYERS WILL BE ABLE TO HOLD THE FLAG/ODDBALL EVEN IF THEY HAVE 4 WEAPONS IN HAND, so don't worry about that.
  25. -- Maximum no. of slots a player has for his weapons is 4, so adding more than 4 weapons in the tables will do nothing, and the extras will not be noticed by the script.
  26. -- To specify no weapon (empty slot), you can simply not enter a weapon name (leave it blank) or enter nil.
  27.  
  28. -- EDIT ONLY THE VALUES(WEAPON NAMES) INSIDE THE BRACKETS, LIKE THE EXAMPLES GIVEN. Do NOT edit the map and gametype names in map_gametype
  29. -- THE SYNTAX IS: map_gametype = {weapon1, weapon2, weapon3, weapon4}
  30.  
  31. -- Capture The Flag -------------------------------------------------------
  32. beavercreek_CTF = {prifle, arifle, nil}
  33. bloodgulch_CTF = {prifle, arifle, sniper, rocket}
  34. boardingaction_CTF = {prifle, fuelrod, sniper}
  35. carousel_CTF = {pistol, arifle, nil}
  36. chillout_CTF = {ppistol, prifle, shotgun}
  37. damnation_CTF = {prifle, needler, flamethrower}
  38. dangercanyon_CTF = {pistol, arifle, sniper}
  39. deathisland_CTF = {pistol, arifle, sniper}
  40. gephyrophobia_CTF = {pistol, arifle, sniper}
  41. hangemhigh_CTF = {ppistol, prifle, arifle}
  42. icefields_CTF = {prifle, arifle, sniper}
  43. infinity_CTF = {pistol, arifle, sniper}
  44. longest_CTF = {pistol, nil, nil}
  45. prisoner_CTF = {pistol, shotgun, sniper}
  46. putput_CTF = {shotgun}
  47. ratrace_CTF = {pistol, arifle, nil}
  48. sidewinder_CTF = {pistol, arifle, sniper}
  49. timberland_CTF = {pistol, arifle, sniper}
  50. wizard_CTF = {ppistol, prifle, pistol}
  51. --------------------------------------------------------------------------
  52.  
  53. -- Slayer ----------------------------------------------------------------
  54. beavercreek_Slayer = {prifle, arifle, nil, nil}
  55. bloodgulch_Slayer = {fuelrod, nil, nil, nil}
  56. boardingaction_Slayer = {prifle, fuelrod, sniper, nil}
  57. carousel_Slayer = {pistol, arifle, nil, nil}
  58. chillout_Slayer = {ppistol, prifle, shotgun, nil}
  59. damnation_Slayer = {prifle, needler, flamethrower, shotgun}
  60. dangercanyon_Slayer = {pistol, arifle, sniper, rocket}
  61. deathisland_Slayer = {pistol, arifle, sniper, rocket}
  62. gephyrophobia_Slayer = {pistol, arifle, sniper, rocket}
  63. hangemhigh_Slayer = {ppistol, prifle, arifle, sniper}
  64. icefields_Slayer = {prifle, arifle, sniper, rocket}
  65. infinity_Slayer = {pistol, arifle, sniper, rocket}
  66. longest_Slayer = {pistol, nil, nil, nil}
  67. prisoner_Slayer = {pistol, shotgun, sniper, nil}
  68. putput_Slayer = {shotgun, nil, nil, nil}
  69. ratrace_Slayer = {pistol, arifle, nil, nil}
  70. sidewinder_Slayer = {pistol, arifle, sniper, rocket}
  71. timberland_Slayer = {pistol, arifle, sniper, rocket}
  72. wizard_Slayer = {ppistol, prifle, pistol, nil}
  73. --------------------------------------------------------------------------
  74.  
  75. -- Oddball ---------------------------------------------------------------
  76. beavercreek_Oddball = {prifle, arifle, nil}
  77. bloodgulch_Oddball = {shotgun, nil, nil}
  78. boardingaction_Oddball = {prifle, fuelrod, sniper}
  79. carousel_Oddball = {pistol, arifle, nil}
  80. chillout_Oddball = {ppistol, prifle, shotgun}
  81. damnation_Oddball = {prifle, needler, flamethrower}
  82. dangercanyon_Oddball = {pistol, arifle, sniper}
  83. deathisland_Oddball = {pistol, arifle, sniper}
  84. gephyrophobia_Oddball = {pistol, arifle, sniper}
  85. hangemhigh_Oddball = {ppistol, prifle, arifle}
  86. icefields_Oddball = {prifle, arifle, sniper}
  87. infinity_Oddball = {pistol, arifle, sniper}
  88. longest_Oddball = {pistol, nil, nil}
  89. prisoner_Oddball = {pistol, shotgun, sniper}
  90. putput_Oddball = {shotgun, nil, nil}
  91. ratrace_Oddball = {pistol, arifle, nil}
  92. sidewinder_Oddball = {pistol, arifle, sniper}
  93. timberland_Oddball = {pistol, arifle, sniper}
  94. wizard_Oddball = {ppistol, prifle, pistol}
  95. --------------------------------------------------------------------------
  96.  
  97. -- King Of The Hill ------------------------------------------------------
  98. beavercreek_KOTH = {prifle, arifle, nil, nil}
  99. bloodgulch_KOTH = {flamethrower, nil, nil, nil}
  100. boardingaction_KOTH = {prifle, fuelrod, sniper, nil}
  101. carousel_KOTH = {pistol, arifle, nil, nil}
  102. chillout_KOTH = {ppistol, prifle, shotgun, nil}
  103. damnation_KOTH = {prifle, needler, flamethrower, shotgun}
  104. dangercanyon_KOTH = {pistol, arifle, sniper, rocket}
  105. deathisland_KOTH = {pistol, arifle, sniper, rocket}
  106. gephyrophobia_KOTH = {pistol, arifle, sniper, rocket}
  107. hangemhigh_KOTH = {ppistol, prifle, arifle, sniper}
  108. icefields_KOTH = {prifle, arifle, sniper, rocket}
  109. infinity_KOTH = {pistol, arifle, sniper, rocket}
  110. longest_KOTH = {pistol, nil, nil, nil}
  111. prisoner_KOTH = {pistol, shotgun, sniper, nil}
  112. putput_KOTH = {shotgun, nil, nil, nil}
  113. ratrace_KOTH = {pistol, arifle, nil, nil}
  114. sidewinder_KOTH = {pistol, arifle, sniper, rocket}
  115. timberland_KOTH = {pistol, arifle, sniper, rocket}
  116. wizard_KOTH = {ppistol, prifle, pistol, nil}
  117. --------------------------------------------------------------------------
  118.  
  119. -- Race ------------------------------------------------------------------
  120. beavercreek_Race = {prifle, arifle, nil, nil}
  121. bloodgulch_Race = {pistol, nil, nil, nil}
  122. boardingaction_Race = {prifle, fuelrod, sniper, nil}
  123. carousel_Race = {pistol, arifle, nil, nil}
  124. chillout_Race = {ppistol, prifle, shotgun, nil}
  125. damnation_Race = {prifle, needler, flamethrower, shotgun}
  126. dangercanyon_Race = {pistol, arifle, sniper, rocket}
  127. deathisland_Race = {pistol, arifle, sniper, rocket}
  128. gephyrophobia_Race = {pistol, arifle, sniper, rocket}
  129. hangemhigh_Race = {ppistol, prifle, arifle, sniper}
  130. icefields_Race = {prifle, arifle, sniper, rocket}
  131. infinity_Race = {pistol, arifle, sniper, rocket}
  132. longest_Race = {pistol, nil, nil, nil}
  133. prisoner_Race = {pistol, shotgun, sniper, nil}
  134. putput_Race = {shotgun, nil, nil, nil}
  135. ratrace_Race = {pistol, arifle, nil, nil}
  136. sidewinder_Race = {pistol, arifle, sniper, rocket}
  137. timberland_Race = {pistol, arifle, sniper, rocket}
  138. wizard_Race = {ppistol, prifle, pistol, nil}
  139. --------------------------------------------------------------------------
  140.  
  141.  
  142. --*****************************************EDITING STOPS*************************************************--
  143.  
  144.  
  145. ------------------------------Don't need to touch anything below here-------------------------------------------
  146.  
  147. CTF = {beavercreek_CTF, bloodgulch_CTF, boardingaction_CTF, carousel_CTF,
  148. chillout_CTF, damnation_CTF, dangercanyon_CTF, deathisland_CTF,
  149. gephyrophobia_CTF, hangemhigh_CTF, icefields_CTF, infinity_CTF, longest_CTF,
  150. prisoner_CTF, putput_CTF, ratrace_CTF, sidewinder_CTF, timberland_CTF, wizard_CTF}
  151.  
  152. Slayer = {beavercreek_Slayer, bloodgulch_Slayer, boardingaction_Slayer,
  153. carousel_Slayer, chillout_Slayer, damnation_Slayer, dangercanyon_Slayer,
  154. deathisland_Slayer, gephyrophobia_Slayer, hangemhigh_Slayer,
  155. icefields_Slayer, infinity_Slayer, longest_Slayer, prisoner_Slayer,
  156. putput_Slayer, ratrace_Slayer, sidewinder_Slayer, timberland_Slayer, wizard_Slayer}
  157.  
  158. Oddball = {beavercreek_Oddball, bloodgulch_Oddball,
  159. boardingaction_Oddball, carousel_Oddball, chillout_Oddball,
  160. damnation_Oddball, dangercanyon_Oddball, deathisland_Oddball,
  161. gephyrophobia_Oddball, hangemhigh_Oddball, icefields_Oddball,
  162. infinity_Oddball, longest_Oddball, prisoner_Oddball, putput_Oddball,
  163. ratrace_Oddball, sidewinder_Oddball, timberland_Oddball, wizard_Oddball}
  164.  
  165. KOTH = {beavercreek_KOTH, bloodgulch_KOTH, boardingaction_KOTH,
  166. carousel_KOTH, chillout_KOTH, damnation_KOTH, dangercanyon_KOTH,
  167. deathisland_KOTH, gephyrophobia_KOTH, hangemhigh_KOTH,
  168. icefields_KOTH, infinity_KOTH, longest_KOTH, prisoner_KOTH,
  169. putput_KOTH, ratrace_KOTH, sidewinder_KOTH, timberland_KOTH, wizard_KOTH}
  170.  
  171. Race = {beavercreek_Race, bloodgulch_Race, boardingaction_Race,
  172. carousel_Race, chillout_Race, damnation_Race, dangercanyon_Race,
  173. deathisland_Race, gephyrophobia_Race, hangemhigh_Race, icefields_Race,
  174. infinity_Race, longest_Race, prisoner_Race, putput_Race,
  175. ratrace_Race, sidewinder_Race, timberland_Race, wizard_Race}
  176.  
  177. spawnweaps = CTF, Slayer, Oddball, KOTH, Race
  178. weapons = {}
  179. restore_weap = {}
  180.  
  181. function GetRequiredVersion()
  182.         return 200
  183. end
  184.  
  185. function OnScriptLoad(processId, game, persistent)
  186.         if game == "PC" then
  187.                 gametype_base = 0x671340
  188.                 ctf_globals = 0x639B98
  189.         elseif game == "CE" then
  190.                 ctf_globals = 0x5BDBB8
  191.                 gametype_base = 0x5F5498
  192.         end
  193.         local gametype_game = readbyte(gametype_base, 0x30)
  194.         if gametype_game == 1 then spawnweaps = CTF
  195.         elseif gametype_game == 2 then spawnweaps = Slayer
  196.         elseif gametype_game == 3 then spawnweaps = Oddball
  197.         elseif gametype_game == 4 then spawnweaps = KOTH
  198.         elseif gametype_game == 5 then spawnweaps = Race
  199.         end
  200.         WeaponsMonitor = registertimer(12, "WeaponMonitor")
  201. end
  202.  
  203. function OnScriptUnload()
  204.         if WeaponsMonitor then
  205.                 removetimer(WeaponsMonitor)
  206.         end
  207. end
  208.  
  209. function OnNewGame(map)
  210.         if map == "beavercreek" then
  211.                 weapon1 = spawnweaps[1][1]
  212.                 weapon2 = spawnweaps[1][2]
  213.                 weapon3 = spawnweaps[1][3]
  214.                 weapon4 = spawnweaps[1][4]
  215.         elseif map == "bloodgulch" then
  216.                 weapon1 = spawnweaps[2][1]
  217.                 weapon2 = spawnweaps[2][2]
  218.                 weapon3 = spawnweaps[2][3]
  219.                 weapon4 = spawnweaps[2][4]
  220.         elseif map == "boardingaction" then
  221.                 weapon1 = spawnweaps[3][1]
  222.                 weapon2 = spawnweaps[3][2]
  223.                 weapon3 = spawnweaps[3][3]
  224.                 weapon4 = spawnweaps[3][4]
  225.         elseif map == "carousel" then
  226.                 weapon1 = spawnweaps[4][1]
  227.                 weapon2 = spawnweaps[4][2]
  228.                 weapon3 = spawnweaps[4][3]
  229.                 weapon4 = spawnweaps[4][4]
  230.         elseif map == "chillout" then
  231.                 weapon1 = spawnweaps[5][1]
  232.                 weapon2 = spawnweaps[5][2]
  233.                 weapon3 = spawnweaps[5][3]
  234.                 weapon4 = spawnweaps[5][4]
  235.         elseif map == "damnation" then
  236.                 weapon1 = spawnweaps[6][1]
  237.                 weapon2 = spawnweaps[6][2]
  238.                 weapon3 = spawnweaps[6][3]
  239.                 weapon4 = spawnweaps[6][4]
  240.         elseif map == "dangercanyon" then
  241.                 weapon1 = spawnweaps[7][1]
  242.                 weapon2 = spawnweaps[7][2]
  243.                 weapon3 = spawnweaps[7][3]
  244.                 weapon4 = spawnweaps[7][4]
  245.         elseif map == "deathisland" then
  246.                 weapon1 = spawnweaps[8][1]
  247.                 weapon2 = spawnweaps[8][2]
  248.                 weapon3 = spawnweaps[8][3]
  249.                 weapon4 = spawnweaps[8][4]
  250.         elseif map == "gephyrophobia" then
  251.                 weapon1 = spawnweaps[9][1]
  252.                 weapon2 = spawnweaps[9][2]
  253.                 weapon3 = spawnweaps[9][3]
  254.                 weapon4 = spawnweaps[9][4]
  255.         elseif map == "hangemhigh" then
  256.                 weapon1 = spawnweaps[10][1]
  257.                 weapon2 = spawnweaps[10][2]
  258.                 weapon3 = spawnweaps[10][3]
  259.                 weapon4 = spawnweaps[10][4]
  260.         elseif map == "icefields" then
  261.                 weapon1 = spawnweaps[11][1]
  262.                 weapon2 = spawnweaps[11][2]
  263.                 weapon3 = spawnweaps[11][3]
  264.                 weapon4 = spawnweaps[11][4]
  265.         elseif map == "infinity" then
  266.                 weapon1 = spawnweaps[12][1]
  267.                 weapon2 = spawnweaps[12][2]
  268.                 weapon3 = spawnweaps[12][3]
  269.                 weapon4 = spawnweaps[12][4]
  270.         elseif map == "longest" then
  271.                 weapon1 = spawnweaps[13][1]
  272.                 weapon2 = spawnweaps[13][2]
  273.                 weapon3 = spawnweaps[13][3]
  274.                 weapon4 = spawnweaps[13][4]
  275.         elseif map == "prisoner" then
  276.                 weapon1 = spawnweaps[14][1]
  277.                 weapon2 = spawnweaps[14][2]
  278.                 weapon3 = spawnweaps[14][3]
  279.                 weapon4 = spawnweaps[14][4]
  280.         elseif map == "putput" then
  281.                 weapon1 = spawnweaps[15][1]
  282.                 weapon2 = spawnweaps[15][2]
  283.                 weapon3 = spawnweaps[15][3]
  284.                 weapon4 = spawnweaps[15][4]
  285.         elseif map == "ratrace" then
  286.                 weapon1 = spawnweaps[16][1]
  287.                 weapon2 = spawnweaps[16][2]
  288.                 weapon3 = spawnweaps[16][3]
  289.                 weapon4 = spawnweaps[16][4]
  290.         elseif map == "sidewinder" then
  291.                 weapon1 = spawnweaps[17][1]
  292.                 weapon2 = spawnweaps[17][2]
  293.                 weapon3 = spawnweaps[17][3]
  294.                 weapon4 = spawnweaps[17][4]
  295.         elseif map == "timberland" then
  296.                 weapon1 = spawnweaps[18][1]
  297.                 weapon2 = spawnweaps[18][2]
  298.                 weapon3 = spawnweaps[18][3]
  299.                 weapon4 = spawnweaps[18][4]
  300.         elseif map == "wizard" then
  301.                 weapon1 = spawnweaps[19][1]
  302.                 weapon2 = spawnweaps[19][2]
  303.                 weapon3 = spawnweaps[19][3]
  304.                 weapon4 = spawnweaps[19][4]
  305.         end
  306. end
  307.  
  308. function OnGameEnd(mode)
  309.         if mode == 2 then
  310.                 removetimer(WeaponsMonitor)
  311.                 WeaponsMonitor = nil
  312.         end
  313. end
  314.  
  315. function OnPlayerJoin(player)
  316.         restore_weap[player] = {}
  317.         restore_weap[player].tagName = nil
  318. end
  319.  
  320. function OnPlayerLeave(player)
  321.         restore_weap[player] = nil
  322. end
  323.  
  324. function OnPlayerSpawn(player, objectId)
  325.         if getobject(objectId) then
  326.                 for i = 0,3 do
  327.                         local weapID = readdword(getobject(objectId), 0x2F8 + i*4)
  328.                         if weapID ~= 0xFFFFFFFF then
  329.                                 destroyobject(weapID)
  330.                         end
  331.                 end
  332.                 registertimer(50, "AssignWeapons", player)
  333.                 -- registertimer(100, "SetNades", player)
  334.         end
  335. end
  336.  
  337. -- assign the weapons one after the other in a way that players have the correct weapon in hand when they spawn
  338. -- and the next weapon they switch to is in the proper order as assigned at the top.
  339. function AssignWeapons(id, count, player)
  340.         if getobject(readdword(getplayer(player), 0x34)) then
  341.                 if weapon2 ~= nil then assignweapon(player, createobject(gettagid("weap", weapon2), 0, 60, false, 0, 1, 2)) end
  342.                 if weapon3 ~= nil then assignweapon(player, createobject(gettagid("weap", weapon3), 0, 60, false, 0, 1, 2)) end
  343.                 if weapon4 ~= nil then assignweapon(player, createobject(gettagid("weap", weapon4), 0, 60, false, 0, 1, 2)) end
  344.                 if weapon1 ~= nil then assignweapon(player, createobject(gettagid("weap", weapon1), 0, 60, false, 0, 1, 2)) end
  345.         end
  346. end
  347.  
  348. function OnObjectInteraction(player, objectId, mapId)
  349.         local tagName, tagType = gettaginfo(mapId)
  350.         if tagType == "weap" and restore_weap[player].tagName == nil then
  351.                 local check = false
  352.                 if tagName == "weapons\\flag\\flag" then
  353.                         if (getteam(player) == 0 and objectId == readdword(ctf_globals + 1*4, 0x8)) or (getteam(player) == 1 and objectId == readdword(ctf_globals + 0*4, 0x8)) then
  354.                                 check = true
  355.                         else
  356.                                 check = false
  357.                         end            
  358.                 elseif tagName == "weapons\\ball\\ball" then
  359.                         check = true
  360.                 end
  361.                 if check == true then
  362.                         local m_object = getobject(readdword(getplayer(player), 0x34))
  363.                         local slot = readword(m_object, 0x2F2)
  364.                         local slot_offset = 0x2F8
  365.                         if slot == 0 then slot_offset = 0x2F8
  366.                         elseif slot == 1 then slot_offset = 0x2F8 + 4
  367.                         elseif slot == 2 then slot_offset = 0x2F8 + 8
  368.                         elseif slot == 3 then slot_offset = 0x2F8 + 12
  369.                         end
  370.                         local weapId = readdword(m_object, slot_offset)
  371.                         if (getobject(readdword(m_object, 0x304)) and readdword(m_object, 0x304) ~= 0xFFFFFFFF) and (weapId ~= 0xFFFFFFFF and getobject(weapId)) then
  372.                                 local tag = gettaginfo(readdword(getobject(weapId)))
  373.                                 if tag ~= "weapons\\flag\\flag" and tag ~= "weapons\\ball\\ball" then
  374.                                         local m_weapon = getobject(readdword(m_object, 0x118))
  375.                                         local ammo
  376.                                         if tag == "weapons\\flamethrower\\flamethrower" then
  377.                                                 ammo = readfloat(m_weapon, 0x124)
  378.                                         elseif tag == "weapons\\plasma pistol\\plasma pistol" then
  379.                                                 ammo = readfloat(m_weapon, 0x140)
  380.                                         elseif tag == "weapons\\plasma rifle\\plasma rifle" or tag == "weapons\\plasma_cannon\\plasma_cannon" then
  381.                                                 ammo = readfloat(m_weapon, 0x240)
  382.                                         else
  383.                                                 ammo = readword(m_weapon, 0x2B6) -- unloaded ammo
  384.                                         end
  385.                                         restore_weap[player].tagName = tag
  386.                                         restore_weap[player].Clip = readword(m_weapon, 0x2B8) -- loaded ammo(for non-battery weapons)
  387.                                         restore_weap[player].Ammo = ammo
  388.                                         destroyobject(weapId)
  389.                                 end
  390.                         end
  391.                 end
  392.         end
  393.         return 1
  394. end
  395.  
  396. -- Nuggets' function
  397. function WeaponMonitor(id, count)
  398.         for player = 0,15 do
  399.                 weapons[player] = weapons[player] or {}
  400.                 if getplayer(player) then
  401.                         local m_object = getobject(readdword(getplayer(player), 0x34))
  402.                         if m_object then
  403.                                 for i = 0,3 do
  404.                                         local weapId = readdword(m_object, 0x2F8 + (i * 4))
  405.                                         if getobject(weapId) then
  406.                                                 local mapId = readdword(getobject(weapId))
  407.                                                 if weapons[player][i] then
  408.                                                         if weapons[player][i].weapId ~= weapId then
  409.                                                                 OnWeaponDrop(player, weapons[player][i].weapId, i, weapons[player][i].mapId)
  410.                                                                 weapons[player][i] = {}
  411.                                                                 weapons[player][i].weapId = weapId
  412.                                                                 weapons[player][i].mapId = mapId
  413.                                                                 OnWeaponPickup(player, weapId, i, mapId)
  414.                                                         end
  415.                                                 else
  416.                                                         weapons[player][i] = {}
  417.                                                         weapons[player][i].weapId = weapId
  418.                                                         weapons[player][i].mapId = mapId
  419.                                                         OnWeaponPickup(player, weapId, i, mapId)
  420.                                                 end
  421.                                         else
  422.                                                 if weapons[player][i] then
  423.                                                         OnWeaponDrop(player, weapons[player][i].weapId, i, weapons[player][i].mapId)
  424.                                                         weapons[player][i] = nil
  425.                                                 end
  426.                                         end
  427.                                 end
  428.                         else
  429.                                 for i = 0,3 do
  430.                                         if weapons[player][i] then
  431.                                                 OnWeaponDrop(player, weapons[player][i].weapId, i, weapons[player][i].mapId)
  432.                                                 weapons[player][i] = nil
  433.                                         end
  434.                                 end
  435.                         end
  436.                 end
  437.         end
  438.         return 1
  439. end
  440.  
  441. function OnWeaponPickup(player, weapId, slot, mapId)
  442. end
  443.  
  444. function OnWeaponDrop(player, weapId, slot, mapId)
  445.         if getobject(readdword(getplayer(player), 0x34)) then -- if player is alive
  446.                 local tagName = gettaginfo(mapId)
  447.                 if (tagName == "weapons\\flag\\flag" or tagName == "weapons\\ball\\ball") and restore_weap[player].tagName ~= nil then
  448.                         registertimer(401, "RestoreWeapon", player)
  449.                 end
  450.         end
  451. end
  452.  
  453. function RestoreWeapon(id, count, player)
  454.         if getobject(readdword(getplayer(player), 0x34)) and restore_weap[player].tagName ~= nil then
  455.                 local tagname = restore_weap[player].tagName
  456.                 local weaponId = createobject(gettagid("weap", tagname), 0, 60, false, 0, 1, 2)
  457.                 local m_weapon = getobject(weaponId)
  458.                 if tagname == "weapons\\flamethrower\\flamethrower" then
  459.                         writefloat(m_weapon, 0x124, restore_weap[player].Ammo)
  460.                 elseif tagname == "weapons\\plasma pistol\\plasma pistol" then
  461.                         writefloat(m_weapon, 0x140, restore_weap[player].Ammo)
  462.                 elseif tagname == "weapons\\plasma rifle\\plasma rifle" or tagname == "weapons\\plasma_cannon\\plasma_cannon" then
  463.                         writefloat(m_weapon, 0x240, restore_weap[player].Ammo)
  464.                 else
  465.                         writeword(m_weapon, 0x2B6, restore_weap[player].Ammo)
  466.                         writeword(m_weapon, 0x2B8, restore_weap[player].Clip)
  467.                 end
  468.                 updateammo(weaponId)
  469.                 assignweapon(player, weaponId)
  470.                 restore_weap[player].tagName = nil
  471.                 restore_weap[player].Ammo = nil
  472.                 restore_weap[player].PackAmmo = nil
  473.         end
  474.         return 0
  475. end

HaloNet.Net is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.