Advertisement
aveyo

coreinit

Oct 4th, 2017
1,749
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 0 0
  1. -- this file: \steamapps\common\dota 2 beta\game\dota\scripts\vscripts\core\coreinit.lua
  2. -- Dota show behavior on startup and after match by AveYo v8 with dynamic grade color [set it and forget it]
  3. -- v9 final : Reliable, native VScript scheduler!
  4.  
  5. local ToConsole = function(s) if SendToServerConsole then SendToServerConsole(s) else SendToConsole(s) end end
  6. local HideBehaviorScore = function(t) ToConsole( 'top_bar_message "" ' .. t ) Convars:SetStr('cl_class','default') end
  7. local ShowBehaviorScore = function(t)
  8.   local behavior_score = Convars:GetStr( 'cl_class' ):gsub('\n','') -- import i/o cvar cl_class
  9.   local grade = behavior_score:gsub('behavior_score: ',''):gsub('+',''):gsub('-','') -- substring grade
  10.   local flower = { Normal=true, A=true, B=true, C=true } -- Roses are Red, Violetes are Blue
  11.   local ass = 1 -- set flag to use red message by default
  12.   if flower[grade] then ass = 0 end -- set flag to use blue message if behavior_score is flower grade
  13.   print( behavior_score ) -- print behavior_score into Console
  14.   local VScheduler = EntIndexToHScript(0) -- if there are entities loaded, than vscheduler is available
  15.   if VScheduler then
  16.     ToConsole( 'top_bar_message "' .. behavior_score .. '" ' .. ass .. ';' ) -- show top bar gui message
  17.     VScheduler:SetContextThink( "GabenPlz", function() HideBehaviorScore(ass) end, 4 ) -- hide after 4 seconds
  18.   end  
  19. end
  20.  
  21. if SendToServerConsole then -- local client only [ VScripts loads two vm's, one for sv, one for cl ]
  22.   ToConsole( 'developer 1; dota_game_account_client_debug | cl_class; developer 0;' ) -- save score into cl_class
  23.   ListenToGameEvent("player_connect_full", ShowBehaviorScore, nil) -- show message after each new map
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement