Advertisement
VXP

MS Console Russian Fix

VXP
Nov 28th, 2015
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.91 KB | None | 0 0
  1. if SERVER then
  2. MsgN( "[MS Server Print] Working." )
  3.  
  4. local function convertTo866( str )
  5.     local tbl = {}
  6.     for p, c in utf8.codes( str ) do
  7.         table.insert( tbl, c )
  8.     end
  9.    
  10.     for i = 1, table.Count( tbl ) do
  11.         -- https://en.wikipedia.org/wiki/Code_page_866
  12.         -- LOWER
  13.         if tbl[i] == utf8.codepoint( "а" ) then
  14.             tbl[i] = 160
  15.         elseif tbl[i] == utf8.codepoint( "б" ) then
  16.             tbl[i] = 161
  17.         elseif tbl[i] == utf8.codepoint( "в" ) then
  18.             tbl[i] = 162
  19.         elseif tbl[i] == utf8.codepoint( "г" ) then
  20.             tbl[i] = 163
  21.         elseif tbl[i] == utf8.codepoint( "д" ) then
  22.             tbl[i] = 164
  23.         elseif tbl[i] == utf8.codepoint( "е" ) then
  24.             tbl[i] = 165
  25.         elseif tbl[i] == utf8.codepoint( "ё" ) then
  26.             tbl[i] = 241
  27.         elseif tbl[i] == utf8.codepoint( "ж" ) then
  28.             tbl[i] = 166
  29.         elseif tbl[i] == utf8.codepoint( "з" ) then
  30.             tbl[i] = 167
  31.         elseif tbl[i] == utf8.codepoint( "и" ) then
  32.             tbl[i] = 168
  33.         elseif tbl[i] == utf8.codepoint( "й" ) then
  34.             tbl[i] = 169
  35.         elseif tbl[i] == utf8.codepoint( "к" ) then
  36.             tbl[i] = 170
  37.         elseif tbl[i] == utf8.codepoint( "л" ) then
  38.             tbl[i] = 171
  39.         elseif tbl[i] == utf8.codepoint( "м" ) then
  40.             tbl[i] = 172
  41.         elseif tbl[i] == utf8.codepoint( "н" ) then
  42.             tbl[i] = 173
  43.         elseif tbl[i] == utf8.codepoint( "о" ) then
  44.             tbl[i] = 174
  45.         elseif tbl[i] == utf8.codepoint( "п" ) then
  46.             tbl[i] = 175
  47.         elseif tbl[i] == utf8.codepoint( "р" ) then
  48.             tbl[i] = 224
  49.         elseif tbl[i] == utf8.codepoint( "с" ) then
  50.             tbl[i] = 225
  51.         elseif tbl[i] == utf8.codepoint( "т" ) then
  52.             tbl[i] = 226
  53.         elseif tbl[i] == utf8.codepoint( "у" ) then
  54.             tbl[i] = 227
  55.         elseif tbl[i] == utf8.codepoint( "ф" ) then
  56.             tbl[i] = 228
  57.         elseif tbl[i] == utf8.codepoint( "х" ) then
  58.             tbl[i] = 229
  59.         elseif tbl[i] == utf8.codepoint( "ц" ) then
  60.             tbl[i] = 230
  61.         elseif tbl[i] == utf8.codepoint( "ч" ) then
  62.             tbl[i] = 231
  63.         elseif tbl[i] == utf8.codepoint( "ш" ) then
  64.             tbl[i] = 232
  65.         elseif tbl[i] == utf8.codepoint( "щ" ) then
  66.             tbl[i] = 233
  67.         elseif tbl[i] == utf8.codepoint( "ъ" ) then
  68.             tbl[i] = 234
  69.         elseif tbl[i] == utf8.codepoint( "ы" ) then
  70.             tbl[i] = 235
  71.         elseif tbl[i] == utf8.codepoint( "ь" ) then
  72.             tbl[i] = 236
  73.         elseif tbl[i] == utf8.codepoint( "э" ) then
  74.             tbl[i] = 237
  75.         elseif tbl[i] == utf8.codepoint( "ю" ) then
  76.             tbl[i] = 238
  77.         elseif tbl[i] == utf8.codepoint( "я" ) then
  78.             tbl[i] = 239
  79.        
  80.         -- UPPER
  81.         elseif tbl[i] == utf8.codepoint( "А" ) then
  82.             tbl[i] = 128
  83.         elseif tbl[i] == utf8.codepoint( "Б" ) then
  84.             tbl[i] = 129
  85.         elseif tbl[i] == utf8.codepoint( "В" ) then
  86.             tbl[i] = 130
  87.         elseif tbl[i] == utf8.codepoint( "Г" ) then
  88.             tbl[i] = 131
  89.         elseif tbl[i] == utf8.codepoint( "Д" ) then
  90.             tbl[i] = 132
  91.         elseif tbl[i] == utf8.codepoint( "Е" ) then
  92.             tbl[i] = 133
  93.         elseif tbl[i] == utf8.codepoint( "Ё" ) then
  94.             tbl[i] = 240
  95.         elseif tbl[i] == utf8.codepoint( "Ж" ) then
  96.             tbl[i] = 134
  97.         elseif tbl[i] == utf8.codepoint( "З" ) then
  98.             tbl[i] = 135
  99.         elseif tbl[i] == utf8.codepoint( "И" ) then
  100.             tbl[i] = 136
  101.         elseif tbl[i] == utf8.codepoint( "Й" ) then
  102.             tbl[i] = 137
  103.         elseif tbl[i] == utf8.codepoint( "К" ) then
  104.             tbl[i] = 138
  105.         elseif tbl[i] == utf8.codepoint( "Л" ) then
  106.             tbl[i] = 139
  107.         elseif tbl[i] == utf8.codepoint( "М" ) then
  108.             tbl[i] = 140
  109.         elseif tbl[i] == utf8.codepoint( "Н" ) then
  110.             tbl[i] = 141
  111.         elseif tbl[i] == utf8.codepoint( "О" ) then
  112.             tbl[i] = 142
  113.         elseif tbl[i] == utf8.codepoint( "П" ) then
  114.             tbl[i] = 143
  115.         elseif tbl[i] == utf8.codepoint( "Р" ) then
  116.             tbl[i] = 144
  117.         elseif tbl[i] == utf8.codepoint( "С" ) then
  118.             tbl[i] = 145
  119.         elseif tbl[i] == utf8.codepoint( "Т" ) then
  120.             tbl[i] = 146
  121.         elseif tbl[i] == utf8.codepoint( "У" ) then
  122.             tbl[i] = 147
  123.         elseif tbl[i] == utf8.codepoint( "Ф" ) then
  124.             tbl[i] = 148
  125.         elseif tbl[i] == utf8.codepoint( "Х" ) then
  126.             tbl[i] = 149
  127.         elseif tbl[i] == utf8.codepoint( "Ц" ) then
  128.             tbl[i] = 150
  129.         elseif tbl[i] == utf8.codepoint( "Ч" ) then
  130.             tbl[i] = 151
  131.         elseif tbl[i] == utf8.codepoint( "Ш" ) then
  132.             tbl[i] = 152
  133.         elseif tbl[i] == utf8.codepoint( "Щ" ) then
  134.             tbl[i] = 153
  135.         elseif tbl[i] == utf8.codepoint( "Ъ" ) then
  136.             tbl[i] = 154
  137.         elseif tbl[i] == utf8.codepoint( "Ы" ) then
  138.             tbl[i] = 155
  139.         elseif tbl[i] == utf8.codepoint( "Ь" ) then
  140.             tbl[i] = 156
  141.         elseif tbl[i] == utf8.codepoint( "Э" ) then
  142.             tbl[i] = 157
  143.         elseif tbl[i] == utf8.codepoint( "Ю" ) then
  144.             tbl[i] = 158
  145.         elseif tbl[i] == utf8.codepoint( "Я" ) then
  146.             tbl[i] = 159
  147.         end
  148.     end
  149.    
  150.     return string.char( unpack(tbl) )
  151. end
  152.  
  153. hook.Remove( "PlayerSay", "MS_PrintValidConsoleChars" )
  154. hook.Add( "PlayerSay", "MS_PrintValidConsoleChars", function( sender, text, teamChat )
  155.     -- Priority, text, userid
  156.     local ply = sender
  157.     text = utf8.force( text ) -- Fixing utf8 string
  158.  
  159.     print( ( IsValid(ply) and ply:Name() or "Console")..": "..text )
  160.    
  161. --  return false -- Then message will not show in player chat
  162. end )
  163.  
  164. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement