Advertisement
Guest User

Jan

a guest
Sep 19th, 2019
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. local UpdateMMR = function()
  2. local update = 'hostfile "";developer 1;dota_game_account_client_debug | hostfile;developer 0; dota_mmr | hostfile | hostfile;'
  3. SendToServerConsole( update ) -- update current mmr cvar
  4. end
  5. local HideMMR = function(t) SendToServerConsole( 'top_bar_message "" ' .. t ) end
  6. local ShowMMR = function(t)
  7. UpdateMMR()
  8. local current = Convars:GetStr( 'hostfile' ):upper() -- get current mmr cvar
  9. local supp, core = string.match(current, "%a+ : ([%w]+) [%a%_]+ = %a+ : ([%w]+) [%a%_]+ = [%a%_]")
  10. local bs = string.match(current, "%a+ : [%w]+ [%a%_]+ = %a+ : [%w]+ [%a%_]+ = [%a%_]+: ([%w]+)")
  11. if bs == nil then bs = "OFFLINE" end
  12. local previous = Convars:GetStr( 'cl_class' ) -- get previous mmr cvar
  13. if previous == (""..core.."."..supp.."") then -- same MMR
  14. print("ShowMMR same")
  15. Msg(GetSystemDate().." "..GetSystemTime().." Behavior: "..bs.. " Core: "..core.." Support: "..supp.."\n\n")
  16. elseif previous == "default" then -- initial script setup or cvars reset
  17. print("ShowMMR init")
  18. Msg(GetSystemDate().." "..GetSystemTime().." Behavior: "..bs.. " Core: "..core.." Support: "..supp.."\n\n")
  19. Convars:SetStr( 'cl_class', core.."."..supp ) -- set previous MMR cvar
  20. else -- changed MMR
  21. local core1, supp1 = string.match(previous, "(%w+).(%w+)")
  22. local c, s, c1, s1, c1c, s1s = tonumber(core), tonumber(supp), tonumber(core1), tonumber(supp1), 0, 0
  23. if c ~= nil and c1 ~= nil then c1c = c - c1 elseif c ~= nil then c1c = c elseif c1 ~= nil then c1c = 0 - c1 end
  24. if s ~= nil and s1 ~= nil then s1s = s - s1 elseif s ~= nil then s1s = s elseif s1 ~= nil then s1s = 0 - s1 end
  25. local tcolor, ccolor, scolor = 0, "00FF00FF", "00FF00FF"
  26. if c1c < 0 then tcolor = 1 ccolor = "FF0000FF" else c1c = "+"..c1c end
  27. if s1s < 0 then tcolor = 1 scolor = "FF0000FF" else s1s = "+"..s1s end
  28. local cmd = "grep . "..GetSystemDate().." "..GetSystemTime().." Behavior: "..bs.." Core: "..core.." ;log_color General "
  29. cmd = cmd.. ccolor.." | grep %;grep . "..c1c.." ;log_color General 00000000 | grep %;grep . Support: "..supp
  30. cmd = cmd.. " ;log_color General "..scolor.." | grep %;grep . "..s1s.." ;log_color General 00000000 | grep %;echoln;echoln"
  31. print("ShowMMR changed")
  32. SendToServerConsole(cmd) -- pretty print MMR changes
  33. Convars:SetStr( 'cl_class', core.."."..supp ) -- set previous MMR cvar to the current one
  34. local VScheduler = EntIndexToHScript(0) -- if there are entities loaded, than vscheduler is available
  35. if VScheduler then
  36. local roses_are_red_violetes_are_blue = 'Core: '..c1c..("\t"):rep(10)..'BS: '..bs..("\t"):rep(10)..'Support: '..s1s
  37. SendToServerConsole('top_bar_message "'..roses_are_red_violetes_are_blue..'" '..tcolor..';') -- show top bar message
  38. VScheduler:SetContextThink( "GabenPlz", function() HideMMR(tcolor) end, 8 ) -- hide after 8 seconds
  39. end
  40. end
  41. end
  42.  
  43. if SendToServerConsole then -- local server only [ VScripts loads two vm's, one for sv, one for cl ]
  44. UpdateMMR()
  45. ListenToGameEvent("player_connect_full", ShowMMR, nil) -- show message after each new map / disconnect
  46. end
  47.  
  48. --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement