Advertisement
suxonov

Untitled

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