Advertisement
Guest User

Untitled

a guest
Nov 30th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.18 KB | None | 0 0
  1. local config = {
  2. pmMsg = "Hello! I saw you we're looking for a group.",
  3. pmStorage = 1594,
  4.  
  5. }
  6.  
  7.  
  8.  
  9. searchingGroup = {}
  10. searchingMore = {}
  11.  
  12. function searchModual(player)
  13. player:registerEvent("search_modalWindow")
  14.  
  15. local title = "Pick your choice"
  16. 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."
  17.  
  18. local window = ModalWindow(1600, title, message)
  19.  
  20. window:addButton(100, "Exit")
  21. window:addButton(101, "LFM")
  22. window:addButton(102, "LFG")
  23. window:setDefaultEnterButton(102)
  24. window:setDefaultEscapeButton(100)
  25.  
  26. window:sendToPlayer(player)
  27. return true
  28. end
  29.  
  30. function groupModualStatsModual(player)
  31. player:registerEvent("search_modalWindow")
  32. local title = ""
  33. local message = ""
  34. local List = true
  35. if #searchingGroup < 1 then
  36. title = "Sorry, no one is looking for a group right now!"
  37. message = "Sorry, no one is looking for a group right now. You can add yourself by clicking on add me."
  38. List = false
  39. else
  40. title = "Looking for group"
  41. 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."
  42. end
  43. local window = ModalWindow(1601, title, message)
  44.  
  45. if List then
  46. window:addButton(100, "PM")
  47. window:addButton(103, "Remove Me")
  48. for i = 1, #searchingGroup do
  49. local p = Player(searchingGroup[i])
  50. if p then
  51. local text = "[lv."..p:getLevel().."] "..p:getName().." [Voc."..p:getVocation():getName().."]"
  52. window:addChoice(i, text)
  53. else
  54. table.remove(searchingGroup, i)
  55. end
  56. end
  57. if #searchingGroup < 1 then
  58. return groupModualStatsModual(player)
  59. end
  60. end
  61.  
  62.  
  63. window:addButton(101, "Add Me")
  64. window:addButton(102, "Back")
  65. window:setDefaultEnterButton(100)
  66. window:setDefaultEscapeButton(102)
  67.  
  68. window:sendToPlayer(player)
  69. return true
  70. end
  71.  
  72. function AddMeGroup(player)
  73. local f = false
  74. local msg = "You have been added to LFG list."
  75. for _, P in ipairs(searchingGroup) do
  76. if P == player:getName() then
  77. msg = "You are already added into this list."
  78. f = true
  79. break
  80. end
  81. end
  82. player:popupFYI(msg)
  83. if not f then
  84. table.insert(searchingGroup, player:getName())
  85. end
  86. searchModual(player)
  87. return true
  88. end
  89.  
  90. function RemoveMeGroup(player)
  91. local f = false
  92. local msg = "You have been removed from the LFG list."
  93. for i = 1, #searchingGroup do
  94. if searchingGroup[i] == player:getName() then
  95. table.remove(searchingGroup, i)
  96. f = true
  97. break
  98. end
  99. end
  100. if not f then
  101. msg = "You haven't been added to the list."
  102. end
  103. player:popupFYI(msg)
  104. searchModual(player)
  105. return true
  106. end
  107.  
  108. function moreModualStatsModual(player)
  109. player:registerEvent("search_modalWindow")
  110. local title = ""
  111. local message = ""
  112. local List = true
  113. if #searchingMore < 1 then
  114. title = "Sorry, no one is looking for more right now!"
  115. message = "Sorry, no one is looking for more right now. You can add yourself by clicking on add me."
  116. List = false
  117. else
  118. title = "Looking for more"
  119. 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."
  120. end
  121. local window = ModalWindow(1602, title, message)
  122.  
  123. if List then
  124. window:addButton(100, "PM")
  125. window:addButton(103, "Remove Me")
  126. for i = 1, #searchingMore do
  127. local p = Player(searchingMore[i])
  128. if p then
  129. local text = "[lv."..p:getLevel().."] "..p:getName().." [Voc."..p:getVocation():getName().."]"
  130. window:addChoice(i, text)
  131. else
  132. table.remove(searchingMore, i)
  133. end
  134. end
  135. if #searchingMore < 1 then
  136. return moreModualStatsModual(player)
  137. end
  138. end
  139.  
  140.  
  141. window:addButton(101, "Add Me")
  142. window:addButton(102, "Back")
  143. window:setDefaultEnterButton(100)
  144. window:setDefaultEscapeButton(102)
  145.  
  146. window:sendToPlayer(player)
  147. return true
  148. end
  149.  
  150.  
  151. function AddMeMore(player)
  152. local f = false
  153. local msg = "You have been added to LFM list."
  154. for _, P in ipairs(searchingMore) do
  155. if P == player:getName() then
  156. msg = "You are already added into this list."
  157. f = true
  158. break
  159. end
  160. end
  161. player:popupFYI(msg)
  162. if not f then
  163. table.insert(searchingMore, player:getName())
  164. end
  165. searchModual(player)
  166. return true
  167. end
  168.  
  169. function RemoveMeMore(player)
  170. local f = false
  171. local msg = "You have been removed from the LFM list."
  172. for i = 1, #searchingMore do
  173. if searchingMore[i] == player:getName() then
  174. table.remove(searchingMore, i)
  175. f = true
  176. break
  177. end
  178. end
  179. if not f then
  180. msg = "You haven't been added to the list."
  181. end
  182. player:popupFYI(msg)
  183. searchModual(player)
  184. return true
  185. end
  186.  
  187.  
  188. function findModual(player, modalWindowId, buttonId, choiceId)
  189. player:registerEvent("search_modalWindow")
  190. if modalWindowId == 1600 then -- Search First Window
  191. if buttonId == 101 then -- Looking for more
  192. moreModualStatsModual(player)
  193. elseif buttonId == 102 then -- Looking for group
  194. groupModualStatsModual(player)
  195. end
  196. elseif modalWindowId == 1601 then -- LFG MOdual
  197. if buttonId == 100 then -- PM
  198. local m = "Sorry, seems like the player has logged out!"
  199. if player:getStorageValue(config.pmStorage) < os.time() then
  200. if Player(searchingGroup[choiceId]) then
  201. Player(searchingGroup[choiceId]):sendPrivateMessage(player, "[LFG] "..config.pmMsg, MESSAGE_STATUS_CONSOLE_BLUE)
  202. m = "You pmed "..searchingGroup[choiceId].."!"
  203. player:setStorageValue(config.pmStorage, os.time()+15)
  204. end
  205. else
  206. m = "You can only pm one person each 15 seconds."
  207. end
  208. player:popupFYI(m)
  209. groupModualStatsModual(player)
  210. elseif buttonId == 101 then -- Add me
  211. AddMeGroup(player)
  212. elseif buttonId == 102 then -- Add me
  213. searchModual(player)
  214. elseif buttonId == 103 then -- Remove me
  215. RemoveMeGroup(player)
  216. end
  217. elseif modalWindowId == 1602 then -- LFM MOdual
  218. if buttonId == 100 then -- PM
  219. local m = "Sorry, seems like the player has logged out!"
  220. if player:getStorageValue(config.pmStorage) < os.time() then
  221. if searchingMore[choiceId] ~= nil then
  222. Player(searchingMore[choiceId]):sendPrivateMessage(player, "[LFM] "..config.pmMsg, MESSAGE_STATUS_CONSOLE_BLUE)
  223. m = "You pmed "..searchingMore[choiceId].."!"
  224. player:setStorageValue(config.pmStorage, os.time()+15)
  225. end
  226. else
  227. m = "You can only pm one person each 15 seconds."
  228. end
  229. player:popupFYI(m)
  230. moreModualStatsModual(player)
  231. elseif buttonId == 101 then -- Add me
  232. AddMeMore(player)
  233. elseif buttonId == 102 then -- Add me
  234. searchModual(player)
  235. elseif buttonId == 103 then -- Remove me
  236. RemoveMeMore(player)
  237. end
  238. end
  239. return true
  240. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement