From 6324b85ded9d636d2d1b5dd48f8cf3adcd08fc5c Mon Sep 17 00:00:00 2001 From: rubin Date: Fri, 29 Mar 2024 15:39:01 +0300 Subject: [PATCH] fix update utf-8 support --- WheelFortune.lua | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/WheelFortune.lua b/WheelFortune.lua index 455d06c..098659e 100644 --- a/WheelFortune.lua +++ b/WheelFortune.lua @@ -191,10 +191,11 @@ function main() end function sampev.onServerMessage(color, message) + message = AnsiToUtf8(message) if message:find(' Вы поставили (%d+) вирт на x(%d+)') then bet, stavka = message:match(' Вы поставили (%d+) вирт на x(%d+)') stavka_me = stavka - return { color, message } + return { color, Utf8ToAnsi(message) } end if message:find(' Поздравляем! Вы выиграли (%d+) вирт') then vin = message:match(' Поздравляем! Вы выиграли (%d+) вирт') @@ -202,7 +203,7 @@ function sampev.onServerMessage(color, message) inicfg.save(ini, thisScript().name) local S2 = mode1 mode1 = 0 - return { color, message } + return { color, Utf8ToAnsi(message) } end if message:find(' К сожалению, вы проиграли, выпал множитель: x(%d+)') then stavka = message:match(' К сожалению, вы проиграли, выпал множитель: x(%d+)') @@ -222,14 +223,16 @@ function sampev.onServerMessage(color, message) sendKey(16) end end - return { color, message } + return { color, Utf8ToAnsi(message) } end end function sampev.onShowDialog(dialogId, style, title, button1, button2, text) - if gamer == 1 and title:find('Выбор множителя') then + title = AnsiToUtf8(title) + text = AnsiToUtf8(text) + if gamer == 1 and string.find(title, 'Выбор множителя') then lua_thread.create(function(dialogId) - wait(100) + wait(300) local sendList = { [2] = 0, [4] = 1, [8] = 2, [16] = 3, [32] = 4 } sampSendDialogResponse(dialogId, 1, sendList[multiplier], string.format('[%d] x%d', sendList[multiplier], multiplier)) gamer = 2 @@ -238,7 +241,7 @@ function sampev.onShowDialog(dialogId, style, title, button1, button2, text) end if gamer == 2 and title:find('Ввод параметра') and text:find('Укажите ставку') then lua_thread.create(function(dialogId) - wait(100) + wait(300) sampSendDialogResponse(dialogId, 1, 0, math.ceil(cost)) gamer = 0 end, dialogId) @@ -253,13 +256,13 @@ function false0_move1_click2(text, posX, posY) local curX, curY = getCursorPos() if curX >= posX and curX <= posX + textLenght and curY >= posY and curY <= posY + textHeight then renderFontDrawText(font, text, posX, posY, 0xFFbababa) - if isKeyJustPressed(1) then - return 2 - else - return 1 - end + if isKeyJustPressed(1) then + return 2 + else + return 1 + end else - return 0 + return 0 end end @@ -448,7 +451,7 @@ script_update = { script_update.menu.ini[#script_update.menu.ini+1] = address text = string.format("%s%s\n", text, string.format("%s\t%s%s", ini.settings.script_name, (ini.settings.version == ini.settings.server_version and "{59fc30}" or "{ff0000}"),ini.settings.version)) script_update.menu.dialog[#script_update.menu.dialog+1] = function(data) - script_update.menu2.show(data) + script_update.menu2.show(data) end end end @@ -522,6 +525,15 @@ function utf8(...) end utf8({ "sampShowDialog" }, "Utf8ToAnsi") +utf8({ "sampSendChat" }, "Utf8ToAnsi") utf8({ "sampAddChatMessage" }, "Utf8ToAnsi") +utf8({ "print" }, "Utf8ToAnsi") utf8({ "renderGetFontDrawTextLength" }, "Utf8ToAnsi") -utf8({ "renderFontDrawText" }, "Utf8ToAnsi") \ No newline at end of file +utf8({ "renderFontDrawText" }, "Utf8ToAnsi") +utf8({ "sampSetCurrentDialogEditboxText" }, "Utf8ToAnsi") +utf8({ "sampCreate3dTextEx" }, "Utf8ToAnsi") +utf8({ "sampCreate3dText" }, "Utf8ToAnsi") +utf8({ "sampSet3dTextString" }, "Utf8ToAnsi") +utf8({ "sampGetDialogText" }, nil, "AnsiToUtf8") +utf8({ "sampGetDialogCaption" }, nil, "AnsiToUtf8") +utf8({ "sampHasDialogRespond" }, nil, "AnsiToUtf8") \ No newline at end of file