Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local caller = getScriptCaller()
- local allData = getAllUserData()
- -- getLocalData(string), setLocalData(string, value)
- isUserReg = getLocalData('Diplom_Tema' .. caller.id)
- isUserHasMentor = getLocalData('Diplom_Mentor' .. caller.id)
- diplomExample = "Вы не выбрали тему дипломки.\n Выберите тему !!diplom тема [название темы]\nПримеры тем: \n1) Виды крашеров и защита от них\n2) Актуальность Lua в 2022 \n3) Современные методы разработки плагинов для SAMPFUNCS\n4) Разработка автоматизированного бота для шахты Advance RP \n5) Разработка информационной системы для кладов Arizona RP"
- cmdsList = "Список команд:\n!!diplom тема [название]\n!!diplom руководитель [ник]\n!!diplom статус\n!!diplom [текст диплома]\n!!diplom читать"
- function checkTime()
- local time = getLocalData('Diplom_Delay' .. caller.id)
- if not time then
- setLocalData('Diplom_Delay' .. caller.id, os.time())
- return false
- end
- if os.time() - tonumber(time) > 24*60*60 then
- setLocalData('Diplom_Delay' .. caller.id, os.time())
- return false
- end
- return true
- end
- function setTema(params)
- if not params then return "Введите действительную тему дипломки." end
- if getLocalData('Diplom_Tema' .. caller.id) then return "Тему изменить нельзя" end
- setLocalData('Diplom_Tema' .. caller.id, params)
- setLocalData('Diplom_Tema_date' .. caller.id, os.date("%d %B %Y %X"))
- setLocalData('Diplom_Status' .. caller.id, 0)
- cuprins = "Тема: " .. params .. "\nАвтор: " .. caller.username .. "\n"
- setLocalData('Diplom_Text' .. caller.id, cuprins)
- return "Тема: " .. params .. "\nДата: " .. os.date("%d %B %Y %X") .. "\nСтудент: " .. caller.username or "Ноунейм" .. "\nДанные были отправлены в деканат.\n*Выберите научного руководителя: !!diplom руководитель [ник руководителя]"
- end
- function setMentor(params)
- if not isUserReg then return diplomExample end
- if not params then return "Введите ник руководителя." end
- if getLocalData('Diplom_Mentor' .. caller.id) then return "Нельзя менять руководителя" end
- setLocalData('Diplom_Mentor' .. caller.id, params)
- return "Тема: " .. getLocalData('Diplom_Tema' .. caller.id) .. "\nДата: " .. getLocalData('Diplom_Tema_date' .. caller.id) .. "\nСтудент: " .. caller.username .. "\nНаучный руководитель: " .. params
- end
- function getStatus(params)
- if not isUserReg then return diplomExample end
- if not isUserHasMentor then return "Вы не выбрали научного руководителя.\n !!diplom руководитель [ник руководителя]" end
- return "В разработке."
- end
- function writeDiplom(text)
- if not isUserReg then return diplomExample end
- if not isUserHasMentor then return "Вы не выбрали научного руководителя.\n !!diplom руководитель [ник руководителя]" end
- if not text then return "Харош лить воду в диплом." end
- if checkTime() then
- local time = 24*60*60 - os.time() + tonumber(getLocalData('Diplom_Delay' .. caller.id))
- local hours = math.floor((time % 86400)/3600)
- local minutes = math.floor((time%3600)/60)
- local seconds = math.floor((time%60))
- return string.format("Вы уже писали дипломку. Возвращайтесь через %02d:%02d:%02d",hours,minutes,seconds)
- end
- diplomText = getLocalData('Diplom_Text' .. caller.id)
- setLocalData('Diplom_Text' .. caller.id, diplomText .. "\n" .. text)
- return "Вы вписали в дипломную работу: " .. text
- end
- function readDiplom()
- if not isUserReg then return diplomExample end
- if not isUserHasMentor then return "Вы не выбрали научного руководителя.\n !!diplom руководитель [ник руководителя]" end
- return getLocalData('Diplom_Text' .. caller.id)
- end
- function helpDiplom()
- return cmdsList
- end
- function deleteDiplom()
- setLocalData('Diplom_Tema' .. caller.id, nil)
- setLocalData('Diplom_Tema_date' .. caller.id, nil)
- setLocalData('Diplom_Status' .. caller.id, nil)
- setLocalData('Diplom_Text' .. caller.id, nil)
- setLocalData('Diplom_Mentor' .. caller.id, nil)
- setLocalData('Diplom_Delay' .. caller.id, nil)
- return "Вся информация была удалена из деканата."
- end
- function debuger(params)
- return getLocalData(params .. caller.id)
- end
- function set(params)
- return setLocalData("Diplom_Delay" .. caller.id, params)
- end
- function topDiplom()
- return "В разработке."
- end
- function serve(action, params)
- if action == "тема" then return setTema(params) end
- if action == "руководитель" then return setMentor(params) end
- if action == "debug" then return debuger(params) end
- if action == "set" then return set(params) end
- return writeDiplom(action .. params)
- end
- function call(action)
- if action == "статус" then return getStatus() end
- if action == "читать" then return readDiplom() end
- if action == "помощь" then return helpDiplom() end
- if action == "бросить" then return deleteDiplom() end
- if action == "топ" then return topDiplom() end
- return writeDiplom(action)
- end
- if _ARGS then
- local index = string.find(_ARGS, ' ')
- if index then
- action = string.sub(_ARGS, 1, index - 1)
- params = string.sub(_ARGS, index + 1)
- return serve(action, params)
- else
- action = _ARGS
- return call(action)
- end
- end
- return cmdsList
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement