Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local config = {
- pmMsg = "Hello! I saw you we're looking for a group.",
- pmStorage = 1594,
- }
- searchingGroup = {}
- searchingMore = {}
- function searchModual(player)
- player:registerEvent("search_modalWindow")
- local title = "Pick your choice"
- local message = "Chose from the options below.\n[LFG] will display players which are looking for group for hunts/quests.\n[LFM] will display players which are looking for other things."
- local window = ModalWindow(1600, title, message)
- window:addButton(100, "Exit")
- window:addButton(101, "LFM")
- window:addButton(102, "LFG")
- window:setDefaultEnterButton(102)
- window:setDefaultEscapeButton(100)
- window:sendToPlayer(player)
- return true
- end
- function groupModualStatsModual(player)
- player:registerEvent("search_modalWindow")
- local title = ""
- local message = ""
- local List = true
- if #searchingGroup < 1 then
- title = "Sorry, no one is looking for a group right now!"
- message = "Sorry, no one is looking for a group right now. You can add yourself by clicking on add me."
- List = false
- else
- title = "Looking for group"
- message = "Select a player and press PM to private message that player. If you want to add yourself to the list press Add Me, if you want to remove yourself from the list press Remove Me."
- end
- local window = ModalWindow(1601, title, message)
- if List then
- window:addButton(100, "PM")
- window:addButton(103, "Remove Me")
- for i = 1, #searchingGroup do
- local p = Player(searchingGroup[i])
- if p then
- local text = "[lv."..p:getLevel().."] "..p:getName().." [Voc."..p:getVocation():getName().."]"
- window:addChoice(i, text)
- else
- table.remove(searchingGroup, i)
- end
- end
- if #searchingGroup < 1 then
- return groupModualStatsModual(player)
- end
- end
- window:addButton(101, "Add Me")
- window:addButton(102, "Back")
- window:setDefaultEnterButton(100)
- window:setDefaultEscapeButton(102)
- window:sendToPlayer(player)
- return true
- end
- function AddMeGroup(player)
- local f = false
- local msg = "You have been added to LFG list."
- for _, P in ipairs(searchingGroup) do
- if P == player:getName() then
- msg = "You are already added into this list."
- f = true
- break
- end
- end
- player:popupFYI(msg)
- if not f then
- table.insert(searchingGroup, player:getName())
- end
- searchModual(player)
- return true
- end
- function RemoveMeGroup(player)
- local f = false
- local msg = "You have been removed from the LFG list."
- for i = 1, #searchingGroup do
- if searchingGroup[i] == player:getName() then
- table.remove(searchingGroup, i)
- f = true
- break
- end
- end
- if not f then
- msg = "You haven't been added to the list."
- end
- player:popupFYI(msg)
- searchModual(player)
- return true
- end
- function moreModualStatsModual(player)
- player:registerEvent("search_modalWindow")
- local title = ""
- local message = ""
- local List = true
- if #searchingMore < 1 then
- title = "Sorry, no one is looking for more right now!"
- message = "Sorry, no one is looking for more right now. You can add yourself by clicking on add me."
- List = false
- else
- title = "Looking for more"
- message = "Select a player and press PM to private message that player. If you want to add yourself to the list press Add Me, if you want to remove yourself from the list press Remove Me."
- end
- local window = ModalWindow(1602, title, message)
- if List then
- window:addButton(100, "PM")
- window:addButton(103, "Remove Me")
- for i = 1, #searchingMore do
- local p = Player(searchingMore[i])
- if p then
- local text = "[lv."..p:getLevel().."] "..p:getName().." [Voc."..p:getVocation():getName().."]"
- window:addChoice(i, text)
- else
- table.remove(searchingMore, i)
- end
- end
- if #searchingMore < 1 then
- return moreModualStatsModual(player)
- end
- end
- window:addButton(101, "Add Me")
- window:addButton(102, "Back")
- window:setDefaultEnterButton(100)
- window:setDefaultEscapeButton(102)
- window:sendToPlayer(player)
- return true
- end
- function AddMeMore(player)
- local f = false
- local msg = "You have been added to LFM list."
- for _, P in ipairs(searchingMore) do
- if P == player:getName() then
- msg = "You are already added into this list."
- f = true
- break
- end
- end
- player:popupFYI(msg)
- if not f then
- table.insert(searchingMore, player:getName())
- end
- searchModual(player)
- return true
- end
- function RemoveMeMore(player)
- local f = false
- local msg = "You have been removed from the LFM list."
- for i = 1, #searchingMore do
- if searchingMore[i] == player:getName() then
- table.remove(searchingMore, i)
- f = true
- break
- end
- end
- if not f then
- msg = "You haven't been added to the list."
- end
- player:popupFYI(msg)
- searchModual(player)
- return true
- end
- function findModual(player, modalWindowId, buttonId, choiceId)
- player:registerEvent("search_modalWindow")
- if modalWindowId == 1600 then -- Search First Window
- if buttonId == 101 then -- Looking for more
- moreModualStatsModual(player)
- elseif buttonId == 102 then -- Looking for group
- groupModualStatsModual(player)
- end
- elseif modalWindowId == 1601 then -- LFG MOdual
- if buttonId == 100 then -- PM
- local m = "Sorry, seems like the player has logged out!"
- if player:getStorageValue(config.pmStorage) < os.time() then
- if Player(searchingGroup[choiceId]) then
- Player(searchingGroup[choiceId]):sendPrivateMessage(player, "[LFG] "..config.pmMsg, MESSAGE_STATUS_CONSOLE_BLUE)
- m = "You pmed "..searchingGroup[choiceId].."!"
- player:setStorageValue(config.pmStorage, os.time()+15)
- end
- else
- m = "You can only pm one person each 15 seconds."
- end
- player:popupFYI(m)
- groupModualStatsModual(player)
- elseif buttonId == 101 then -- Add me
- AddMeGroup(player)
- elseif buttonId == 102 then -- Add me
- searchModual(player)
- elseif buttonId == 103 then -- Remove me
- RemoveMeGroup(player)
- end
- elseif modalWindowId == 1602 then -- LFM MOdual
- if buttonId == 100 then -- PM
- local m = "Sorry, seems like the player has logged out!"
- if player:getStorageValue(config.pmStorage) < os.time() then
- if searchingMore[choiceId] ~= nil then
- Player(searchingMore[choiceId]):sendPrivateMessage(player, "[LFM] "..config.pmMsg, MESSAGE_STATUS_CONSOLE_BLUE)
- m = "You pmed "..searchingMore[choiceId].."!"
- player:setStorageValue(config.pmStorage, os.time()+15)
- end
- else
- m = "You can only pm one person each 15 seconds."
- end
- player:popupFYI(m)
- moreModualStatsModual(player)
- elseif buttonId == 101 then -- Add me
- AddMeMore(player)
- elseif buttonId == 102 then -- Add me
- searchModual(player)
- elseif buttonId == 103 then -- Remove me
- RemoveMeMore(player)
- end
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement