- 2
- 2
Всех привествую,недавно увлёкся lua скриптингом. Решил написать простенький вывод времени на экран,прощу помощи от вас. Код ниже
Lua:
local timeTextDraw = {}
function createTimeTextDraw(playerid)
timeTextDraw[playerid] = CreatePlayerTextDraw(playerid, 200.0, 100.0, "_")
PlayerTextDrawBackgroundColor(playerid, timeTextDraw[playerid], 0)
PlayerTextDrawFont(playerid, timeTextDraw[playerid], 1)
PlayerTextDrawLetterSize(playerid, timeTextDraw[playerid], 0.55, 1.5)
PlayerTextDrawColor(playerid, timeTextDraw[playerid], 0xFFFFFFFF)
PlayerTextDrawSetOutline(playerid, timeTextDraw[playerid], 1)
PlayerTextDrawSetProportional(playerid, timeTextDraw[playerid], 1)
PlayerTextDrawHide(playerid, timeTextDraw[playerid])
end
function updatePlayerTimeTextDraw(playerid)
if timeTextDraw[playerid] then
local time = os.date("*t")
local formattedTime = string.format("Текущее время: %02d:%02d:%02d", time.hour, time.min, time.sec)
PlayerTextDrawSetString(playerid, timeTextDraw[playerid], formattedTime)
end
end
function cmd_ttime(playerid, cmdtext)
if timeTextDraw[playerid] then
if IsPlayerTextDrawVisible(playerid, timeTextDraw[playerid]) then
PlayerTextDrawHide(playerid, timeTextDraw[playerid])
else
updatePlayerTimeTextDraw(playerid)
PlayerTextDrawShow(playerid, timeTextDraw[playerid])
SetTimer("updatePlayerTimeTextDraw", 1000, true, playerid)
end
end
end
function onPlayerConnect(playerid)
createTimeTextDraw(playerid)
end
AddCommandHandler("ttime", cmd_ttime)
RegisterPlayerEvent("OnPlayerConnect", onPlayerConnect)
Последнее редактирование модератором: