Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.91 KB | None | 0 0
  1.  
  2. --[[
  3.     HSP LCD File output plugin
  4. ]]
  5.  
  6. local LCDEnabled = CreateConVar("lcd_enabled", 1, true, false)
  7. local LCDFile = "writelcd.txt"
  8.  
  9. local LastUsedWeaponClass = "No Kills"
  10. local TotalKills = 0
  11.  
  12. local Buff1 = "Buffer 1 fuckup\n"
  13. local Buff2 = "Buffer 2 fuckup\n"
  14. local Buff3 = "Buffer 3 fuckup\n"
  15. local Buff4 = "Buffer 4 fuckup\n"
  16.  
  17. local NiceWeaponNames = {
  18.     ["npc_grenade_frag"]            = "Frag Grenade",
  19.     ["ent_mad_c4"]                  = "C4 Bomb",
  20.     ["weapon_sniper"]               = "HL2 Beta Sniper",
  21.     ["weapon_pistol"]               = "Pistol",
  22.     ["weapon_crowbar"]              = "Crowbar",
  23.     ["weapon_357"]                  = ".357 Magnum",
  24.     ["weapon_smg1"]                 = "SMG",
  25.     ["weapon_ar2"]                  = "Frag Grenade",
  26.     ["weapon_rpg"]                  = "Missile",
  27.     ["rpg_missile"]                 = "Missile",
  28.     ["worldspawn"]                  = "The Floor",
  29.     ["prop_physics"]                = "Something hard",
  30.     ["prop_physics_multiplayer"]    = "Something hard",
  31.     ["weapon_shotgun"]              = "Shotgun",
  32.     ["npc_tripmine"]                = "Tripmine",
  33.     ["weapon_slam"]                 = "Tripmine",
  34.     ["npc_satchel"]                 = "Satchel charge",
  35.     ["prop_vehicle_prisoner_pod"]   = "A Chair",
  36.     ["prop_vehicle_jeep"]           = "A car",
  37.     ["prop_vehicle_jalopy"]         = "A car",
  38.     ["prop_vehicle_airboat"]        = "Airboat",
  39.     ["env_explosion"]               = "Kaboom!",
  40.     ["weapon_twitch_g3"]            = "Twitch G3",
  41.     ["weapon_twitch_awp"]           = "Twitch AWP",
  42.     ["weapon_stunstick"]            = "Stunstick",
  43.     ["gravestone"]                  = "Gravestone (!?)",
  44.     ["crossbow_bolt"]               = "Crossbow",
  45.     ["weapon_crossbow"]             = "Crossbow",
  46.     ["prop_combine_ball"]           = "Conbine Ball",
  47.     ["weapon_twitch_ak47"]          = "Twitch AK-47",
  48.     ["weapon_ak47"]                 = "CSS AK-47",
  49.     ["gmod_turret"]                 = "GMod Turret",
  50.     ["npc_turret_floor"]            = "NPC Turret",
  51.     ["npc_portalturret_floor"]      = "Portal Turret",
  52.     ["weapon_galil"]                = "CSS Galil",
  53.     ["weapon_ioncannon"]            = "Ion Cannon",
  54.     ["weapon_fiveseven"]            = "CSS FiveSeveN",
  55.     ["kh_smg"]                      = "KH SMG",
  56.     ["grenade_ar2"]                 = "SMG Grenade",
  57.     ["weapon_deagle"]               = "CSS Deagle",
  58.     ["plasma_smg"]                  = "Plasma SMG",
  59.     ["weapon_tmp"]                  = "CSS TMP",
  60.     ["weapon_knife"]                = "CSS Knife",
  61.     ["weapon_mp5"]                  = "CSS MP5",
  62.     ["weapon_p90"]                  = "CSS P-90",
  63.     ["bullet_grenade"]              = "Bullet Grenade",
  64.     ["plasma_rifle"]                = "Plasma Rifle",
  65.     ["weapon_twitch_m1014"]         = "Twitch M1014",
  66.     ["sent_plasma"]                 = "Plasma Bomb",
  67.     ["weapon_para"]                 = "CSS M249",
  68.     ["boomstick"]                   = "BOOMSTICK!",
  69.     ["weapon_twitch_aug"]           = "Twitch AUG",
  70.     ["weapon_twitch_hl2357"]        = "Twitch .357",
  71.     ["hunter_flechette"]            = "Flechettes",
  72.     ["weapon_twitch_sg550"]         = "Twitch SG550",
  73.     ["weapon_twitch_m4"]            = "Twitch M16",
  74.     ["weapon_twitch_scout"]         = "Twitch Scout",
  75.     ["weapon_stridercannon"]        = "Strider Cannon",
  76.     ["suicide_deagle"]              = "Suicide Deagle",
  77.     ["weapon_g3"]                   = "CSS G3",
  78.     ["entityflame"]                 = "Fire",
  79.     ["env_fire"]                    = "Fire",
  80.     ["weapon_m4"]                   = "CSS M16",
  81.     ["weapon_pumpshotgun"]          = "CSS Shotgun",
  82.     ["weapon_twitch_deagle"]        = "Twitch Deagle",
  83.     ["weapon_twitch_p90"]           = "Twitch P-90",
  84.     ["weapon_famas"]                = "CSS Famas",
  85.    
  86.     ["weapon_sniper"]               = "lolololol",
  87.     --["weapon_sniper"]             = "lolololol",
  88.     --["weapon_sniper"]             = "lolololol",
  89.     --["weapon_sniper"]             = "lolololol",
  90.     --["weapon_sniper"]             = "lolololol",
  91.     --["weapon_sniper"]             = "lolololol",
  92.    
  93. --[[
  94. HHHHHHHHHHHHHHH
  95.  
  96.  
  97. ]]
  98. }
  99.  
  100.  
  101. local AlsoInclude = {
  102.     "rpdm",
  103.     "gtfo",
  104.     "gmdm",
  105. }
  106. local DontInclude = {
  107.     "wal",
  108.     "hex",
  109. }
  110. local function FixMapName(str)
  111.     str = str:gsub("_", " ")
  112.     str = str:gsub("-", " ")
  113.    
  114.     local result = ""
  115.     for word in string.gmatch(str, "%S+") do          
  116.         local first = string.sub(word,1,1)
  117.         result = (result..string.upper(first)..string.lower(string.sub(word,2)).." ")
  118.     end
  119.     str = result:Trim()
  120.    
  121.     local tab = string.Explode(" ",str)
  122.     for k,v in pairs(tab) do
  123.         if (table.HasValue(AlsoInclude, v:lower()) or string.len(v) <= 3) and (not table.HasValue(DontInclude, v:lower())) then
  124.             --print("!: ", k)
  125.             tab[k] = v:upper()
  126.             --print(tab[k])
  127.         end
  128.     end
  129.     str = table.concat(tab, " ")
  130.    
  131.     --PrintTable(tab)
  132.     --print("! return: ", str )
  133.     return str:Trim()
  134. end
  135.  
  136.  
  137. local function GetLastUsedWeapon(ply,killer,dmginfo)
  138.     TotalKills = TotalKills + 1
  139.     local weapon = dmginfo:GetInflictor()
  140.     if ( weapon and weapon == killer and (weapon:IsPlayer() or weapon:IsNPC()) ) then --get weapon
  141.         weapon = weapon:GetActiveWeapon()
  142.         if ( !weapon or weapon == NULL ) then weapon = killer end
  143.     end
  144.     if (killer == ply) then
  145.         LastUsedWeaponClass = "Suicide"
  146.         return
  147.     end
  148.     LastUsedWeaponClass = weapon:GetClass():lower()
  149.     return
  150. end
  151. hook.Add("DoPlayerDeath", "LCDGetLastUsedWeapon", GetLastUsedWeapon)
  152.  
  153. local function LCDBuffer()
  154.     if not LCDEnabled:GetBool() then
  155.         return "WriteLCD\nDisabled"
  156.     end
  157.    
  158.     Buff1 = Format("Plyrs: %s/%s Ents: %s\n", #player.GetHumans(), MaxPlayers(), #ents.GetAll() )
  159.     Buff2 = Format("Map: %s\n", FixMapName(game.GetMap()) )
  160.     Buff3 = Format("Wep: %s\n", NiceWeaponNames[LastUsedWeaponClass] or LastUsedWeaponClass )
  161.     Buff4 = Format("HAC: %s/%s Deaths: %s\n", HAC.TotalBans or 0, HAC.TotalHacks or 0, TotalKills or "None" )
  162.     return Buff1..Buff2..Buff3..Buff4
  163. end
  164.  
  165. local function WriteLCD()
  166.     file.Write(LCDFile, LCDBuffer() )
  167. end
  168. timer.Create("WriteLCD", 2, 0, WriteLCD)
  169.  
  170. local function WriteLCDShutdown()
  171.     Buff1 = "SRCDS Shutting down\n / \nChanging levels\n"
  172.     file.Write(LCDFile, Buff1)
  173. end
  174. hook.Add("ShutDown", "WriteLCDShutdown", WriteLCDShutdown)
  175.  
  176.  
  177. local function KillLCD(ply,cmd,args)
  178.     if not ply:IsAdmin() then return end
  179.     timer.Destroy("WriteLCD")
  180.     file.Write(LCDFile, "sv_WriteLCD Disabled")
  181.     ply:PrintMessage(HUD_PRINTCONSOLE, "LCD: Killed\n")
  182. end
  183. concommand.Add("lcd_kill", KillLCD)
  184.  
  185. local function RestartLCD(ply,cmd,args)
  186.     if not ply:IsAdmin() then return end
  187.     include("HSP/server/sv_WriteLCD.lua")
  188.     ply:PrintMessage(HUD_PRINTCONSOLE, "LCD: Restarted\n")
  189. end
  190. concommand.Add("lcd_reload", RestartLCD)
  191.  
  192. local function RestartLCD(ply,cmd,args)
  193.     ply:PrintMessage(HUD_PRINTCONSOLE, "\n"..LCDBuffer().."\n" )
  194. end
  195. concommand.Add("lcd_print", RestartLCD)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement