LUA 160
V2+ Object Replacing Script 1.0 By xdedeone on 26th February 2019 05:21:25 PM
  1.         --Creator: AelitePrime
  2.     --Script Name: Object Replacing Script
  3.     --Website: http://phasorscripts.wordpress.com/
  4.     --Xfire: eliteprime14789x
  5.     --Version: 1.0
  6.        
  7. -- Format: {object1, object2}
  8. -- object2 replaces object1 when object1 is about to spawn.
  9. -- if object2 is 'nil' then object1 will not spawn. Example: {"health pack", "nil"},
  10.  
  11. replacing = {} -- do not touch
  12.  
  13. -- Valid Equiment names:
  14.         -- camo,
  15.         -- health pack,
  16.         -- overshield,
  17.         -- frag nade,
  18.         -- plasma nade,
  19.         -- assault rifle ammo,
  20.         -- flamethrower ammo,
  21.         -- needler ammo,
  22.         -- pistol ammo,
  23.         -- rocket ammo,
  24.         -- shotgun ammo,
  25.         -- sniper ammo,
  26.        
  27. replacing["eqip"] = {
  28.         -- Example: {"shotgun bullet", "rocket launcher bullet"},
  29. }
  30.  
  31. -- Valid Vehicle names:
  32.         -- banshee
  33.         -- gun turrent
  34.         -- ghost
  35.         -- rwarthog
  36.         -- scorpion
  37.         -- warthog
  38.  
  39. replacing["vehi"] = {
  40.         -- Example: {"warthog", "gun turrent"},
  41. }
  42.  
  43. -- Valid Weapons:
  44.         -- assault rifle
  45.         -- ball
  46.         -- flag
  47.         -- flamethrower
  48.         -- needler
  49.         -- pistol
  50.         -- plasma pistol
  51.         -- plasma rifle
  52.         -- fuel rod
  53.         -- rocket launcher
  54.         -- shotgun
  55.         -- sniper rifle
  56. replacing["weap"] = {
  57.     -- Example: {"assault rifle", "shotgun"},
  58. }
  59.  
  60. -- Valid Projectiles:
  61.         -- banshee bolt
  62.         -- banshee fuel rod
  63.         -- gun turrent bolt
  64.         -- ghost bolt
  65.         -- scorpion bullet
  66.         -- scorpion shell
  67.         -- warthog turrent
  68.         -- assault rifle bullet
  69.         -- flamethrower bullet
  70.         -- frag nade obj
  71.         -- needler bullet
  72.         -- pistol bullet
  73.         -- plasma nade obj
  74.         -- plasma pistol bullet
  75.         -- plasma rifle bullet
  76.         -- fuel rod bullet
  77.         -- rocket launcher bullet
  78.         -- shotgun bullet
  79.         -- sniper rifle bullet
  80.  
  81. replacing["proj"] = {
  82.         -- Example: {"pistol bullet", "fuel rod bullet"},
  83. }
  84.  
  85. -- Do not modify beyond this point --
  86. r_table = {}
  87. function GetRequiredVersion()
  88.         return 200
  89. end
  90.  
  91. function OnScriptLoad(process, game, persistent)
  92.  
  93. end
  94.  
  95. function OnNewGame(map)
  96.         r_table = setuptable(replacing)
  97. end
  98.  
  99. function OnObjectCreationAttempt(mapId, parentId, player)
  100.         local name, type = gettaginfo(mapId)
  101.         return checkObject(mapId, r_table[type])
  102. end
  103.  
  104. function checkObject(mapId, table)
  105.         if table then
  106.                 for k,v in ipairs(table) do
  107.                         if table[k] then
  108.                                 if table[k][1] == mapId then
  109.                                         if table[k][2] == "nil" then
  110.                                                 return false
  111.                                         else
  112.                                                 return table[k][2]
  113.                                         end
  114.                                 end
  115.                         end
  116.                 end
  117.         end
  118.         return mapId
  119. end
  120.  
  121. function setuptable(table)
  122.         local t = {}
  123.         for type,__ in pairs(table) do
  124.                 if table[type] then
  125.                         t[type] = {}
  126.                         for k,__ in ipairs(table[type]) do
  127.                                 if table[type][k] then
  128.                                         t[type][k] = {}
  129.                                         for key, value in ipairs(table[type][k]) do
  130.                                                 if type == "vehi" then
  131.                                                         if value == "banshee" then
  132.                                                                 t[type][k][key] = gettagid("vehi", "vehicles\\banshee\\banshee_mp")
  133.                                                         elseif value == "gun turrent" then
  134.                                                                 t[type][k][key] = gettagid("vehi", "vehicles\\c gun turret\\c gun turret_mp")
  135.                                                         elseif value == "ghost" then
  136.                                                                 t[type][k][key] = gettagid("vehi", "vehicles\\ghost\\ghost_mp")
  137.                                                         elseif value == "rwarthog" then
  138.                                                                 t[type][k][key] = gettagid("vehi", "vehicles\\rwarthog\\rwarthog")
  139.                                                         elseif value == "scorpion" then
  140.                                                                 t[type][k][key] = gettagid("vehi", "vehicles\\scorpion\\scorpion_mp")
  141.                                                         elseif value == "warthog" then
  142.                                                                 t[type][k][key] = gettagid("vehi", "vehicles\\warthog\\mp_warthog")
  143.                                                         elseif value == "nil" or value == nil then
  144.                                                                 t[type][k][key] = "nil"
  145.                                                         else
  146.                                                                 raiseerror(tostring(value) .. " is not a valid input for type: " .. tostring(type))
  147.                                                                 t[type][k] = {}
  148.                                                         end
  149.                                                 elseif type == "weap" then
  150.                                                         if value == "assault rifle" then
  151.                                                                 t[type][k][key] = gettagid("weap", "weapons\\assault rifle\\assault rifle")
  152.                                                         elseif value == "ball" then
  153.                                                                 t[type][k][key] = gettagid("weap", "weapons\\ball\\ball")
  154.                                                         elseif value == "flag" then
  155.                                                                 t[type][k][key] = gettagid("weap", "weapons\\flag\\flag")
  156.                                                         elseif value == "flamethrower" then
  157.                                                                 t[type][k][key] = gettagid("weap", "weapons\\flamethrower\\flamethrower")
  158.                                                         elseif value == "needler" then
  159.                                                                 t[type][k][key] = gettagid("weap", "weapons\\needler\\mp_needler")
  160.                                                         elseif value == "pistol" then
  161.                                                                 t[type][k][key] = gettagid("weap", "weapons\\pistol\\pistol")
  162.                                                         elseif value == "plasma pistol" then
  163.                                                                 t[type][k][key] = gettagid("weap", "weapons\\plasma pistol\\plasma pistol")
  164.                                                         elseif value == "plasma rifle" then
  165.                                                                 t[type][k][key] = gettagid("weap", "weapons\\plasma rifle\\plasma rifle")
  166.                                                         elseif value == "fuel rod" then
  167.                                                                 t[type][k][key] = gettagid("weap", "weapons\\plasma_cannon\\plasma_cannon")
  168.                                                         elseif value == "rocket launcher" then
  169.                                                                 t[type][k][key] = gettagid("weap", "weapons\\rocket launcher\\rocket launcher")
  170.                                                         elseif value == "shotgun" then
  171.                                                                 t[type][k][key] = gettagid("weap", "weapons\\shotgun\\shotgun")
  172.                                                         elseif value == "sniper rifle" then
  173.                                                                 t[type][k][key] = gettagid("weap", "weapons\\sniper rifle\\sniper rifle")
  174.                                                         elseif value == "nil" or value == nil then
  175.                                                                 t[type][k][key] = "nil"
  176.                                                         else
  177.                                                                 raiseerror(tostring(value) .. " is not a valid input for type: " .. tostring(type))
  178.                                                                 t[type][k] = {}
  179.                                                         end
  180.                                                 elseif type == "proj" then
  181.                                                         if value == "banshee bolt" then
  182.                                                                 t[type][k][key] = gettagid("proj", "vehicles\\banshee\\banshee bolt")
  183.                                                         elseif value == "banshee fuel rod" then
  184.                                                                 t[type][k][key] = gettagid("proj", "vehicles\\banshee\\mp_banshee fuel rod")
  185.                                                         elseif value == "gun turrent bolt" then
  186.                                                                 t[type][k][key] = gettagid("proj", "vehicles\\c gun turret\\mp gun turret")
  187.                                                         elseif value == "ghost bolt" then
  188.                                                                 t[type][k][key] = gettagid("proj", "vehicles\\ghost\\ghost bolt")
  189.                                                         elseif value == "scorpion bullet" then
  190.                                                                 t[type][k][key] = gettagid("proj", "vehicles\\scorpion\\bullet")
  191.                                                         elseif value == "scorpion shell" then
  192.                                                                 t[type][k][key] = gettagid("proj", "vehicles\\scorpion\\tank shell")
  193.                                                         elseif value == "warthog turrent" then
  194.                                                                 t[type][k][key] = gettagid("proj", "vehicles\\warthog\\bullet")
  195.                                                         elseif value == "assault rifle bullet" then
  196.                                                                 t[type][k][key] = gettagid("proj", "weapons\\assault rifle\\bullet")
  197.                                                         elseif value == "flamethrower bullet" then
  198.                                                                 t[type][k][key] = gettagid("proj", "weapons\\flamethrower\\flame")
  199.                                                         elseif value == "frag nade obj" then
  200.                                                                 t[type][k][key] = gettagid("proj", "weapons\\frag grenade\\frag grenade")
  201.                                                         elseif value == "needler bullet" then
  202.                                                                 t[type][k][key] = gettagid("proj", "weapons\\needler\\mp_needle")
  203.                                                         elseif value == "pistol bullet" then
  204.                                                                 t[type][k][key] = gettagid("proj", "weapons\\pistol\\bullet")
  205.                                                         elseif value == "plasma nade obj" then
  206.                                                                 t[type][k][key] = gettagid("proj", "weapons\\plasma grenade\\plasma grenade")
  207.                                                         elseif value == "plasma pistol bullet" then
  208.                                                                 t[type][k][key] = gettagid("proj", "weapons\\plasma pistol\\bolt")
  209.                                                         elseif value == "plasma rifle bullet" then
  210.                                                                 t[type][k][key] = gettagid("proj", "weapons\\plasma rifle\\bolt")
  211.                                                         elseif value == "fuel rod bullet" then
  212.                                                                 t[type][k][key] = gettagid("proj", "weapons\\plasma_cannon\\plasma_cannon")
  213.                                                         elseif value == "rocket launcher bullet" then
  214.                                                                 t[type][k][key] = gettagid("proj", "weapons\\rocket launcher\\rocket")
  215.                                                         elseif value == "shotgun bullet" then
  216.                                                                 t[type][k][key] = gettagid("proj", "weapons\\shotgun\\pellet")
  217.                                                         elseif value == "sniper rifle bullet" then
  218.                                                                 t[type][k][key] = gettagid("proj", "weapons\\sniper rifle\\sniper bullet")
  219.                                                         elseif value == "nil" or value == nil then
  220.                                                                 t[type][k][key] = "nil"
  221.                                                         else
  222.                                                                 raiseerror(tostring(value) .. " is not a valid input for type: " .. tostring(type))
  223.                                                                 t[type][k] = {}
  224.                                                         end
  225.                                                 elseif type == "eqip" then
  226.                                                         if value == "camo" then
  227.                                                                 t[type][k][key] = gettagid("eqip", "powerups\\active camouflage")
  228.                                                         elseif value == "health pack" then
  229.                                                                 t[type][k][key] = gettagid("eqip", "powerups\\health pack")
  230.                                                         elseif value == "overshield" then
  231.                                                                 t[type][k][key] = gettagid("eqip", "powerups\\over shield")
  232.                                                         elseif value == "frag nade" then
  233.                                                                 t[type][k][key] = gettagid("eqip", "weapons\\frag grenade\\frag grenade")
  234.                                                         elseif value == "plasma nade" then
  235.                                                                 t[type][k][key] = gettagid("eqip", "weapons\\plasma grenade\\plasma grenade")
  236.                                                         elseif value == "assault rifle ammo" then
  237.                                                                 t[type][k][key] = gettagid("eqip", "powerups\\assault rifle ammo\\assault rifle ammo")
  238.                                                         elseif value == "flamethrower ammo" then
  239.                                                                 t[type][k][key] = gettagid("eqip", "powerups\\flamethrower ammo\\flamethrower ammo")
  240.                                                         elseif value == "needler ammo" then
  241.                                                                 t[type][k][key] = gettagid("eqip", "powerups\\needler ammo\\needler ammo")
  242.                                                         elseif value == "pistol ammo" then
  243.                                                                 t[type][k][key] = gettagid("eqip", "powerups\\pistol ammo\\pistol ammo")
  244.                                                         elseif value == "rocket ammo" then
  245.                                                                 t[type][k][key] = gettagid("eqip", "powerups\\rocket launcher ammo\\rocket launcher ammo")
  246.                                                         elseif value == "shotgun ammo" then
  247.                                                                 t[type][k][key] = gettagid("eqip", "powerups\\shotgun ammo\\shotgun ammo")
  248.                                                         elseif value == "sniper ammo" then
  249.                                                                 t[type][k][key] = gettagid("eqip", "powerups\\sniper rifle ammo\\sniper rifle ammo")
  250.                                                         elseif value == "nil" or value == nil then
  251.                                                                 t[type][k][key] = "nil"
  252.                                                         else
  253.                                                                 raiseerror(tostring(value) .. " is not a valid input for type: " .. tostring(type))
  254.                                                                 t[type][k] = {}
  255.                                                         end
  256.                                                 end
  257.                                         end
  258.                                 end
  259.                         end
  260.                 end
  261.         end
  262.         return t
  263. 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.