Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data={}
- winers={}
- --[[quests={
- {t="emote",points=1,id={8},isTime=true,isDone=false,count=0,required=20,text='Sit for 20 seconds continuously'},
- {t="jump",points=2,count=0,required=15,isDone=false,text='Jump 15 times'},
- {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"},
- {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'},
- }
- ]]
- quests={
- {t="emote",points=1,id={65},isTime=false,required=1,text='Use happy emotion'},
- {t="emote",points=4,id={3},isTime=false,x=2113, y=194,zone=80,required=5,text='Kiss the sun 5 times'},
- {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"},
- {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'},
- {t="look",points=666,required=1,text='Look for a changing room and change your clothes'},
- {t="mouse",points=8,isR=false,positions={{x=3097, y=706, zone=20}},text="Find two cups of coffee and click on them"},
- {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'},
- {t="message",points=10,msg="hynixy",x=1030, y=709,zone=180,required=3,text='Say "hynixy" 3 times at the bridge'},
- {t="mouse",points=11,positions={{x=1700, y=384, zone=20}},text="Look for a dove"},
- {t="emote",points=12,id={3},isTime=false,x=3142, y=60,zone=70,required=3,text='Kiss the moon 3 times'},
- {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'},
- }
- for i=1,#quests do
- quests[i].count = 0
- end
- function deepcopy(orig)
- local orig_type = type(orig)
- local copy
- if orig_type == 'table' then
- copy = {}
- for orig_key, orig_value in next, orig, nil do
- copy[deepcopy(orig_key)] = deepcopy(orig_value)
- end
- setmetatable(copy, deepcopy(getmetatable(orig)))
- else
- copy = orig
- end
- return copy
- end
- function lent(tab)
- local count = 0
- for _ in next, tab do
- count = count + 1
- end
- return count
- end
- function eventNewPlayer(n)
- for key=0,3 do
- system.bindKeyboard(n, key, true, true)
- system.bindKeyboard(n, key, false, true)
- end
- for i=0,9 do
- system.bindKeyboard(n, string.byte(tostring(i)), true, true)
- system.bindKeyboard(n, string.byte(tostring(i)), false, true)
- end
- system.bindMouse(n, True)
- if not data[n] then
- data[n]={
- jamp_last=false,
- last_look=tfm.get.room.playerList[n].look,
- emote_time={bool=false, id=id, flag="", time=os.time()},
- quests={deepcopy(quests[1]),deepcopy(quests[2]),deepcopy(quests[3])},
- lq=3,
- count=0,
- text="<p align='right'>",
- }
- end
- Menu(n)
- updateWiners()
- end
- function ListQuests(n)
- local self = data[n]
- local text = self.text
- for i=1,#self.quests do
- local p = self.quests[i]
- local co = self.quests[i].isDone and true or false
- local required = self.quests[i].t == "mouse" and #self.quests[i].positions or p.required
- local tpc = string.format("<ch>[%s Quest]</ch>",p.points) --text = text..""..p.points.."<vp> points </vp> "..p.text..
- 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>")
- end
- ui.addTextArea(1,text,n,20,60,300,nil,1,1,0.8,true,true)
- end
- function updateWiners()
- 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)
- end
- function Menu(n)
- self = data[n]
- ListQuests(n)
- ui.addTextArea(3,"<p align='center'><fc>"..(self.count).."/"..#quests.."</fc> : Finished quests ",n,180,30,140,20,1,1,0.8,true,true)
- 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)
- end
- function or_in(v,w)
- local a = false
- for p,n in pairs(w) do
- if v == n then
- a=true
- end
- end
- return a
- end
- function _in(v,w)
- for i=1,#w do
- if v == w[i] then
- return true
- end
- end
- return false
- end
- function getTableLook(look)
- local looks={}
- local colors ={}
- local types={[1]="Head",[2]="Eyes",[3]="Ears",[4]="Mouth",[5]="Neck",[6]="Hair style",[7]="Tail",[8]="Contact lenses"}
- local fur = tonumber(look:sub(1,look:find(";")-1))
- look = look:sub(look:find(";")+1)
- local i=0
- for l in string.gmatch(look, "[^,]+") do
- i=i+1
- co ={}
- if l:find("_") then
- for p in string.gmatch(l, "[^+]+") do
- table.insert(co, p:find("_") and p:sub(p:find("[_]")+1) or p)
- end
- end
- table.insert(looks, {type=types[i], id=tonumber(l:find("[_]") and l:sub(1,l:find("[_]")-1)) or tonumber(l), colors=co})
- end
- return fur,looks
- end
- function eventLoop()
- local self
- for n,p in pairs(tfm.get.room.playerList) do
- self = data[n]
- if p.isJumping and not self.jamp_last then
- self.jamp_last = true
- self.emote_time.bool = false
- e_PlayerJump(n,p.x,p.y)
- else
- self.jamp_last = false
- end
- if self.emote_time then
- if self.emote_time.bool then
- if os.time()-1000 > self.emote_time.time then
- e_EmoteAfterSecond(n,true,self.emote_time.id,self.emote_time.flag)
- self.emote_time.time = os.time()
- end
- else
- e_EmoteAfterSecond(n,false)
- self.emote_time.bool = false
- end
- end
- for q=1,#self.quests do
- if self.quests[q] ~= nil then
- if self.quests[q].isDone then
- if self.quests[q].Hide then
- if os.time()-4000 > self.quests[q].Hide then
- self.lq = self.lq + 1
- if quests[self.lq] then
- self.quests[q] = deepcopy(quests[self.lq])
- else
- table.remove(self.quests,q)
- end
- Menu(n)
- end
- else
- self.quests[q].Hide = os.time()
- self.count = self.count + 1
- if self.count == #quests then
- winers[#winers+1] = n
- self.text = "<p align='center'><t>You are the winner number "..#winers.."!"
- end
- updateWiners()
- end
- end
- end
- end
- end
- end
- function eventKeyboard(n,key,down,Px,Py)
- local self = data[n]
- if or_in(key,{0,1,2,3}) and self.emote_time then
- self.emote_time.bool = false
- end
- if key == 3 and down then
- if self.emote_time then
- e_EmoteAfterSecond(n,false)
- end
- e_EmoteAfterSecond(n,true,50,flag)
- self.emote_time = {bool=true, id=50, flag="", time=os.time()}
- elseif key >= string.byte("0") and key <= string.byte("9") and down then
- if self.emote_time then
- e_EmoteAfterSecond(n,false)
- end
- e_EmoteAfterSecond(n,true,tonumber(string.char(key))+60,flag)
- self.emote_time = {bool=true, id=tonumber(string.char(key))+60, flag="", time=os.time()}
- end
- end
- function eventPlayerDied(n)
- local self = data[n]
- self.emote_time.bool = false
- end
- function eventEmotePlayed(n,id,flag)
- local self = data[n]
- if self.emote_time then
- e_EmoteAfterSecond(n,false)
- end
- e_EmoteAfterSecond(n,true,id,flag)
- self.emote_time = {bool=true, id=id, flag="", time=os.time()}
- end
- function e_PlayerLookChanged(n,look)
- local self = data[n]
- --tfm.exec.displayParticle(3, x, y)
- --print(n)
- for i=1,#self.quests do
- if self.quests[i].t == "look" and not self.quests[i].isDone then
- self.quests[i].count = self.quests[i].count + 1
- self.quests[i].isDone = self.quests[i].count == self.quests[i].required and true or false
- ListQuests(n)
- end
- end
- end
- function e_PlayerJump(n, x, y)
- local self = data[n]
- for i=1,#self.quests do
- if self.quests[i].t == "jump" and not self.quests[i].isDone then
- self.quests[i].count = self.quests[i].count + 1
- self.quests[i].isDone = self.quests[i].count == self.quests[i].required and true or false
- ListQuests(n)
- end
- end
- end
- function e_EmoteAfterSecond(n,play,id,flag)
- local self = data[n]
- for i=1,#self.quests do
- if self.quests[i] then
- if self.quests[i].t == "emote" and not self.quests[i].isDone then
- if play then
- if _in(id,self.quests[i].id) then
- if self.quests[i].x and self.quests[i].y then
- p = tfm.get.room.playerList[n]
- if ((p.x - self.quests[i].x)^2 + (p.y - self.quests[i].y)^2 <= self.quests[i].zone^2) then
- self.quests[i].count = self.quests[i].count + 1
- end
- else
- self.quests[i].count = self.quests[i].count + 1
- end
- self.quests[i].isDone = self.quests[i].count == self.quests[i].required
- end
- else
- if self.quests[i].isTime then
- self.quests[i].count = 0
- end
- end
- ListQuests(n)
- end
- end
- end
- end
- function eventMouse(n,x,y)
- local self = data[n]
- for i=1,#self.quests do
- if self.quests[i] then
- if self.quests[i].t == "mouse" and not self.quests[i].isDone then
- if not self.quests[i].requireds then
- self.quests[i].requireds = {}
- end
- for ii,e in pairs(self.quests[i].positions) do
- if ((x - e.x)^2 + (y - e.y)^2 <= e.zone^2) and not self.quests[i].requireds[ii] then
- if not self.quests[i].isR then
- self.quests[i].requireds[ii] = true
- self.quests[i].count = self.quests[i].count + 1
- self.quests[i].isDone = self.quests[i].count == #self.quests[i].positions
- else
- if ii-1 == self.quests[i].count or (self.quests[i].count == 0 and ii == 1) then
- self.quests[i].requireds[ii] = true
- self.quests[i].count = self.quests[i].count + 1
- self.quests[i].isDone = self.quests[i].count == #self.quests[i].positions
- end
- end
- ListQuests(n)
- end
- end
- end
- end
- end
- end
- function eventChatMessage(n,msg)
- local self = data[n]
- for i=1,#self.quests do
- if self.quests[i] then
- if self.quests[i].t == "message" and not self.quests[i].isDone then
- if self.quests[i].x and self.quests[i].y and self.quests[i].zone then
- local p = tfm.get.room.playerList[n]
- 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
- self.quests[i].count = self.quests[i].count + 1
- end
- else
- self.quests[i].count = self.quests[i].count + 1
- end
- self.quests[i].isDone = self.quests[i].count == self.quests[i].required
- ListQuests(n)
- end
- end
- end
- end
- function eventTextAreaCallback(id, name, event)
- self = data[name]
- if event == "change" then
- local p = tfm.get.room.playerList[name]
- if ((p.x - 1418)^2 + (p.y - 220)^2 <= 30^2) then
- if self.last_look ~= p.look then
- e_PlayerLookChanged(name,p.look)
- self.last_look = p.look
- tfm.exec.killPlayer(name)
- tfm.exec.respawnPlayer(name)
- tfm.exec.movePlayer(name, p.x, p.y)
- else
- ui.addPopup(1, 0, "<p align='center'>You didn't change your cloths<br> change them and try again", name, 250, 200, 300, true)
- end
- else
- ui.addPopup(1, 0, "<p align='center'>You must be inside the dressroom", name, 250, 200, 300, true)
- end
- elseif event == "l_w" then
- local text = ""
- for i,n in pairs (winers) do
- text = text..string.format("<fc>%s</fc> : %s\n", i, n)
- if i == 18 then
- break
- end
- end
- ui.addTextArea(10, "<p align='center'>Ranking</p>"..text.."...", name, 460, 67, 189, 290, 0x000001, 0x000001, 0.9, true)
- 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)
- elseif event == "close_wins" then
- ui.removeTextArea(10, name)
- ui.removeTextArea(11, name)
- end
- end
- table.foreach(tfm.get.room.playerList, eventNewPlayer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement