Advertisement
Unlocker001_TFM

Untitled

Jun 15th, 2018
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.75 KB | None | 0 0
  1. data={}
  2. winers={}
  3.  
  4. --[[quests={
  5. {t="emote",points=1,id={8},isTime=true,isDone=false,count=0,required=20,text='Sit for 20 seconds continuously'},
  6. {t="jump",points=2,count=0,required=15,isDone=false,text='Jump 15 times'},
  7. {t="mouse",points=3,positions={{x=1074,y=626,zone=20,bl=false}},count=0,isDone=false,text="Look for a small bird and click on it"},
  8. {t="emote",points=4,id={6},isTime=true,isDone=false,x=2406,y=117,zone=40,count=0,required=10,text='Find a bed and sleep on it for 10 seconds'},
  9. }
  10.  
  11. ]]
  12.  
  13. quests={
  14. {t="emote",points=1,id={65},isTime=false,required=1,text='Use happy emotion'},
  15. {t="emote",points=4,id={3},isTime=false,x=2113, y=194,zone=80,required=5,text='Kiss the sun 5 times'},
  16. {t="mouse",points=5,isR=false,positions={{x=2740, y=621, zone=20}, {x=2712, y=644, zone=20}, {x=3101, y=455, zone=25}, {x=2856, y=656, zone=40}, {x=2552, y=464, zone=30}},text="Look for shaman items in the cafeteria"},
  17. {t="emote",points=6,id={0},isTime=false,x=2040, y=773,zone=70,required=1,text='Dance beside the fountain until the mouse in the window sees you'},
  18. {t="look",points=666,required=1,text='Look for a changing room and change your clothes'},
  19. {t="mouse",points=8,isR=false,positions={{x=3097, y=706, zone=20}},text="Find two cups of coffee and click on them"},
  20. {t="emote",points=9,id={50},isTime=true,x=1048,y=253,zone=170,required=20,text='Dive in the swimming pool for 20 seconds'},
  21. {t="message",points=10,msg="hynixy",x=1030, y=709,zone=180,required=3,text='Say "hynixy" 3 times at the bridge'},
  22. {t="mouse",points=11,positions={{x=1700, y=384, zone=20}},text="Look for a dove"},
  23. {t="emote",points=12,id={3},isTime=false,x=3142, y=60,zone=70,required=3,text='Kiss the moon 3 times'},
  24. {t="emote",points=13,id={6},isTime=true,x=1283, y=183,zone=50,required=15,text='Sleep on the red relaxing bed for 15 seconds'},
  25. }
  26.  
  27. for i=1,#quests do
  28. quests[i].count = 0
  29. end
  30.  
  31. function deepcopy(orig)
  32. local orig_type = type(orig)
  33. local copy
  34. if orig_type == 'table' then
  35. copy = {}
  36. for orig_key, orig_value in next, orig, nil do
  37. copy[deepcopy(orig_key)] = deepcopy(orig_value)
  38. end
  39. setmetatable(copy, deepcopy(getmetatable(orig)))
  40. else
  41. copy = orig
  42. end
  43. return copy
  44. end
  45.  
  46. function lent(tab)
  47. local count = 0
  48. for _ in next, tab do
  49. count = count + 1
  50. end
  51. return count
  52. end
  53.  
  54. function eventNewPlayer(n)
  55. for key=0,3 do
  56. system.bindKeyboard(n, key, true, true)
  57. system.bindKeyboard(n, key, false, true)
  58. end
  59. for i=0,9 do
  60. system.bindKeyboard(n, string.byte(tostring(i)), true, true)
  61. system.bindKeyboard(n, string.byte(tostring(i)), false, true)
  62. end
  63. system.bindMouse(n, True)
  64. if not data[n] then
  65. data[n]={
  66. jamp_last=false,
  67. last_look=tfm.get.room.playerList[n].look,
  68. emote_time={bool=false, id=id, flag="", time=os.time()},
  69. quests={deepcopy(quests[1]),deepcopy(quests[2]),deepcopy(quests[3])},
  70. lq=3,
  71. count=0,
  72. text="<p align='right'>",
  73. }
  74. end
  75. Menu(n)
  76. updateWiners()
  77. end
  78.  
  79. function ListQuests(n)
  80. local self = data[n]
  81. local text = self.text
  82. for i=1,#self.quests do
  83. local p = self.quests[i]
  84. local co = self.quests[i].isDone and true or false
  85. local required = self.quests[i].t == "mouse" and #self.quests[i].positions or p.required
  86. local tpc = string.format("<ch>[%s Quest]</ch>",p.points) --text = text..""..p.points.."<vp> points </vp> "..p.text..
  87. text = text..string.format("%s %s %s", p.text, tpc, "<br>"..(co and "<t>" or "<r>")..p.count.."/"..required..(co and "</t>" or "</r>").."<br><br>")
  88. end
  89. ui.addTextArea(1,text,n,20,60,300,nil,1,1,0.8,true,true)
  90. end
  91.  
  92. function updateWiners()
  93. ui.addTextArea(4,"<p align='center'><a href='event:l_w'><fc>"..#winers.."</fc> : winners ",nil,20,30,150,20,1,1,0.8,true,true)
  94. end
  95.  
  96. function Menu(n)
  97. self = data[n]
  98. ListQuests(n)
  99. ui.addTextArea(3,"<p align='center'><fc>"..(self.count).."/"..#quests.."</fc> : Finished quests ",n,180,30,140,20,1,1,0.8,true,true)
  100. ui.addTextArea(100,"<b><p align='center'><font color='#1' ><a href='event:change'>اضغط\nلتغير ملابس",n,1389,118,nil,nil,1,1,0,false,false)
  101. end
  102.  
  103. function or_in(v,w)
  104. local a = false
  105. for p,n in pairs(w) do
  106. if v == n then
  107. a=true
  108. end
  109. end
  110. return a
  111. end
  112.  
  113.  
  114. function _in(v,w)
  115. for i=1,#w do
  116. if v == w[i] then
  117. return true
  118. end
  119. end
  120. return false
  121. end
  122.  
  123. function getTableLook(look)
  124. local looks={}
  125. local colors ={}
  126. local types={[1]="Head",[2]="Eyes",[3]="Ears",[4]="Mouth",[5]="Neck",[6]="Hair style",[7]="Tail",[8]="Contact lenses"}
  127. local fur = tonumber(look:sub(1,look:find(";")-1))
  128. look = look:sub(look:find(";")+1)
  129. local i=0
  130. for l in string.gmatch(look, "[^,]+") do
  131. i=i+1
  132. co ={}
  133. if l:find("_") then
  134. for p in string.gmatch(l, "[^+]+") do
  135. table.insert(co, p:find("_") and p:sub(p:find("[_]")+1) or p)
  136. end
  137. end
  138. table.insert(looks, {type=types[i], id=tonumber(l:find("[_]") and l:sub(1,l:find("[_]")-1)) or tonumber(l), colors=co})
  139. end
  140. return fur,looks
  141. end
  142.  
  143.  
  144. function eventLoop()
  145. local self
  146. for n,p in pairs(tfm.get.room.playerList) do
  147. self = data[n]
  148. if p.isJumping and not self.jamp_last then
  149. self.jamp_last = true
  150. self.emote_time.bool = false
  151. e_PlayerJump(n,p.x,p.y)
  152. else
  153. self.jamp_last = false
  154. end
  155. if self.emote_time then
  156. if self.emote_time.bool then
  157. if os.time()-1000 > self.emote_time.time then
  158. e_EmoteAfterSecond(n,true,self.emote_time.id,self.emote_time.flag)
  159. self.emote_time.time = os.time()
  160. end
  161. else
  162. e_EmoteAfterSecond(n,false)
  163. self.emote_time.bool = false
  164. end
  165. end
  166. for q=1,#self.quests do
  167. if self.quests[q] ~= nil then
  168. if self.quests[q].isDone then
  169. if self.quests[q].Hide then
  170. if os.time()-4000 > self.quests[q].Hide then
  171. self.lq = self.lq + 1
  172. if quests[self.lq] then
  173. self.quests[q] = deepcopy(quests[self.lq])
  174. else
  175. table.remove(self.quests,q)
  176. end
  177. Menu(n)
  178. end
  179. else
  180. self.quests[q].Hide = os.time()
  181. self.count = self.count + 1
  182. if self.count == #quests then
  183. winers[#winers+1] = n
  184. self.text = "<p align='center'><t>You are the winner number "..#winers.."!"
  185. end
  186. updateWiners()
  187. end
  188. end
  189. end
  190. end
  191. end
  192. end
  193.  
  194.  
  195.  
  196. function eventKeyboard(n,key,down,Px,Py)
  197. local self = data[n]
  198. if or_in(key,{0,1,2,3}) and self.emote_time then
  199. self.emote_time.bool = false
  200. end
  201. if key == 3 and down then
  202. if self.emote_time then
  203. e_EmoteAfterSecond(n,false)
  204. end
  205. e_EmoteAfterSecond(n,true,50,flag)
  206. self.emote_time = {bool=true, id=50, flag="", time=os.time()}
  207. elseif key >= string.byte("0") and key <= string.byte("9") and down then
  208. if self.emote_time then
  209. e_EmoteAfterSecond(n,false)
  210. end
  211. e_EmoteAfterSecond(n,true,tonumber(string.char(key))+60,flag)
  212. self.emote_time = {bool=true, id=tonumber(string.char(key))+60, flag="", time=os.time()}
  213. end
  214. end
  215.  
  216. function eventPlayerDied(n)
  217. local self = data[n]
  218. self.emote_time.bool = false
  219. end
  220.  
  221.  
  222. function eventEmotePlayed(n,id,flag)
  223. local self = data[n]
  224. if self.emote_time then
  225. e_EmoteAfterSecond(n,false)
  226. end
  227. e_EmoteAfterSecond(n,true,id,flag)
  228. self.emote_time = {bool=true, id=id, flag="", time=os.time()}
  229. end
  230.  
  231.  
  232.  
  233.  
  234. function e_PlayerLookChanged(n,look)
  235. local self = data[n]
  236. --tfm.exec.displayParticle(3, x, y)
  237. --print(n)
  238. for i=1,#self.quests do
  239. if self.quests[i].t == "look" and not self.quests[i].isDone then
  240. self.quests[i].count = self.quests[i].count + 1
  241. self.quests[i].isDone = self.quests[i].count == self.quests[i].required and true or false
  242. ListQuests(n)
  243. end
  244. end
  245. end
  246.  
  247. function e_PlayerJump(n, x, y)
  248. local self = data[n]
  249. for i=1,#self.quests do
  250. if self.quests[i].t == "jump" and not self.quests[i].isDone then
  251. self.quests[i].count = self.quests[i].count + 1
  252. self.quests[i].isDone = self.quests[i].count == self.quests[i].required and true or false
  253. ListQuests(n)
  254. end
  255. end
  256. end
  257.  
  258.  
  259. function e_EmoteAfterSecond(n,play,id,flag)
  260. local self = data[n]
  261. for i=1,#self.quests do
  262. if self.quests[i] then
  263. if self.quests[i].t == "emote" and not self.quests[i].isDone then
  264. if play then
  265. if _in(id,self.quests[i].id) then
  266. if self.quests[i].x and self.quests[i].y then
  267. p = tfm.get.room.playerList[n]
  268. if ((p.x - self.quests[i].x)^2 + (p.y - self.quests[i].y)^2 <= self.quests[i].zone^2) then
  269. self.quests[i].count = self.quests[i].count + 1
  270. end
  271. else
  272. self.quests[i].count = self.quests[i].count + 1
  273. end
  274. self.quests[i].isDone = self.quests[i].count == self.quests[i].required
  275. end
  276. else
  277. if self.quests[i].isTime then
  278. self.quests[i].count = 0
  279. end
  280. end
  281. ListQuests(n)
  282. end
  283. end
  284. end
  285. end
  286.  
  287.  
  288. function eventMouse(n,x,y)
  289. local self = data[n]
  290. for i=1,#self.quests do
  291. if self.quests[i] then
  292. if self.quests[i].t == "mouse" and not self.quests[i].isDone then
  293. if not self.quests[i].requireds then
  294. self.quests[i].requireds = {}
  295. end
  296. for ii,e in pairs(self.quests[i].positions) do
  297. if ((x - e.x)^2 + (y - e.y)^2 <= e.zone^2) and not self.quests[i].requireds[ii] then
  298. if not self.quests[i].isR then
  299. self.quests[i].requireds[ii] = true
  300. self.quests[i].count = self.quests[i].count + 1
  301. self.quests[i].isDone = self.quests[i].count == #self.quests[i].positions
  302. else
  303. if ii-1 == self.quests[i].count or (self.quests[i].count == 0 and ii == 1) then
  304. self.quests[i].requireds[ii] = true
  305. self.quests[i].count = self.quests[i].count + 1
  306. self.quests[i].isDone = self.quests[i].count == #self.quests[i].positions
  307. end
  308. end
  309. ListQuests(n)
  310. end
  311. end
  312. end
  313. end
  314. end
  315. end
  316.  
  317. function eventChatMessage(n,msg)
  318. local self = data[n]
  319. for i=1,#self.quests do
  320. if self.quests[i] then
  321. if self.quests[i].t == "message" and not self.quests[i].isDone then
  322. if self.quests[i].x and self.quests[i].y and self.quests[i].zone then
  323. local p = tfm.get.room.playerList[n]
  324. if ((p.x - self.quests[i].x)^2 + (p.y - self.quests[i].y)^2 <= self.quests[i].zone^2) and msg:lower() == self.quests[i].msg then
  325. self.quests[i].count = self.quests[i].count + 1
  326. end
  327. else
  328. self.quests[i].count = self.quests[i].count + 1
  329. end
  330. self.quests[i].isDone = self.quests[i].count == self.quests[i].required
  331.  
  332. ListQuests(n)
  333. end
  334. end
  335. end
  336. end
  337.  
  338. function eventTextAreaCallback(id, name, event)
  339. self = data[name]
  340. if event == "change" then
  341. local p = tfm.get.room.playerList[name]
  342. if ((p.x - 1418)^2 + (p.y - 220)^2 <= 30^2) then
  343. if self.last_look ~= p.look then
  344. e_PlayerLookChanged(name,p.look)
  345. self.last_look = p.look
  346. tfm.exec.killPlayer(name)
  347. tfm.exec.respawnPlayer(name)
  348. tfm.exec.movePlayer(name, p.x, p.y)
  349. else
  350. ui.addPopup(1, 0, "<p align='center'>You didn't change your cloths<br> change them and try again", name, 250, 200, 300, true)
  351. end
  352. else
  353. ui.addPopup(1, 0, "<p align='center'>You must be inside the dressroom", name, 250, 200, 300, true)
  354. end
  355. elseif event == "l_w" then
  356. local text = ""
  357. for i,n in pairs (winers) do
  358. text = text..string.format("<fc>%s</fc> : %s\n", i, n)
  359. if i == 18 then
  360. break
  361. end
  362. end
  363. ui.addTextArea(10, "<p align='center'>Ranking</p>"..text.."...", name, 460, 67, 189, 290, 0x000001, 0x000001, 0.9, true)
  364. ui.addTextArea(11, "<p align='center'>______________________<font size='25'>\n</font><a href='event:close_wins'>Close", name, 474, 310, 159, 50, 0x324650, 0x000000, 0, true)
  365. elseif event == "close_wins" then
  366. ui.removeTextArea(10, name)
  367. ui.removeTextArea(11, name)
  368. end
  369. end
  370.  
  371.  
  372.  
  373. table.foreach(tfm.get.room.playerList, eventNewPlayer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement