Advertisement
HR_Shaft

Random Weapons for Classic Weapon sets Phasor v2+

Jan 15th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 18.99 KB | None | 0 0
  1. --[[ ###  Random Weapons Infinite Ammo v1 ###]]--
  2. --[[ ###    by H® Shaft for Phasor v2     ###]]--
  3.  
  4. -- gametype MUST have weapons set to generic, use ONLY on maps that have standard/classic halo weapon sets
  5.  
  6. team_play = false
  7. game_started = false
  8. weapons = {}
  9. mybattery = {}
  10. needler_clip = 40
  11. shotgun_clip = 12
  12. assault_clip = 60
  13. flame_clip = 200
  14. pistol_clip = 12
  15. rocket_clip = 2
  16. sniper_clip = 4
  17. rocket_ammo = 4
  18. battery = 0
  19.  
  20. function GetRequiredVersion()
  21.     return 200
  22. end
  23.  
  24. function OnScriptLoad(process, game, persistent)
  25.     if game == true or game == "PC" then
  26.         GAME = "PC"
  27.         gametype_base = 0x671340
  28.         map_name = readstring(0x698F21)
  29.     else
  30.         GAME = "CE"
  31.         gametype_base = 0x5F5498
  32.         map_name = readstring(0x61D151)
  33.     end
  34.     for i=0,15 do
  35.         if getplayer(i) then
  36.             mybattery[i] = 0
  37.             weapons[i] = {}
  38.         end
  39.     end
  40.     team_play = getteamplay()  
  41.     gametype = readbyte(gametype_base + 0x30)  
  42. end
  43.  
  44. function OnNewGame(map)
  45.     if GAME == "PC" then
  46.         gametype_base = 0x671340
  47.         map_name = readstring(0x698F21)
  48.     elseif GAME == "CE" then
  49.         gametype_base = 0x5F5498
  50.         map_name = readstring(0x61D151)
  51.     end
  52.     for i=0,15 do
  53.         if getplayer(i) then
  54.             mybattery[i] = 0
  55.             weapons[i] = {}
  56.         end
  57.     end
  58.     team_play = getteamplay()
  59.     gametype = readbyte(gametype_base + 0x30)
  60.     game_started =  true
  61. end    
  62.    
  63. function getteamplay()
  64.     if readbyte(gametype_base + 0x34) == 1 then
  65.         return true
  66.     else
  67.         return false
  68.     end
  69. end
  70.  
  71. function OnPlayerJoin(player)
  72.     if getplayer(player) then
  73.         mybattery[player] = 0
  74.         weapons[player] = nil
  75.         welcome = registertimer(9000, "Welcome", player)
  76.     end
  77. end
  78.  
  79. function Welcome(id, count, player)
  80.     if count == 1 then
  81.         if getplayer(player) and game_started then
  82.             sendconsoletext(player, "Welcome to Random Weapons!", 10, 0)
  83.             sendconsoletext(player, "Each time you spawn, you will be given a random weapon.", 10, 0)
  84.         end
  85.     end
  86.     return false   
  87. end
  88.  
  89. function OnPlayerKill(killer, victim, mode)
  90.     if getplayer(victim) then
  91.         weapons[victim] = nil
  92.         mybattery[victim] = 0
  93.     end
  94. end
  95.  
  96. function OnPlayerLeave(player)
  97.     if getplayer(player) then
  98.         weapons[player] = nil
  99.         mybattery[player] = nil
  100.     end
  101. end
  102.  
  103. function OnTeamChange(player, old_team, new_team, relevant)
  104.     if getplayer(player) then
  105.         weapons[player] = nil
  106.         mybattery[player] = 1
  107.     end
  108.     return nil
  109. end
  110.  
  111. function OnPlayerSpawnEnd(player, m_objectId)
  112.     if getplayer(player) then
  113.         weapons[player] = nil
  114.         mybattery[player] = 0
  115.         ChangeFFAColor(player)
  116.         local m_objectId = getplayerobjectid(player)       
  117.         if m_objectId then
  118.             gameweap = registertimer(0, "AssignGameWeapons", player)
  119.         end
  120.     end
  121. end
  122.  
  123. function ChangeFFAColor(player)
  124.     if getplayer(player) then
  125.         local m_objectId = getplayerobjectid(player)
  126.         if m_objectId then
  127.             local m_object = getobject(m_objectId)
  128.             if m_object then
  129.                 local m_player = getplayer(player)
  130.                 local color = getrandomnumber(1, 18)
  131.                 writeword(m_player + 0x60, color)
  132.             end
  133.         end
  134.     end
  135. end
  136.  
  137. function ApplyHP(id, count, player)
  138.     if count == 1 then
  139.         if player and game_started then
  140.             local name = getname(player)
  141.             local m_playerObjId = getplayerobjectid(player)
  142.             if m_playerObjId ~= nil then
  143.                 local m_object = getobject(m_playerObjId)
  144.                 local obj_health = readfloat(m_object + 0xE0)
  145.                 if obj_health < 1 then
  146.                     writefloat(m_object + 0xE0, 1)
  147.                     sendconsoletext(player, "Bonus: Your health has been restored.", 4, 0)
  148.                 end
  149.             end
  150.         end
  151.     end
  152.     return false
  153. end
  154.  
  155. function AssignGameWeapons(id, count, player)
  156.     if getplayer(player) and game_started then
  157.         local m_objectId = getplayerobjectid(player)
  158.         local m_object = getobject(m_objectId)
  159.         local clip = 0
  160.         local ammo = 9999
  161.         local battery = 0
  162.         if m_objectId then
  163.             for i = 0,3 do
  164.                 local weapID = readdword(getobject(m_objectId), 0x2F8 + i*4)
  165.                 if weapID ~= 0xFFFFFFFF then
  166.                     destroyobject(weapID)
  167.                 end
  168.             end
  169.        
  170.             local randomweap = getrandomnumber(1, 10)
  171.             local randomclip = getrandomnumber(1, 20)
  172.             if randomweap == 1 then
  173.                 if randomclip > 19 then
  174.                     clip = 9999
  175.                     sendconsoletext(player, "Bottomless Clip: No Reload!", 5, 0)
  176.                 else   
  177.                     clip = shotgun_clip
  178.                 end            
  179.                 weapons[player] = "weapons\\shotgun\\shotgun"
  180.                 sendconsoletext(player, "Shotgun", 5, 0)
  181.             elseif randomweap == 2 then
  182.                 if randomclip > 19 then
  183.                     clip = 9999
  184.                     sendconsoletext(player, "Bottomless Clip: No Reload!", 5, 0)
  185.                 else   
  186.                     clip = assault_clip
  187.                 end            
  188.                 weapons[player] = "weapons\\assault rifle\\assault rifle"
  189.                 sendconsoletext(player, "Assault Rifle", 5, 0)
  190.             elseif randomweap == 3 then
  191.                 if randomclip > 19 then
  192.                     clip = 9999
  193.                     sendconsoletext(player, "Bottomless Clip: No Reload!", 5, 0)
  194.                 else   
  195.                     clip = flame_clip
  196.                 end            
  197.                 weapons[player] = "weapons\\flamethrower\\flamethrower"
  198.                 sendconsoletext(player, "Flame-Thrower", 5, 0)
  199.             elseif randomweap == 4 then
  200.                 if randomclip > 19 then
  201.                     clip = 9999
  202.                     sendconsoletext(player, "Bottomless Clip: No Reload!", 5, 0)
  203.                 else   
  204.                     clip = needler_clip
  205.                 end
  206.                 weapons[player] = "weapons\\needler\\mp_needler"
  207.                 sendconsoletext(player, "Needler", 5, 0)
  208.             elseif randomweap == 5 then
  209.                 if randomclip > 19 then
  210.                     clip = 9999
  211.                     sendconsoletext(player, "Bottomless Clip: No Reload!", 5, 0)
  212.                 else   
  213.                     clip = pistol_clip
  214.                 end            
  215.                 weapons[player] = "weapons\\pistol\\pistol"
  216.                 sendconsoletext(player, "Pistol", 5, 0)
  217.             elseif randomweap == 6 then
  218.                 battery = 0
  219.                 weapons[player] = "weapons\\plasma pistol\\plasma pistol"
  220.                 sendconsoletext(player, " Plasma Pistol", 5, 0)
  221.             elseif randomweap == 7 then
  222.                 battery = 0
  223.                 weapons[player] = "weapons\\plasma rifle\\plasma rifle"
  224.                 sendconsoletext(player, "Plasma Rifle", 5, 0)
  225.             elseif randomweap == 8 then
  226.                 battery = 0
  227.                 weapons[player] = "weapons\\plasma_cannon\\plasma_cannon"
  228.                 sendconsoletext(player, "Fuel-Rod Gun", 5, 0)
  229.             elseif randomweap == 9 then
  230.                 if randomclip > 19 then
  231.                     clip = 9999
  232.                     sendconsoletext(player, "Bottomless Clip: No Reload!", 5, 0)
  233.                 else   
  234.                     clip = rocket_clip
  235.                 end        
  236.                 weapons[player] = "weapons\\rocket launcher\\rocket launcher"
  237.                 sendconsoletext(player, "Rocket Launcher", 5, 0)
  238.             elseif randomweap == 10 then
  239.                 if randomclip > 19 then
  240.                     clip = 9999
  241.                     sendconsoletext(player, "Bottomless Clip: No Reload!", 5, 0)
  242.                 else   
  243.                     clip = sniper_clip
  244.                 end            
  245.                 weapons[player] = "weapons\\sniper rifle\\sniper rifle"
  246.                 sendconsoletext(player, "Sniper Rifle", 5, 0)
  247.             end
  248.            
  249.             local m_weaponId = createobject(gettagid("weap", weapons[player]), 0, 10, false, 0, 0, 0)
  250.             assignweapon(player, m_weaponId)
  251.             local m_weapon = getobject(m_weaponId)
  252.            
  253.             if randomweap == 6 or randomweap == 7 or randomweap == 8 then
  254.                 if m_weapon then
  255.                     writefloat(m_weapon + 0x240, battery)
  256.                     updateammo(m_weaponId)
  257.                     infbattery = registertimer(1000, "InfBattery", {m_weapon, player}) 
  258.                     mybattery[player] = 1
  259.                 end
  260.             elseif randomclip <= 19 then
  261.                 if m_weapon then
  262.                     if randomweap == 9 then ammo = rocket_ammo clip = rocket_clip end -- rocket launcher
  263.                     writeword(m_weapon + 0x2B6, ammo)
  264.                     writeword(m_weapon + 0x2B8, clip)
  265.                     updateammo(m_weaponId)
  266.                 end                
  267.             else
  268.                 if m_weapon then
  269.                     if randomweap == 9 then ammo = rocket_ammo clip = rocket_clip end -- rocket launcher
  270.                     writeword(m_weapon + 0x2B6, ammo)
  271.                     writeword(m_weapon + 0x2B8, clip)
  272.                     updateammo(m_weaponId)
  273.                 end
  274.             end
  275.            
  276.             local random_nade = getrandomnumber(1, 7)
  277.             if m_object then
  278.                 if random_nade == 1 then
  279.                     writebyte(m_object, 0x31E, 2)
  280.                     writebyte(m_object, 0x31F, 2)
  281.                     sendconsoletext(player, "Grenades: 2 of each.", 5, 0)
  282.                 elseif random_nade == 2 then
  283.                     writebyte(m_object, 0x31E, 1)
  284.                     writebyte(m_object, 0x31F, 1)
  285.                     sendconsoletext(player, "Grenades: 1 of each.", 5, 0)
  286.                 elseif random_nade == 3 then   
  287.                     writebyte(m_object, 0x31E, 1)
  288.                     writebyte(m_object, 0x31F, 0)
  289.                     sendconsoletext(player, "Grenades: 1 frag.", 5, 0)
  290.                 elseif random_nade == 4 then
  291.                     writebyte(m_object, 0x31E, 0)
  292.                     writebyte(m_object, 0x31F, 1)
  293.                     sendconsoletext(player, "Grenades: 1 Plasma.", 5, 0)
  294.                 elseif random_nade == 5 then
  295.                     writebyte(m_object, 0x31E, 2)
  296.                     writebyte(m_object, 0x31F, 0)
  297.                     sendconsoletext(player, "Grenades: 2 Frags.", 5, 0)
  298.                 elseif random_nade == 6 then
  299.                     writebyte(m_object, 0x31E, 0)
  300.                     writebyte(m_object, 0x31F, 2)
  301.                     sendconsoletext(player, "Grenades: 2 Plasma.", 5, 0)
  302.                 elseif random_nade == 7 then
  303.                     writebyte(m_object, 0x31E, 0)
  304.                     writebyte(m_object, 0x31F, 0)
  305.                 end    
  306.             end
  307.            
  308.             local random_camo = getrandomnumber(1, 30)
  309.             local id = resolveplayer(player)
  310.             if random_camo > 29 then
  311.                 svcmd("sv_invis " .. id)
  312.                 sendconsoletext(player, "You are Invisible!", 5, 0)
  313.             end
  314.             if gametype ~= 5 then
  315.                 local random_speed = getrandomnumber(1, 30)
  316.                 if random_speed >= 29 then
  317.                     setspeed(player, 1.5)
  318.                     sendconsoletext(player, "150% Speed!", 5, 0)
  319.                 elseif random_speed >= 1 and random_speed < 3 then 
  320.                     setspeed(player, 1.25)
  321.                     sendconsoletext(player, "125% Speed!", 5, 0)               
  322.                 end
  323.             end
  324.             health = registertimer(0, "ApplyHP", player)
  325.         end
  326.     end
  327.     return false
  328. end
  329.  
  330. function InfBattery(id, count, arg)
  331.     local m_weapon = arg[1]
  332.     local player = arg[2]
  333.     if m_weapon and game_started then
  334.         if readfloat(m_weapon + 0x240) == 1 and mybattery[player] == 1 then
  335.             destroyplayerweaps(player)
  336.             replaceplasmaweap = registertimer(0, "ReplacePlasmaWeap", {player, m_weapon})
  337.             mybattery[player] = 0
  338.         end
  339.     end
  340.     return true
  341. end
  342.  
  343. function ReplacePlasmaWeap(id, count, arg)
  344.     local player = arg[1]
  345.     local m_weapon = arg[2]
  346.     if count == 1 then
  347.         if player and game_started then
  348.             local m_weaponId = createobject(gettagid("weap", weapons[player]), 0, 10, false, 0, 0, 0)
  349.             assignweapon(player, m_weaponId)
  350.             privatesay(player, "Battery recharged.")
  351.         end
  352.         mybattery[player] = 0
  353.     end
  354.     return false
  355. end
  356.  
  357. function getweaponobjectid(player, slot)
  358.     local m_objectId = getplayerobjectid(player)
  359.     if m_objectId then return readdword(getobject(m_objectId) + 0x2F8 + slot*4) end
  360. end
  361.  
  362. function destroyplayerweaps(player)
  363.     for i=0,3 do
  364.         local weap_id = getweaponobjectid(player, i)
  365.         if weap_id ~= 0xFFFFFFFF then destroyobject(weap_id) end
  366.     end
  367. end
  368.  
  369. function OnDamageLookup(receiving, causing, tagid)
  370.     -- looks up and sets damage variables
  371.     if receiving and causing and receiving ~= causing then
  372.         local tagname, tagtype = gettaginfo(tagid)
  373.         local melee = string.find(tagname, "melee")
  374.         local ppistolc = string.find(tagname, "weapons\\plasma rifle\\charged bolt")
  375.         local ppistolb = string.find(tagname, "weapons\\plasma pistol\\bolt")
  376.         local needlerd = string.find(tagname, "weapons\\needler\\detonation damage")
  377.         local plasrifle = string.find(tagname, "weapons\\plasma rifle\\bolt")
  378.         local deltappcharge = string.find(tagname, "weapons\\plasma pistol\\rw charged bolt")
  379.         local c_player = objectidtoplayer(causing)
  380.         local r_player = objectidtoplayer(receiving)
  381.         -- block vehicle and vehicle gun damage
  382.         if c_player and isinvehicle(c_player) then
  383.             local m_vehicleId = getplayervehicleid(c_player)
  384.             if m_vehicleId then
  385.                 local m_vehicle = getobject(m_vehicleId)
  386.                 local gunner = readdword(m_vehicle + 0x328)
  387.                 local driver = readdword(m_vehicle + 0x324)
  388.                 if gunner == causing then
  389.                     return false
  390.                 elseif driver == causing then
  391.                     return false
  392.                 end            
  393.             end
  394.         end
  395.         -- increase damage of melee to instant kill, increase plasma pistol, needler and plasma rifle to balance game play
  396.         if c_player and r_player then
  397.             if melee then odl_multiplier(9999) end
  398.             if ppistolc then odl_multiplier(1.85) end
  399.             if ppistolb then odl_multiplier(1.85) end
  400.             if needlerd then odl_multiplier(1.75) end
  401.             if plasrifle then odl_multiplier(1.35) end
  402.             if map_name == "deltaruins" then
  403.                 if deltappcharge then return ppistolb end
  404.                 if ppistolb then odl_multiplier(1.8) end
  405.             end
  406.         end
  407.     end
  408.     return nil
  409. end
  410.  
  411. function OnObjectCreationAttempt(mapId, parentId, player)
  412.     local response = nil
  413.     if game_started then
  414.         if mapId == gettagid("eqip", "powerups\\active camouflage") then
  415.             return gettagid("eqip", "powerups\\over shield")
  416.         end        
  417.     elseif not game_started then
  418.         -- allows creation of these items when game starts or on script load
  419.         if mapId == gettagid("eqip", "powerups\\over shield") or
  420.             mapId == gettagid("eqip", "powerups\\health pack") or
  421.             mapId == gettagid("bipd", "characters\\cyborg_mp\\cyborg_mp") or
  422.             mapId == gettagid("vehi", "vehicles\\warthog\\mp_warthog") or
  423.             mapId == gettagid("vehi", "vehicles\\rwarthog\\rwarthog") or
  424.             mapId == gettagid("vehi", "vehicles\\ghost\\ghost_mp") or
  425.             mapId == gettagid("vehi", "vehicles\\c gun turret\\c gun turret_mp") or
  426.             mapId == gettagid("vehi", "vehicles\\scorpion\\scorpion_mp") then
  427.             response = true
  428.         end
  429.         if mapId == gettagid("eqip", "powerups\\active camouflage") then
  430.             return gettagid("eqip", "powerups\\over shield")
  431.         end
  432.     else
  433.         response = false
  434.     end
  435.     return response
  436. end
  437.  
  438. function OnObjectInteraction(player, objId, mapId)
  439.     local Pass = nil
  440.     local name, type = gettaginfo(mapId)
  441.     if type == "weap" then
  442.         if gametype == 1 or gametype == 3 then
  443.             if name == "weapons\\ball\\ball" or name == "weapons\\flag\\flag" then
  444.                 Pass = true
  445.             elseif weapons[player] ~= nil then
  446.                 if name ~= weapons[player] then
  447.                     Pass = false
  448.                 end
  449.             end
  450.         elseif weapons[player] ~= nil then
  451.             if name ~= weapons[player] then
  452.                 Pass = false
  453.             end
  454.         end
  455.     elseif type == "eqip" then
  456.         if name == "powerups\\over shield" or name == "powerups\\health pack" then
  457.             Pass = true
  458.         else   
  459.             Pass = false
  460.         end
  461.     end
  462.     return Pass
  463. end
  464.  
  465. function OnGameEnd(stage)
  466.     if stage == 1 then
  467.         game_started = false
  468.         if gameweap then
  469.             gameweap = nil
  470.         end
  471.         if infbattery then
  472.             infbattery = nil
  473.         end
  474.         if replaceplasmaweap then
  475.             replaceplasmaweap = nil
  476.         end
  477.     elseif stage == 3 then
  478.         for i = 0, 15 do
  479.             if getplayer(i) then
  480.                 privatesay(i, "Thank you for playing Random Weapons!")
  481.                 privatesay(i, "by H\174 Shaft")
  482.             end
  483.         end    
  484.     end    
  485. end
  486.  
  487. -- Start sendconsoletext overloaded by Nugget
  488. console = {}
  489. console.__index = console
  490. consoletimer = registertimer(100, "ConsoleTimer")
  491. phasor_sendconsoletext = sendconsoletext
  492.  
  493. function sendconsoletext(player, message, time, order, align, height, func)
  494.     if player then
  495.         console[player] = console[player] or {}
  496.         local temp = {}
  497.         temp.player = player
  498.         temp.id = nextid(player, order)
  499.         temp.message = message or ""
  500.         temp.time = time or 0.7
  501.         temp.remain = temp.time
  502.         temp.align = align or "left"
  503.         temp.height = height or 0
  504.         if type(func) == "function" then
  505.             temp.func = func
  506.         elseif type(func) == "string" then
  507.             temp.func = _G[func]
  508.         end
  509.         console[player][temp.id] = temp
  510.         setmetatable(console[player][temp.id], console)
  511.         return console[player][temp.id]
  512.     end
  513. end
  514.  
  515. function nextid(player, order)
  516.     if not order then
  517.         local x = 0
  518.         for k,v in pairs(console[player]) do
  519.             if k > x + 1 then
  520.                 return x + 1
  521.             end
  522.             x = x + 1
  523.         end
  524.         return x + 1
  525.     else
  526.         local original = order
  527.         while console[player][order] do
  528.             order = order + 0.001
  529.             if order == original + 0.999 then break end
  530.         end
  531.         return order
  532.     end
  533. end
  534.  
  535. function getmessage(player, order)
  536.     if console[player] then
  537.         if order then
  538.             return console[player][order]
  539.         end
  540.     end
  541. end
  542.  
  543. function getmessages(player)
  544.     return console[player]
  545. end
  546.  
  547. function getmessageblock(player, order)
  548.     local temp = {}
  549.     for k,v in opairs(console[player]) do
  550.         if k >= order and k < order + 1 then
  551.             table.insert(temp, console[player][k])
  552.         end
  553.     end
  554.     return temp
  555. end
  556.  
  557. function console:getmessage()
  558.     return self.message
  559. end
  560.  
  561. function console:append(message, reset)
  562.     if console[self.player] then
  563.         if console[self.player][self.id] then
  564.             if getplayer(self.player) then
  565.                 if reset then
  566.                     if reset == true then
  567.                         console[self.player][self.id].remain = console[self.player][self.id].time
  568.                     elseif tonumber(reset) then
  569.                         console[self.player][self.id].time = tonumber(reset)
  570.                         console[self.player][self.id].remain = tonumber(reset)
  571.                     end
  572.                 end
  573.                 console[self.player][self.id].message = message or ""
  574.                 return true
  575.             end
  576.         end
  577.     end
  578. end
  579.  
  580. function console:shift(order)
  581.     local temp = console[self.player][self.id]
  582.     console[self.player][self.id] = console[self.player][order]
  583.     console[self.player][order] = temp
  584. end
  585.  
  586. function console:pause(time)
  587.     console[self.player][self.id].pausetime = time or 5
  588. end
  589.  
  590. function console:delete()
  591.     console[self.player][self.id] = nil
  592. end
  593.  
  594. function ConsoleTimer(id, count)
  595.     for i,_ in opairs(console) do
  596.         if tonumber(i) then
  597.             if getplayer(i) then
  598.                 for k,v in opairs(console[i]) do
  599.                     if console[i][k].pausetime then
  600.                         console[i][k].pausetime = console[i][k].pausetime - 0.1
  601.                         if console[i][k].pausetime <= 0 then
  602.                             console[i][k].pausetime = nil
  603.                         end
  604.                     else
  605.                         if console[i][k].func then
  606.                             if not console[i][k].func(i) then
  607.                                 console[i][k] = nil
  608.                             end
  609.                         end
  610.                         if console[i][k] then
  611.                             console[i][k].remain = console[i][k].remain - 0.1
  612.                             if console[i][k].remain <= 0 then
  613.                                 console[i][k] = nil
  614.                             end
  615.                         end
  616.                     end
  617.                 end
  618.                 if table.len(console[i]) > 0 then
  619.                     local paused = 0
  620.                     for k,v in pairs(console[i]) do
  621.                         if console[i][k].pausetime then
  622.                             paused = paused + 1
  623.                         end
  624.                     end
  625.                     if paused < table.len(console[i]) then
  626.                         local str = ""
  627.                         for i = 0,30 do
  628.                             str = str .. " \n"
  629.                         end
  630.                         phasor_sendconsoletext(i, str)
  631.                         for k,v in opairs(console[i]) do
  632.                             if not console[i][k].pausetime then
  633.                                 if console[i][k].align == "right" or console[i][k].align == "center" then
  634.                                     phasor_sendconsoletext(i, consolecenter(string.sub(console[i][k].message, 1, 78)))
  635.                                 else
  636.                                     phasor_sendconsoletext(i, string.sub(console[i][k].message, 1, 78))
  637.                                 end
  638.                             end
  639.                         end
  640.                     end
  641.                 end
  642.             else
  643.                 console[i] = nil
  644.             end
  645.         end
  646.     end
  647.    
  648.     return true
  649. end
  650.  
  651. function consolecenter(text)
  652.     if text then
  653.         local len = string.len(text)
  654.         for i = len + 1, 78 do
  655.             text = " " .. text
  656.         end
  657.         return text
  658.     end
  659. end
  660.  
  661. function opairs(t)
  662.     local keys = {}
  663.     for k,v in pairs(t) do
  664.         table.insert(keys, k)
  665.     end    
  666.     table.sort(keys,
  667.     function(a,b)
  668.         if type(a) == "number" and type(b) == "number" then
  669.             return a < b
  670.         end
  671.         an = string.lower(tostring(a))
  672.         bn = string.lower(tostring(b))
  673.         if an ~= bn then
  674.             return an < bn
  675.         else
  676.             return tostring(a) < tostring(b)
  677.         end
  678.     end)
  679.     local count = 1
  680.     return function()
  681.         if table.unpack(keys) then
  682.             local key = keys[count]
  683.             local value = t[key]
  684.             count = count + 1
  685.             return key,value
  686.         end
  687.     end
  688. end
  689.  
  690. function table.len(t)
  691.     local count = 0
  692.     for k,v in pairs(t) do
  693.         count = count + 1
  694.     end
  695.     return count
  696. end
  697. -- Stop sendconsoletext overloaded
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement