- 5
- 0
- Версия SA-MP
-
- 0.3.7 (R1)
ru: в этом коде я получаю 40 кадров в секунду, потому что шрифт создается каждую секунду, и как это исправить? я пытался написать этот код вне цикла, но тогда он не проверяет каждый раз, было ли изменено разрешение или нет
en: in this code i'm getting 40 fps because font creates every second and how can i fix it? i tried to write that code outside loop but then it doesn't check everytime if resolution has been changed or not
en: in this code i'm getting 40 fps because font creates every second and how can i fix it? i tried to write that code outside loop but then it doesn't check everytime if resolution has been changed or not
Lua:
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
repeat wait(0) until isSampAvailable()
sampAddChatMessage('{C3B1E1}[DT] {FFFFFF}Warmatebit Chaitvirta by {C3B1E1}sulo {FFFFFF}| For EDRP | Gamoiyenet {C3B1E1}/dsettings', -1)
if not doesDirectoryExist("moonloader\\config") then createDirectory("moonloader\\config") end
if settings == nil then
settings = inicfg.load({
SETTINGS = {
amount = 3,
key = 88,
enabled = true
}
}, '..\\config\\drugtimer.ini')
inicfg.save(settings, '..\\config\\drugtimer.ini')
thisScript():reload()
end
sampRegisterChatCommand('dsettings', function()
lua_thread.create(dsettings)
end)
while true do
wait(0)
local settings = inicfg.load(nil, direct)
if active == false and settings.SETTINGS.enabled == true then
local screenX, screenY = getScreenResolution()
local x = screenX * (pos[1] / 100)
local y = screenY * (pos[2] / 100)
if screenX > 1440 or screenX == 1440 then
my_font = renderCreateFont('Verdana', 14, font_flag.BOLD + 12)
renderFontDrawText(my_font, "Use!", x, y, 0xFFFFFFFF)
elseif screenX < 1440 or screenX > 1152 or screenX == 1152 then
my_font = renderCreateFont('Verdana', 9, font_flag.BOLD + 12)
renderFontDrawText(my_font, "Use!", x, y, 0xFFFFFFFF)
elseif screenX < 1152 or screenX > 640 or screenX == 640 then
my_font = renderCreateFont('Verdana', 2, font_flag.BOLD + 12)
renderFontDrawText(my_font, "Use!", x, y, 0xFFFFFFFF)
end
end
if wasKeyPressed(settings.SETTINGS.key) and active == false and not sampIsChatInputActive() and not sampIsDialogActive() and settings.SETTINGS.enabled == true then
local final_command = command .. " " .. settings.SETTINGS.amount -- Create a new variable instead of modifying the global command
sampSendChat(final_command)
end
end
end