Как правильно хукать 3DText?

kyrtion

Известный
Автор темы
630
232
Версия MoonLoader
.026-beta
Я нашёл функция, sampev.onCreate3DText(idObject, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, textObject)
но что-то пошло не так...
Хукал 3dtext, но число чет так криво...
Аптечки: 46 из 10000 г, но выдало результаты: мин = 247, макс = 260...?
Мне хотелось бы узнать, как раскрыть измененные краски текста? типа так: Аптечки: {FFAAAA}46 из 10000 г и т.д.

Фыа:
function sampev.onCreate3DText(idObject, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, textObject)
    --print()
    print('founded 3dtext, idObject =='..idObject..', color == '..color)--..', attachedPlayerId == '..attachedPlayerId..', attachedVehicleId == '..attachedVehicleId)
    print('textObject:\n'..textObject)
    print()
    if textObject:find(' (%d*) из (%d*) г') then -- 'Аптечки: 46 из 10000 г' | 'Аптечки: (%d+) из (%d+) г'
        --lua_thread.create(function()
            min, max = textObject:find(' (%d*) из (%d*) г')
            sampAddChatMessage('min == '..min, -1)
            sampAddChatMessage('max == '..max, -1)
        --end
        --)
    end
end

1640406803339.png

1640406465671.png

Плюс, поставил по фильтр idObject, ничего не хукает, ни одной сообщение... бред какой-то
 
Решение
Lua:
function sampev.onCreate3DText(idObject, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, textObject)
    --print()
    print('founded 3dtext, idObject =='..idObject..', color == '..color)--..', attachedPlayerId == '..attachedPlayerId..', attachedVehicleId == '..attachedVehicleId)
    print('textObject:\n'..textObject)
    print()
    if textObject:find('Аптечки:%{......%} (%d*) из (%d*) г') then -- 'Аптечки: 46 из 10000 г' | 'Аптечки: (%d+) из (%d+) г'
        --lua_thread.create(function()
            min, max = textObject:match('(%d*) из (%d*) г')
            sampAddChatMessage('min == '..min, -1)
            sampAddChatMessage('max == '..max, -1)
        --end)
    end
end

qdIbp

Автор темы
Проверенный
1,383
1,139
Хмм...
Код:
min, max = textObject:find('(%d*) из (%d*) г')
вообще чаще всего используют
Код:
min, max = textObject:match('(%d*) из (%d*) г')

попробуй вот так

Lua:
function sampev.onCreate3DText(idObject, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, textObject)
    --print()
    print('founded 3dtext, idObject =='..idObject..', color == '..color)--..', attachedPlayerId == '..attachedPlayerId..', attachedVehicleId == '..attachedVehicleId)
    print('textObject:\n'..textObject)
    print()
    if textObject:find('Аптечки: (%d*) из (%d*) г') then -- 'Аптечки: 46 из 10000 г' | 'Аптечки: (%d+) из (%d+) г'
        --lua_thread.create(function()
            min, max = textObject:match('(%d*) из (%d*) г')
            sampAddChatMessage('min == '..min, -1)
            sampAddChatMessage('max == '..max, -1)
        --end)
    end
end
 
Последнее редактирование:
  • Нравится
Реакции: kyrtion

kyrtion

Известный
Автор темы
630
232
Хмм...
Код:
min, max = textObject:find('(%d*) из (%d*) г')
вообще чаще всего используют
Код:
min, max = textObject:match('(%d*) из (%d*) г')

попробуй вот так

Lua:
function sampev.onCreate3DText(idObject, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, textObject)
    --print()
    print('founded 3dtext, idObject =='..idObject..', color == '..color)--..', attachedPlayerId == '..attachedPlayerId..', attachedVehicleId == '..attachedVehicleId)
    print('textObject:\n'..textObject)
    print()
    if textObject:find('Аптечки: (%d*) из (%d*) г') then -- 'Аптечки: 46 из 10000 г' | 'Аптечки: (%d+) из (%d+) г'
        --lua_thread.create(function()
            min, max = textObject:match('(%d*) из (%d*) г')
            sampAddChatMessage('min == '..min, -1)
            sampAddChatMessage('max == '..max, -1)
        --end)
    end
end
Из-за раскрашенный текст не совпадает как и надо, возможно ли раскрыть цвет формата в 3DText? типа так выводит 'Аптечки:{FFAAAA} 49516 из 10000 г'
Убрал "Аптечки: " и выдало нужные результаты
 

qdIbp

Автор темы
Проверенный
1,383
1,139
Lua:
function sampev.onCreate3DText(idObject, color, position, distance, testLOS, attachedPlayerId, attachedVehicleId, textObject)
    --print()
    print('founded 3dtext, idObject =='..idObject..', color == '..color)--..', attachedPlayerId == '..attachedPlayerId..', attachedVehicleId == '..attachedVehicleId)
    print('textObject:\n'..textObject)
    print()
    if textObject:find('Аптечки:%{......%} (%d*) из (%d*) г') then -- 'Аптечки: 46 из 10000 г' | 'Аптечки: (%d+) из (%d+) г'
        --lua_thread.create(function()
            min, max = textObject:match('(%d*) из (%d*) г')
            sampAddChatMessage('min == '..min, -1)
            sampAddChatMessage('max == '..max, -1)
        --end)
    end
end
 
  • Нравится
Реакции: artemka20046 и kyrtion