local vkeys = require 'vkeys'
local samp = require 'samp.events'
local cfg = {
pos = {x = 500, y = 100},
show_time = 3000
}
local conf_path = getWorkingDirectory() .. "\\config\\money_mover.ini"
local active = false
local last_money = 0
local display_text = ""
local display_color = 0xFFFFFFFF
local timer = 0
function main()
while not isSampAvailable() do wait(100) end
if doesFileExist(conf_path) then
local f = io.open(conf_path, "r")
if f then
cfg.pos.x = tonumber(f:read("*line")) or 500
cfg.pos.y = tonumber(f:read("*line")) or 100
f:close()
end
end
sampAddChatMessage("{FFD700}[MoneyMover]{FFFFFF} Скрипт загружен. Команда: {FFD700}/mny", -1)
last_money = getPlayerMoney(playerHandle)
sampRegisterChatCommand("mny", function()
active = not active
if active then
sampAddChatMessage("{FFD700}[MoneyMover]{FFFFFF} Режим настройки: зажми {BBBBBB}ЛКМ{FFFFFF} и двигай. Повтори /mny для сохранения.", -1)
sampSetCursorMode(3)
display_text = "-1488$"
display_color = 0xFF3232BB
timer = os.clock() + 999999
else
sampSetCursorMode(0)
timer = 0 -- Скрыть
saveConfig()
sampAddChatMessage("{00FF00}[MoneyMover]{FFFFFF} Позиция сохранена!", -1)
end
end)
while true do
wait(0)
local current_money = getPlayerMoney(playerHandle)
if not active and current_money ~= last_money then
local diff = current_money - last_money
if diff > 0 then
display_text = "+" .. diff .. "$"
display_color = 0xFF4CAF50
else
display_text = diff .. "$"
display_color = 0xFF3232BB
end
timer = os.clock() + (cfg.show_time / 1000)
last_money = current_money
end
if active or os.clock() < timer then
if active and isKeyDown(vkeys.VK_LBUTTON) then
local mx, my = getCursorPos()
local sw, sh = getScreenResolution()
cfg.pos.x = mx / (sw / 640)
cfg.pos.y = my / (sh / 448)
end
drawMoneyText(display_text, cfg.pos.x, cfg.pos.y, display_color)
else
sampTextdrawDelete(228)
end
end
end
function drawMoneyText(text, x, y, color)
if sampTextdrawIsExists(228) then
sampTextdrawSetPos(228, x, y)
sampTextdrawSetString(228, text)
sampTextdrawSetLetterSizeAndColor(228, 0.6, 2.2, color)
else
sampTextdrawCreate(228, text, x, y)
sampTextdrawSetLetterSizeAndColor(228, 0.6, 2.2, color)
sampTextdrawSetOutlineColor(228, 2, 0xFF000000)
sampTextdrawSetStyle(228, 2)
sampTextdrawSetProportional(228, true)
end
end
function saveConfig()
if not doesDirectoryExist(getWorkingDirectory() .. "\\config") then
createDirectory(getWorkingDirectory() .. "\\config")
end
local f = io.open(conf_path, "w")
if f then
f:write(cfg.pos.x .. "\n" .. cfg.pos.y)
f:close()
end
end