Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --DARKROOM--
- players= { level = {}; rounds = {} }
- tfm.exec.disableAutoScore(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAfkDeath(true)
- tfm.exec.disableAutoNewGame(true)
- local mapcr={"Kaysha","Ilyasport"}
- local admins={"Aviener"}
- maplist={"@1257258", "@6459786", "@6465008", "@6464994", "@4043664", "@5925567"}
- maps=maplist[math.random(#maplist)]
- imagelist={"15250377fc3.png", "1525037a4c0.png", "1525037c672.png", "1525037e340.png", "1525037ff9a.png"}
- skin=imagelist[math.random(#imagelist)]
- lang=string.upper(tfm.get.room.community);
- if lang=="XX" then
- lang = "EN";
- end
- messages = {
- RU=
- {
- welcome='<BV>%s<N>, привет! Добро пожаловать в <BV>#darkroom!<N> Попробуй найти выход из лабиринта. Напиши в чат <J>!help<N> для более подробной информации.';
- help='<BV>Суть игры<N>: найдите <BV>выход из <N>лабиринта!\n<BV>Команды:\n<J>!cont<N> - список контактов\nНажмите<J> [P] <N>- Ваш профиль\nНажмите <J>[M] <N>- магазин\n<BV>Основной концепт<N> придуман игроком Defoster\n<BV>Игра сделана<N> игроком Aviener';
- cont='<BV>Администратор<N>: Aviener\n<BV>Map Crew<N>: '..table.concat(mapcr, ", ");
- win='<CH>%s<N> выиграл <J>игру!'
- };
- EN=
- {
- welcome='<BV>%s<N>, hello! Welcome to <BV>#darkroom!<N> Try to find hole. Type <J>!help<N> for more information.';
- help='<BV>Point of game<N>: Find <BV> the hole (exit) <N>from labyrinth <N>\n<BV>Commands:\n<J>!cont<N> <N>- contacts\n<J>Press [P] <N>- your peofile\n<J>Press [M] <N>- open shop\n<BV>Original idea<N> by Defoster\n<BV>Game made by<N> Aviener';
- cont='<BV>Admin<N>: Aviener\n<BV>Map Crew<N>: '..table.concat(mapcr, ", ");
- win='<CH>%s<N> won the <J>game!'
- }
- }
- --start game
- tfm.exec.newGame(maplist[math.random(#maplist)])
- function isarray(val,arr)
- local flag=true
- for i,v in pairs(arr) do
- if v==val then
- flag=false;
- break
- end
- end
- return flag
- end
- function xmlToobj(xmlS)
- local obj={}
- local i=1
- local blacklist={"0","1","2","4","5","6","7","8","10","12","13","14","15","16","17","18","19","20","21","22","23","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","40","47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98","99","100","101","102","103","104","105","106","107","108","109","110","111","112","113","114","115","116","117","118","119","120","121","122","123","124","125","126","127","128","129","130","131"}
- for w in string.gmatch(xmlS, "<P.-T.->") do
- local tmps=string.sub(w, string.find(w, 'X="[-]?%d+"'))
- xO=string.sub(tmps,string.find(tmps,"[-]?%d+"))
- tmps=string.sub(w, string.find(w, 'Y="[-]?%d+"'))
- yO=string.sub(tmps,string.find(tmps,"[-]?%d+"))
- idO=string.gsub(string.sub(w, string.find(w, 'T="%d+"')),"%D","")
- if isarray(idO,blacklist) then
- print("Found object [" .. tostring(i) .. "] x:" .. tostring(xO) .. "," .. tostring(yO))
- obj[i]={x=xO;y=yO;id=idO}
- i=i+1
- end
- end
- -- table.insert(obj,{x=tonumber(xO);y=tonumber(yO);id=tonumber(idO)})
- return obj
- end
- function eventNewPlayer(playerName)
- players[playerName]={level=0;rounds=0}
- ui.addTextArea(1,"",playerName,0,0,800, 400,0x030303,0x030303,1,true)
- tfm.exec.chatMessage(string.format(messages[lang].welcome, playerName), playerName)
- end
- function eventNewGame()
- if tfm.get.room.xmlMapInfo.xml then
- local myVar = xmlToobj(tfm.get.room.xmlMapInfo.xml);
- local index = math.random(#myVar)
- print("Choose location:" .. tostring(index))
- local tmpO=myVar[index]
- tfm.exec.addShamanObject (27, tmpO.x, tmpO.y-50, 0, 0, 0, ghost)
- tfm.exec.addShamanObject (26, 818, 363, 0, 0, 0, false)
- tfm.exec.addImage("152703b1a0f.png","%Aviener",-13,-12)
- for playerName, key in pairs(tfm.get.room.playerList) do
- local skin = imagelist[math.random(#imagelist)]
- tfm.exec.addImage(skin, "%"..playerName, -13, -12)
- ui.removeTextArea (1, playerName)
- ui.removeTextArea (22, playerName)
- end
- end
- for playerName, key in pairs(tfm.get.room.playerList) do
- players[playerName].rounds = players[playerName].rounds+1
- tfm.exec.bindKeyboard(playerName, 77, true)
- tfm.exec.bindKeyboard(playerName, 80, true)
- end
- end
- --ChatCommands
- function eventChatCommand(playername, cmd)
- if cmd == "help" then
- tfm.exec.chatMessage(messages[lang].help, playername)
- elseif cmd== "cont" then
- tfm.exec.chatMessage(messages[lang].cont, playername)
- end
- end
- function eventPlayerDied(playerName)
- ui.addTextArea(22,"",playerName,0,0,800,400,0x030303,0x030303,1,true)
- end
- for name,player in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
- function eventPlayerWon(playerName)
- ui.addTextArea(1,"",playerName,0,0,800, 400,0x030303,0x030303,1,true)
- players[playerName].level = players[playerName].level+1
- for name,player in pairs(tfm.get.room.playerList) do
- tfm.exec.chatMessage(string.format(messages[lang].win, playerName), name)
- tfm.exec.newGame(maplist[math.random(#maplist)])
- end
- end
- function eventKeyboard(playerName, keyc, down, x, y)
- if keyc == 77 then
- ui.addTextArea(11,"",playerName,171,91,409,215,0x212F36,0x212F36,1,true)
- ui.addTextArea(12,"<a href='event:closeshop'>X</a>",playerName,569,72,11,20,0x212F36,0x212F36,1,true)
- ui.addTextArea(13,"",playerName,214,105,120,60,0x2a3940,0x2a3940,1,true)
- ui.addTextArea(14,"<p align='center'><a href='event:buy1'>Not Available</a></p>",playerName,214,150,120,20,0x3e5057,0x3e5057,1,true)
- ui.addTextArea(15,"<a href='event:items'>Items</a>",playerName,125,116,50,20,0x212F36,0x212F36,1,true)
- ui.addTextArea(16,"<a href='event:skins'>Skins</a>",playerName,125,156,50,20,0x212F36,0x212F36,1,true)
- elseif keyc == 80 then
- ui.addPopup(1,0, "<p align='center'><font size='30' face='Soopafresh' color='#009D9D'>"..playerName.."</font></p>\n\n\n<font color='#BABD2F'>Player's stats</font>\n • Total rounds played: " ..players[playerName].rounds..";\n • Total wins: " ..players[playerName].level..";\n\n\n<font color='#BABD2F'>Shop</font>\n • Total skins: ;\n • Total items: ;",playerName,208, 55, 307, true)
- --ui.addTextArea(8,"<p align='center'><font size='30' face='Soopafresh' color='#009D9D'>"..playerName.."</font></p>",playerName,209, 67, 305, 40,0x32454f, 0x32454f,1,true)
- end
- end
- function eventTextAreaCallback(id, playerName, callback)
- if callback == "closeshop" then
- ui.removeTextArea(11, playername)
- ui.removeTextArea(12, playername)
- ui.removeTextArea(13, playername)
- ui.removeTextArea(14, playername)
- ui.removeTextArea(15, playername)
- ui.removeTextArea(16, playername)
- elseif callback == "close" then
- ui.removeTextArea(7, playername)
- ui.removeTextArea(8, playername)
- ui.removeTextArea(9, playername)
- ui.removeTextArea(10, playername)
- elseif callback == "buy1" then
- tfm.exec.chatMessage('<R>Not Available', playerName)
- end
- end
- function eventLoop(t1, t2)
- if t2<=0 then
- tfm.exec.newGame(maplist[math.random(#maplist)])
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement