цвета lua

heybeykyept

Известный
Автор темы
415
299
Версия MoonLoader
Другое
привет ребят. начал вчера изучать lua, и столкнулся с проблемой.
изучать начал тект и трабл
сделал как на видео 2 переменных с цветами для удобства, но не выводится сам цвет, а только типо переменная. помогите пожалуйста




 

heybeykyept

Известный
Автор темы
415
299
Можешь скинуть код нормально? Не скринами

Вот так:
Lua:
...
1. script_name('test script')
2. script_author('heybey')
3. script_description('text')
4.
5. require "lib.moonloader"
6.
7. local tag = '[Author - heybey]:'
8. local main_color = 0x9A2EFE
9. local main_color_text = "(9A2EFE)"
10.local white_color = "(FFFFFF)"
11.
12. function main()
13. if not isSampLoaded() or not isSampfuncsLoaded() then return end
14. while not isSampAvailable() do wait(100) end
15.
16. sampRegisterChatCommand ("normal", cmd_test)
17. sampRegisterChatCommand ("bad", bad)
18. sampRegisterChatCommand ("great", great)
19.
20. sampAddChatMessage(tag .. " Activation - /normal", 0xFFFF00)
21.
22. while true do
23. wait(0)
24.
25. end
26.
27. end
28.
29. function cmd_test(arg)
30. sampAddChatMessage("Succesfull", main_color)
40. end
41.
42. function bad(arg)
43. if #arg == 0 then
44. sampAddChatMessage ("arg not completed")
45. else
46. sampAddChatMessage ("arg completed. arg - " .. arg, main_color)
47. end
48.
49. end
50.
51. function great(arg)
52. var1, var2 = string.match(arg, "(.+) (.+)")
53. if var1 == nil or var1 == "" then
54. sampAddChatMessage("tw0 arg, but Im not undetstend", white_color)
55. else
56. sampAddChatMessage("ohh yes, tw0 arguments. first: " .. white_color .. var1 .. ", " .. main_color_text .. "tw0" .. white_color .. var2, main_color)
57. end
58.
59. end
 
  • Ха-ха
Реакции: qdIbp

RedHolms

Известный
Проверенный
617
360
1. script_name('test script')
2. script_author('heybey')
3. script_description('text')
4.
5. require "lib.moonloader"
6.
7. local tag = '[Author - heybey]:'
8. local main_color = 0x9A2EFE
9. local main_color_text = "(9A2EFE)"
10.local white_color = "(FFFFFF)"
11.
12. function main()
13. if not isSampLoaded() or not isSampfuncsLoaded() then return end
14. while not isSampAvailable() do wait(100) end
15.
16. sampRegisterChatCommand ("normal", cmd_test)
17. sampRegisterChatCommand ("bad", bad)
18. sampRegisterChatCommand ("great", great)
19.
20. sampAddChatMessage(tag .. " Activation - /normal", 0xFFFF00)
21.
22. while true do
23. wait(0)
24.
25. end
26.
27. end
28.
29. function cmd_test(arg)
30. sampAddChatMessage("Succesfull", main_color)
40. end
41.
42. function bad(arg)
43. if #arg == 0 then
44. sampAddChatMessage ("arg not completed")
45. else
46. sampAddChatMessage ("arg completed. arg - " .. arg, main_color)
47. end
48.
49. end
50.
51. function great(arg)
52. var1, var2 = string.match(arg, "(.+) (.+)")
53. if var1 == nil or var1 == "" then
54. sampAddChatMessage("tw0 arg, but Im not undetstend", white_color)
55. else
56. sampAddChatMessage("ohh yes, tw0 arguments. first: " .. white_color .. var1 .. ", " .. main_color_text .. "tw0" .. white_color .. var2, main_color)
57. end
58.
59. end
Lua:
script_name('test script')
script_author('heybey')
script_description('text')

require "lib.moonloader"

local tag = '[Author - heybey]:'
local main_color = 0x9A2EFE
local main_color_text = "(9A2EFE)"
local white_color = -1 -- Тоже самое, что и 0xFFFFFFFF

function main()
   if not isSampLoaded() or not isSampfuncsLoaded() then return end
   while not isSampAvailable() do wait(100) end
 
   sampRegisterChatCommand ("normal", cmd_test)
   sampRegisterChatCommand ("bad", bad)
   sampRegisterChatCommand ("great", great)
   sampAddChatMessage(tag .. " Activation - /normal", 0xFFFF00)
 
   wait(-1)
end
function cmd_test(arg)
   sampAddChatMessage("Succesfull", main_color)
end
function bad(arg)
   if #arg == 0 then
      sampAddChatMessage ("arg not completed", -1) -- Если не передавать цвет, сообщение будет черное
   else
      sampAddChatMessage ("arg completed. arg - " .. arg, main_color)
   end
end
function great(arg)
   var1, var2 = string.match(arg, "(.+) (.+)")
   if var1 == nil or var1 == "" then
      sampAddChatMessage("tw0 arg, but Im not undetstend", white_color)
   else
      sampAddChatMessage("ohh yes, tw0 arguments. first: " .. white_color .. var1 .. ", " .. main_color_text .. "tw0" .. white_color .. var2, main_color)
   end
end
 
  • Bug
Реакции: Andrinall

Andrinall

Известный
680
532
Дело в фигурных скобках.
У тебя в коде они круглые)

Замени это:
Lua:
local main_color_text = "(9A2EFE)"
local white_color = "(FFFFFF)"
На это:
Lua:
local main_color_text = "{9A2EFE}"
local white_color = "{FFFFFF}"

Ну и как показал человек выше, поставь -1 тут
Lua:
sampAddChatMessage("tw0 arg, but Im not undetstend", -1)
и тут
Lua:
sampAddChatMessage ("arg not completed", -1)
( только я не понял сути, зачем он переменную заменил, если оно юзается в строке, а не только в вызове функции )

И для вставки кода есть такая вот конструкция.

1644841742308.png
 
Последнее редактирование: