Advertisement
HR_Shaft

Assault Rifle Infinite Ammo v1 for Phasor v2

Mar 30th, 2014
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.30 KB | None | 0 0
  1. --[[ ###  Assault Rifle Infinite Ammo v1  ###]]--
  2. --[[ ###    by Hยฎ Shaft for Phasor v2     ###]]--
  3.  
  4. -- gametype MUST have weapons set to generic
  5.  
  6. team_play = false
  7. weapons = {}
  8.  
  9.  
  10. function GetRequiredVersion()
  11.     return 200
  12. end
  13.  
  14. function OnScriptLoad(process, game, persistent)
  15.     if game == true or game == "PC" then
  16.         GAME = "PC"
  17.         gametype_base = 0x671340
  18.         map_name = readstring(0x698F21)
  19.     else
  20.         GAME = "CE"
  21.         gametype_base = 0x5F5498
  22.         map_name = readstring(0x61D151)
  23.     end
  24.     for i=0,15 do
  25.         if getplayer(i) then
  26.             weapons[i] = {}
  27.         end
  28.     end    
  29.     gametype = readbyte(gametype_base + 0x30)
  30.     if getteamplay() == true then team_play = true else team_play = false end  
  31. end
  32.  
  33. function OnNewGame(map)
  34.     if GAME == "PC" then
  35.         gametype_base = 0x671340
  36.         map_name = readstring(0x698F21)
  37.     elseif GAME == "CE" then
  38.         gametype_base = 0x5F5498
  39.         map_name = readstring(0x61D151)
  40.     end
  41.     for i=0,15 do
  42.         if getplayer(i) then
  43.             weapons[i] = {}
  44.         end
  45.     end
  46.     gametype = readbyte(gametype_base + 0x30)
  47.     if getteamplay() == true then team_play = true else team_play = false end      
  48. end    
  49.    
  50. function getteamplay()
  51.     if readbyte(gametype_base + 0x34) == 1 then
  52.         return true
  53.     else
  54.         return false
  55.     end
  56. end
  57.  
  58. function OnPlayerJoin(player)
  59.     if getplayer(player) then
  60.         weapons[player] = nil
  61.         sendconsoletext(player, "Assault Rifle! Unlimited Ammo!")
  62.     end
  63. end
  64.  
  65. function OnPlayerKill(killer, victim, mode)
  66.     if getplayer(victim) then
  67.         weapons[victim] = nil
  68.     end
  69. end
  70.  
  71. function OnPlayerLeave(player)
  72.     if getplayer(player) then
  73.         weapons[player] = nil
  74.     end
  75. end
  76.  
  77. function OnPlayerSpawn(player, m_objectId)
  78.     if getplayer(player) then
  79.         weapons[player] = nil
  80.         local m_objectId = getplayerobjectid(player)   
  81.         if m_objectId then
  82.             gameweap = registertimer(0, "AssignGameWeapons", player)
  83.         end
  84.     end
  85. end
  86.  
  87. function AssignGameWeapons(id, count, player)
  88.     if getplayer(player) then
  89.         local m_objectId = getplayerobjectid(player)
  90.         local m_object = getobject(m_objectId)
  91.         local clip = 0
  92.         local ammo = 9999
  93.         if m_objectId then
  94.             for i = 0,3 do
  95.                 local weapID = readdword(getobject(m_objectId), 0x2F8 + i*4)
  96.                 if weapID ~= 0xFFFFFFFF then
  97.                     destroyobject(weapID)
  98.                 end
  99.             end
  100.             if m_object then
  101.                 writebyte(m_object + 0x31E, 1)
  102.                 writebyte(m_object + 0x31F, 1) 
  103.             end    
  104.             local m_weaponId = createobject(gettagid("weap", "weapons\\assault rifle\\assault rifle"), 0, 10, false, 0, 0, 0)
  105.             weapons[player] = "weapons\\assault rifle\\assault rifle"
  106.             clip = 60
  107.             assignweapon(player, m_weaponId)
  108.             local m_weapon = getobject(m_weaponId)
  109.             if m_weapon then
  110.                 writeword(m_weapon + 0x2B6, ammo)
  111.                 writeword(m_weapon + 0x2B8, clip)
  112.                 updateammo(m_weaponId)
  113.             end
  114.         end
  115.     end
  116.     return false
  117. end
  118.  
  119. function OnObjectInteraction(player, objId, mapId)
  120.     local Pass = nil
  121.     local name, type = gettaginfo(mapId)
  122.     if type == "weap" then
  123.         if gametype == 1 or gametype == 3 then
  124.             if name == "weapons\\ball\\ball" or name == "weapons\\flag\\flag" then
  125.                 Pass = true
  126.             elseif weapons[player] ~= nil then
  127.                 if name ~= weapons[player] then
  128.                     Pass = false
  129.                 end
  130.             end
  131.         else
  132.             if weapons[player] ~= nil then
  133.                 if name ~= weapons[player] then
  134.                     Pass = false
  135.                 end
  136.             end
  137.         end
  138.     end
  139.     return Pass
  140. end
  141.  
  142. function OnObjectCreationAttempt(mapId, parentId, player)
  143.     if mapId == gettagid("weap", "weapons\\pistol\\pistol") or
  144.         mapId == gettagid("weap", "weapons\\rocket launcher\\rocket launcher") or
  145.         mapId == gettagid("weap", "weapons\\flamethrower\\flamethrower") or
  146.         mapId == gettagid("weap", "weapons\\plasma pistol\\plasma pistol") or
  147.         mapId == gettagid("weap", "weapons\\plasma rifle\\plasma rifle") or
  148.         mapId == gettagid("weap", "weapons\\plasma_cannon\\plasma_cannon") or
  149.         mapId == gettagid("weap", "weapons\\sniper rifle\\sniper rifle") or
  150.         mapId == gettagid("weap", "weapons\\needler\\mp_needler") or
  151.         mapId == gettagid("weap", "weapons\\shotgun\\shotgun") then
  152.         return false
  153.     end
  154. end
  155.  
  156. function OnGameEnd(stage)
  157.     if stage == 1 then
  158.         if gameweap then
  159.             removetimer(gameweap)
  160.             gameweap = nil
  161.         end    
  162.     end    
  163. end
  164.  
  165. -- Created by Hยฎ Shaft thank you to Oxide, AelitePrime, Nugget & Wizard.
  166. -- Visit http://halorace.org/forum/index.php?topic=514.0 or
  167. -- Visit http://pastebin.com/u/HR_Shaft for more phasor scripts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement