скрипт /timecard

KeCu

Участник
Автор темы
35
3
Всем привет.
Кто играет на евольве в гос оргах, те в курсе, чтобы вести отчёты онлайна всех сотрудников, используется скрипт timecard. Прописывают команду /timecard и часы засчитываются в таблицу. Так вот, у меня такой вопрос, как можно переделать этот скрипт под другой проект и привязать другую таблицу?

Вот код

script_properties('work-in-pause', 'forced-reloading-only')
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local timecard = { stats = false, tab = {}, full = {} }
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do wait(0) end
if not doesDirectoryExist('moonloader/config/LVaTools/TimeCard') then createDirectory(getWorkingDirectory().."//config//LVaTools//TimeCard//") end
sampRegisterChatCommand('timecard', function()
sampAddChatMessage('Пытаюсь получить TimeCard...',-1)
timecard.stats = true
sampSendChat('/members')
end)
sampAddChatMessage('TimeCard успешно запущен, активация по команде /timecard',-1)
wait(-1)
end



function otpravka()
local function MembTologs()
local f = io.open(getWorkingDirectory().."//config//LVaTools//TimeCard//"..os.date("%d.%m.%y %H.%M.txt"), "a")
f:write(table.concat(timecard.full,'\n')); f:flush(); f:close()
end
downloadUrlToFile("https://script.google.com/macros/s/...VOaUCokEx1bjMUZJe2Jcs-3omghUSVDPoU/exec?nick="..sampGetPlayerNickname(select(2, sampGetPlayerIdByCharHandle(PLAYER_PED))).."&card="..table.concat(timecard.tab,' | '))
MembTologs()
end

require('lib.samp.events').onServerMessage = function(color, text)
if timecard.stats then
if text:find('Члены организации Он') then timecard.tab = {}; timecard.full = {}; table.insert(timecard.full, text) return false end
if text:find('ID: %d+ | %d+:%d+ %d+.%d+.%d+ | %w+_%w+.+%: .+%- .+') then
local nick = text:match('ID: %d+ | %d+:%d+ %d+.%d+.%d+ | (%w+_%w+).+%: .+%- .+')
if text:find('На работе') then table.insert(timecard.tab, nick) end
table.insert(timecard.full, text)
return false
end
if text:find('Всего: %d+ человек') then
sampAddChatMessage('Отправляю TimeCard...',-1)
table.insert(timecard.full, text)
timecard.stats = false
lua_thread.create(otpravka)
return false
end
if #text < 3 then return false end
end
end


function split(inputstr, sep)
if sep == nil then sep = "%s" end
local t = {} ; i = 1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t = str
i = i + 1
end
return t
end