[Scriptmeister] Небольшие скрипты на заказ |
![]() ![]() « Citoyen » 1435895940000
| 0 | ||
bulldoozzer a dit : Код local map = [[<C><P /><Z><S><S L="800" v="5000" H="47" X="401" Y="376" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S L="169" H="62" X="8" Y="87" T="6" P="0,0,0.3,0.2,-40,0,0,0" /><S L="10" H="237" X="5" Y="241" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" H="51" X="5" Y="22" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S L="797" H="10" X="400" Y="2" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S L="10" H="366" X="800" Y="178" T="6" P="0,0,0.3,0.2,0,0,0,0" /><S L="169" X="794" H="62" Y="78" T="6" P="0,0,0.3,0.2,40,0,0,0" /></S><D><DS Y="337" X="381" /><DC Y="341" X="451" /><P P="0,0" C="0" Y="-2" T="34" X="1" /><P P="0,0" Y="126" T="41" X="38" /><P P="0,1" Y="128" T="41" X="769" /></D><O /></Z></C>]] tfm.exec.disableAutoNewGame(true) tfm.exec.disableAutoShaman(true) tfm.exec.disableAutoTimeLeft(true) function startGame() tfm.exec.setGameTime(83, true) end function winAllAlive() for k,v in pairs(tfm.get.room.playerList) do if not(v.isDead) then tfm.exec.giveCheese(k) tfm.exec.playerVictory(k) end end end function eventPlayerDied(playerName) local i = 0 for k,v in pairs(tfm.get.room.playerList) do if not(v.isDead) then i = i + 1 end end if i <= 1 then winAllAlive() tfm.exec.newGame(map) end end function eventLoop(currentTime, timeRemaining) if timeRemaining <= 0 then winAllAlive() tfm.exec.newGame(map) end end function eventNewGame() startGame() end tfm.exec.newGame(map) |
![]() ![]() « Consul » 1435928520000
| 0 | ||
|
0 | ||
Bushmeister a dit : Чем от гоночной силы отличается? Да и карты никакие не проигрываются, а система очков это как я говорил - заходишь в нору +1 очко, умираешь -1, за очки покупаешь бонусы. |
![]() ![]() « Consul » 1435936800000
| 0 | ||
Dobrjik a dit : Сам хотел ставить карты, про очки ничего толкового не рассказал, систему бонусов хотел оставить. Как объяснил то и получай. |
![]() ![]() « Citoyen » 1435939740000
| 0 | ||
Dobrjik a dit : На ен форуме недавно спрашивали магазинчик, вот такой код предлагали shop={ {name="Бейсбольная бита",price=6,effect=function(name) tfm.exec.killPlayer(name) end}, {name="Бутылка вина",price=2,effect=function(name) tfm.exec.giveCheese(name) end}, {name="Сырная пица",price=99,effect=function(name) tfm.exec.setShaman(name) end} } tfm.exec.disableAutoScore(true) -- отключить автобалы function eventPlayerWon(name) -- когда игрок зашел в нору tfm.exec.setPlayerScore(name,1,true) -- добавить 1 очко end function eventPlayerDied(name) --когда игрок умер tfm.exec.setPlayerScore(name,-1,true) -- отнять 1 очко end function eventChatCommand(name,command) if command=="shop" then local str="" for id,item in pairs(shop) do str=str.."<a href='event:buy "..id.."'>["..item.price.."] "..item.name.."</a><br />" end ui.addTextArea(1, str, name, 300, 100, 200, 200, nil, nil, 1, true) ui.addTextArea(2, "<b><a href='event:exit'>X</a></b>", name, 485, 100, nil, nil, nil, nil, 0, true) end end function eventTextAreaCallback(id,name,callback) local arg={} for args in callback:gmatch("[^%s]+") do table.insert(arg,args:lower()) end local id=tonumber(arg[2]) if arg[1]=="buy" and id then if shop[id] and tfm.get.room.playerList[name].score>=shop[id].price then if shop[id].effect then shop[id].effect(name) end --Do what you want with the shop item. tfm.exec.setPlayerScore(name,-shop[id].price,true) print(name.." purchased "..shop[id].name) end elseif arg[1]=="exit" then ui.removeTextArea(1, name) ui.removeTextArea(2, name) end end Тут только нет прокрутки карт, чтобы открыть магазин надо ввести в чат !shop При покупки биты ты умираешь, если купил вино то получишь сыр, а если купить пицу то станешь шамом Dernière modification le 1435939980000 |
0 | ||
Я немного дополнил этот код, но есть проблема, каждый раз когда умираешь карта продолжается с тем же временем и я не знаю как это исправить. Еще надо чтобы был админ-лист и специальные команды были только для админов (например запустить следующую карту) tfm.exec.disableAutoNewGame(true) maps={0,1,2,3,4,5,6,7,8,9,10} function eventLoop(time,remaining) if remaining<=0 then tfm.exec.newGame(maps[math.random(#maps)]) end end tfm.exec.setUIMapName("Golden Cheese | Золотой сыр") function eventPlayerDied() local i=0 for n,player in pairs(tfm.get.room.playerList) do if not player.isDead then i=i+1 end end if i==0 then tfm.exec.newGame(maps[math.random(#maps)]) end end tfm.exec.setPlayerScore("Dobrjik", "2000") shop={ {name="Умереть",price=0,effect=function(name) tfm.exec.killPlayer(name) end}, {name="Получить сыр",price=5,effect=function(name) tfm.exec.giveCheese(name) end}, {name="Стать шаманом",price=10,effect=function(name) tfm.exec.setShaman(name) end}, {name="Получить мип",price=3,effect=function(name) tfm.exec.giveMeep(name) end}, {name="Стать вампиром",price=6,effect=function(name) tfm.exec.setVampirePlayer(name) end}, {name="Возрадиться",price=6,effect=function(name) tfm.exec.respawnPlayer(name) end}, {name="Следующая карта",price=500,effect=function(name) tfm.exec.newGame(maps[math.random(#maps)]) end} } tfm.exec.disableAutoScore(true)-- отключить автобалы function eventPlayerWon(name) --когда игрок зашел в нору tfm.exec.setPlayerScore(name,3,true) -- добавить 3 очка end function eventPlayerDied(name) --когда игрок умер tfm.exec.setPlayerScore(name,-1,true) -- отнять 1 очко end function eventPlayerShaman(name) --когда игрок шаман tfm.exec.setPlayerScore(name,1,true) -- добавить 1 очко end function eventChatCommand(name,command) if command=="shop" then local str="" for id,item in pairs(shop) do str=str.."<a href='event:buy "..id.."'>["..item.price.."] "..item.name.."</a><br />" end ui.addTextArea(1, str, name, 300, 100, 200, 200, nil, nil, 1, true) ui.addTextArea(2, "<b><a href='event:exit'>X</a></b>", name, 485, 100, nil, nil, nil, nil, 0, true) end end function eventTextAreaCallback(id,name,callback) local arg={} for args in callback:gmatch("[^%s]+") do table.insert(arg,args:lower()) end local id=tonumber(arg[2]) if arg[1]=="buy" and id then if shop[id] and tfm.get.room.playerList[name].score>=shop[id].price then if shop[id].effect then shop[id].effect(name) end --Do what you want with the shop item. tfm.exec.setPlayerScore(name,-shop[id].price,true) print(name.." purchased "..shop[id].name) end elseif arg[1]=="exit" then ui.removeTextArea(1, name) ui.removeTextArea(2, name) end end |
![]() ![]() « Citoyen » 1436022300000
| 0 | ||
Некоторые замечания eventPlayerShaman - такого события по умолчанию нет если называть функции одинаковыми именами, то будет работать лишь последняя из них Исправленный код tfm.exec.disableAutoNewGame(true) tfm.exec.disableAutoScore(true)-- отключить автобалы tfm.exec.setPlayerScore("Dobrjik", "2000") local admins = {"Dobrjik"} local shop={ {name="Умереть",price=0,effect=function(name) tfm.exec.killPlayer(name) end, forAdmin=false}, {name="Получить сыр",price=5,effect=function(name) tfm.exec.giveCheese(name) end, forAdmin=false}, {name="Стать шаманом",price=10,effect=function(name) tfm.exec.setShaman(name) end, forAdmin=false}, {name="Получить мип",price=3,effect=function(name) tfm.exec.giveMeep(name) end, forAdmin=false}, {name="Стать вампиром",price=6,effect=function(name) tfm.exec.setVampirePlayer(name) end, forAdmin=false}, {name="Возрадиться",price=6,effect=function(name) tfm.exec.respawnPlayer(name) end, forAdmin=false}, {name="Следующая карта",price=500,effect=startGame, forAdmin=true} } function count(t, f) local c = 0 for k,v in pairs(t) do if f == nil or (type(f) == "function" and f(v)) then c = c + 1 end end return c end function table.indexOf(t, value) for i, v in ipairs(t) do if v==value then return i end end return false end function startGame() local maps = {0,1,2,3,4,5,6,7,8,9,10} tfm.exec.newGame(maps[math.random(#maps)]) tfm.exec.setUIMapName("Golden Cheese | Золотой сыр") end function eventLoop(currentTime,remaining) if remaining<=0 then startGame() end end function eventPlayerWon(name) --когда игрок зашел в нору tfm.exec.setPlayerScore(name,3,true) -- добавить 3 очка local aliveMouse = count(tfm.get.room.playerList, function(v) return not v.isDead end) if aliveMouse == 0 then startGame() end end function eventPlayerDied(name) --когда игрок умер tfm.exec.setPlayerScore(name,-1,true) -- отнять 1 очко local aliveMouse = count(tfm.get.room.playerList, function(v) return not v.isDead end) if aliveMouse == 0 then startGame() end end function eventNewGame() --когда началась новая карта for k,v in pairs(tfm.get.room.playerList) do --в цикле проходимся по всем мышам if v.isShaman then -- если мышь - шаман tfm.exec.setPlayerScore(k,1,true) -- добавить 1 очко end end -- конец цикла end function eventChatCommand(name,command) if command=="shop" then local str="" for id,item in pairs(shop) do if (item.forAdmin and table.indexOf(admins, name)) or not item.forAdmin then str=str.."<a href='event:buy "..id.."'>["..item.price.."] "..item.name.."</a><br />" end end ui.addTextArea(1, str, name, 300, 100, 200, 200, nil, nil, 1, true) ui.addTextArea(2, "<b><a href='event:exit'>X</a></b>", name, 485, 100, nil, nil, nil, nil, 0, true) end end function eventTextAreaCallback(id,name,callback) local arg={} for args in callback:gmatch("[^%s]+") do table.insert(arg,args:lower()) end local id=tonumber(arg[2]) if arg[1]=="buy" and id then if shop[id] and tfm.get.room.playerList[name].score>=shop[id].price and ((shop[id].forAdmin and table.indexOf(admins, name)) or not shop[id].forAdmin) then if shop[id].effect then shop[id].effect(name) end --Действие при покупке. tfm.exec.setPlayerScore(name,-shop[id].price,true) print(name.." purchased "..shop[id].name) end elseif arg[1]=="exit" then ui.removeTextArea(1, name) ui.removeTextArea(2, name) end end startGame() поправил твой код, если будут вопросы задавай |
0 | ||
Smgxxx a dit : Спасибо, буду знать. UPD: У меня почему-то не работает команда на следующую карту, в чем дело? Dernière modification le 1436028840000 |
![]() ![]() « Citoyen » 1436078280000
| 0 | ||
Как всегда в последний момент меняю код и не проверяю -_- tfm.exec.disableAutoNewGame(true) tfm.exec.disableAutoScore(true)-- отключить автобалы tfm.exec.setPlayerScore("Dobrjik", "2000") local admins = {"Dobrjik"} local shop={ {name="Умереть",price=0,effect=function(name) tfm.exec.killPlayer(name) end, forAdmin=false}, {name="Получить сыр",price=5,effect=function(name) tfm.exec.giveCheese(name) end, forAdmin=false}, {name="Стать шаманом",price=10,effect=function(name) tfm.exec.setShaman(name) end, forAdmin=false}, {name="Получить мип",price=3,effect=function(name) tfm.exec.giveMeep(name) end, forAdmin=false}, {name="Стать вампиром",price=6,effect=function(name) tfm.exec.setVampirePlayer(name) end, forAdmin=false}, {name="Возрадиться",price=6,effect=function(name) tfm.exec.respawnPlayer(name) end, forAdmin=false}, {name="Следующая карта",price=500,effect=function(name) startGame() end, forAdmin=true} } function count(t, f) local c = 0 for k,v in pairs(t) do if f == nil or (type(f) == "function" and f(v)) then c = c + 1 end end return c end function table.indexOf(t, value) for i, v in ipairs(t) do if v==value then return i end end return false end function startGame() local maps = {0,1,2,3,4,5,6,7,8,9,10} tfm.exec.newGame(maps[math.random(#maps)]) tfm.exec.setUIMapName("Golden Cheese | Золотой сыр") end function eventLoop(currentTime,remaining) if remaining<=0 then startGame() end end function eventPlayerWon(name) --когда игрок зашел в нору tfm.exec.setPlayerScore(name,3,true) -- добавить 3 очка local aliveMouse = count(tfm.get.room.playerList, function(v) return not v.isDead end) if aliveMouse == 0 then startGame() end end function eventPlayerDied(name) --когда игрок умер tfm.exec.setPlayerScore(name,-1,true) -- отнять 1 очко local aliveMouse = count(tfm.get.room.playerList, function(v) return not v.isDead end) if aliveMouse == 0 then startGame() end end function eventNewGame() --когда началась новая карта for k,v in pairs(tfm.get.room.playerList) do --в цикле проходимся по всем мышам if v.isShaman then -- если мышь - шаман tfm.exec.setPlayerScore(k,1,true) -- добавить 1 очко end end -- конец цикла end function eventChatCommand(name,command) if command=="shop" then local str="" for id,item in pairs(shop) do if (item.forAdmin and table.indexOf(admins, name)) or not item.forAdmin then str=str.."<a href='event:buy "..id.."'>["..item.price.."] "..item.name.."</a><br />" end end ui.addTextArea(1, str, name, 300, 100, 200, 200, nil, nil, 1, true) ui.addTextArea(2, "<b><a href='event:exit'>X</a></b>", name, 485, 100, nil, nil, nil, nil, 0, true) end end function eventTextAreaCallback(id,name,callback) local arg={} for args in callback:gmatch("[^%s]+") do table.insert(arg,args:lower()) end local id=tonumber(arg[2]) if arg[1]=="buy" and id then if shop[id] and tfm.get.room.playerList[name].score>=shop[id].price and ((shop[id].forAdmin and table.indexOf(admins, name)) or not shop[id].forAdmin) then if shop[id].effect then shop[id].effect(name) end --Действие при покупке. tfm.exec.setPlayerScore(name,-shop[id].price,true) print(name.." purchased "..shop[id].name) end elseif arg[1]=="exit" then ui.removeTextArea(1, name) ui.removeTextArea(2, name) end end startGame() |
0 | ||
у меня есть вопрос, а как пользоваться скриптами? Dernière modification le 1436782260000 |
![]() ![]() « Citoyen » 1436785500000
| 0 | ||
1) и снова я. 2) в определенном x и y, которые можно указать самому, появляется табличка (прямоугольник, квадрат, прозрачная, не прозрачная - не важно), на которую определенный игрок, нажав, может писать что угодно, при этом табличка видна всем, и никто не сможет на нее повлиять/чудесным образом удалить. Буду благодарна. |
![]() ![]() « Consul » 1436799960000
| 0 | ||
a dit : А кто её может изменять? Первый кто кликнет? |
0 | ||
Smgxxx a dit : теперь работает, а кстати, можно ли еще как-то запихнуть функцию полета или других больших модулей? я пытался, никак не выходило |
![]() ![]() « Citoyen » 1436850120000
| 0 | ||
hfib a dit : Копируешь нужный скрипт, в комнате племени в чат вводишь /lua, в открывшееся окошко вставляешь код, и нажимаешь кнопку выполнить Dobrjik a dit : Да можно, скинь как пытался, посмотрим, поможем. |
0 | ||
Smgxxx a dit : Пытался ставить скрипт на полет, вылазила ошибка. Код и ошибка в спойлере. Скорее всего это элементарная ошибка, просто раньше у меня был магазин в текстовом виде и запихнуть туда большие команды было легче чем в такой магазин. • [19:13] # tfm.exec.disableAutoNewGame(true) tfm.exec.disableAutoScore(true) -- отключить автобалы local admins = {"Dobrjik"} local shop={ {name="Умереть",price=0,effect=function(name) tfm.exec.killPlayer(name) end, forAdmin=false}, {name="Возродиться",price=6,effect=function(name) tfm.exec.respawnPlayer(name) end, forAdmin=false}, {name="Получить сыр",price=5,effect=function(name) tfm.exec.giveCheese(name) end, forAdmin=false}, {name="Получить мип",price=3,effect=function(name) tfm.exec.giveMeep(name) end, forAdmin=false}, {name="Стать шаманом",price=10,effect=function(name) tfm.exec.setShaman(name) end, forAdmin=false}, {name="Стать вампиром",price=6,effect=function(name) tfm.exec.setVampirePlayer(name) end, forAdmin=false}, {name="Переключить карту",price=0,effect=function(name) startGame() end, forAdmin=true}, {name="2 минуты до конца карты",price=0,effect=function(name) tfm.exec.setGameTime("121") end, forAdmin=true}, {name="Полет",price=0,effect=function(name) function eventNewPlayer(name) tfm.exec.bindKeyboard(name,32,true,true) end for name,player in pairs(tfm.get.room.playerList) do eventNewPlayer(name) end, forAdmin=true}, function eventKeyboard(name,key,down,x,y) if key==32 then tfm.exec.movePlayer(name,0,0,true,0,-50,false) end end end, forAdmin=true} } function count(t, f) local c = 0 for k,v in pairs(t) do if f == nil or (type(f) == "function" and f(v)) then c = c + 1 end end return c end function table.indexOf(t, value) for i, v in ipairs(t) do if v==value then return i end end return false end function startGame() local maps = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70} tfm.exec.newGame(maps[math.random(#maps)]) tfm.exec.setUIMapName("<J>[BETA] <VP>Golden Cheese") tfm.exec.setPlayerScore("Dobrjik", "10000") tfm.exec.setNameColor("Dobrjik", 0xEB1D51) end function eventPlayerLeft(playerName) print("<VP>"..playerName.." <R>покинул комнату.") end function eventNewPlayer(playerName) print("<VP>"..playerName.." <J>зашел в комнату.") end function eventLoop(currentTime,remaining) if remaining<=0 then startGame() end end function eventPlayerWon(name) -- когда игрок зашел в нору tfm.exec.setPlayerScore(name,3,true) -- добавить 3 очка print("<VP>"..name.."<J> получил 3 очка.") local aliveMouse = count(tfm.get.room.playerList, function(v) return not v.isDead end) if aliveMouse == 0 then startGame() end end function eventPlayerDied(name) -- когда игрок умер tfm.exec.setPlayerScore(name,-1,true) -- отнять 1 очко print("<VP>"..name.."<R> потерял 1 очко.") local aliveMouse = count(tfm.get.room.playerList, function(v) return not v.isDead end) if aliveMouse == 0 then startGame() end end function eventNewGame() -- когда началась новая карта for k,v in pairs(tfm.get.room.playerList) do -- в цикле проходимся по всем мышам if v.isShaman then -- если нашелся шаман tfm.exec.setPlayerScore(k,1,true) -- добавить 1 очко шаману end end -- конец цикла end function eventChatCommand(name,command) if command=="shop" then local str="" for id,item in pairs(shop) do if (item.forAdmin and table.indexOf(admins, name)) or not item.forAdmin then str=str.."<a href='event:buy "..id.."'>["..item.price.."] "..item.name.."</a><br />" end end ui.addTextArea(1, str, name, 300, 100, 200, 200, nil, nil, 1, true) ui.addTextArea(2, "<b><a href='event:exit'>X</a></b>", name, 485, 100, nil, nil, nil, nil, 0, true) end end function eventTextAreaCallback(id,name,callback) local arg={} for args in callback:gmatch("[^%s]+") do table.insert(arg,args:lower()) end local id=tonumber(arg[2]) if arg[1]=="buy" and id then if shop[id] and tfm.get.room.playerList[name].score>=shop[id].price and ((shop[id].forAdmin and table.indexOf(admins, name)) or not shop[id].forAdmin) then if shop[id].effect then shop[id].effect(name) end -- Действие при покупке. tfm.exec.setPlayerScore(name,-shop[id].price,true) end elseif arg[1]=="exit" then ui.removeTextArea(1, name) ui.removeTextArea(2, name) end end startGame() Dernière modification le 1436890740000 |
![]() ![]() « Consul » 1436903220000
| 0 | ||
a dit : здесь полный бред особенно тут a dit : function function? Переменная может быть равна какой то одной функции, но не может быть равна куску кода, где часть выполняется где-то внутри функции, а другая снаружи в цикле. |
0 | ||
Bushmeister a dit : >Скорее всего это элементарная ошибка, |
![]() ![]() « Citoyen » 1436960340000
| 0 | ||
Ну вообще то объявлять функции внутри функций можно, там ошибка в другом, нет закрывающего энда, но даже если все правильно написать то не будет работать. Я чуток код поменял. tfm.exec.disableAutoNewGame(true) tfm.exec.disableAutoScore(true) -- отключить автобалы function eventNewPlayer(name) tfm.exec.bindKeyboard(name,32,true,true) end for name,player in pairs(tfm.get.room.playerList) do eventNewPlayer(name) end local admins = {"Dobrjik"} local flyMode = false local shop={ {name="Умереть",price=0,effect=function(name) tfm.exec.killPlayer(name) end, forAdmin=false}, {name="Возродиться",price=6,effect=function(name) tfm.exec.respawnPlayer(name) end, forAdmin=false}, {name="Получить сыр",price=5,effect=function(name) tfm.exec.giveCheese(name) end, forAdmin=false}, {name="Получить мип",price=3,effect=function(name) tfm.exec.giveMeep(name) end, forAdmin=false}, {name="Стать шаманом",price=10,effect=function(name) tfm.exec.setShaman(name) end, forAdmin=false}, {name="Стать вампиром",price=6,effect=function(name) tfm.exec.setVampirePlayer(name) end, forAdmin=false}, {name="Переключить карту",price=0,effect=function(name) startGame() end, forAdmin=true}, {name="2 минуты до конца карты",price=0,effect=function(name) tfm.exec.setGameTime("121") end, forAdmin=true}, {name="Полет",price=0,effect=function(name) flyMode = not(flyMode) end, forAdmin=true} } function eventKeyboard(name,key,down,x,y) if key==32 and flyMode then tfm.exec.movePlayer(name,0,0,true,0,-50,false) end end function count(t, f) local c = 0 for k,v in pairs(t) do if f == nil or (type(f) == "function" and f(v)) then c = c + 1 end end return c end function table.indexOf(t, value) for i, v in ipairs(t) do if v==value then return i end end return false end function startGame() local maps = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70} tfm.exec.newGame(maps[math.random(#maps)]) tfm.exec.setUIMapName("<J>[BETA] <VP>Golden Cheese") tfm.exec.setPlayerScore("Dobrjik", "10000") tfm.exec.setNameColor("Dobrjik", 0xEB1D51) end function eventPlayerLeft(playerName) print("<VP>"..playerName.." <R>покинул комнату.") end function eventNewPlayer(playerName) print("<VP>"..playerName.." <J>зашел в комнату.") end function eventLoop(currentTime,remaining) if remaining<=0 then startGame() end end function eventPlayerWon(name) -- когда игрок зашел в нору tfm.exec.setPlayerScore(name,3,true) -- добавить 3 очка print("<VP>"..name.."<J> получил 3 очка.") local aliveMouse = count(tfm.get.room.playerList, function(v) return not v.isDead end) if aliveMouse == 0 then startGame() end end function eventPlayerDied(name) -- когда игрок умер tfm.exec.setPlayerScore(name,-1,true) -- отнять 1 очко print("<VP>"..name.."<R> потерял 1 очко.") local aliveMouse = count(tfm.get.room.playerList, function(v) return not v.isDead end) if aliveMouse == 0 then startGame() end end function eventNewGame() -- когда началась новая карта for k,v in pairs(tfm.get.room.playerList) do -- в цикле проходимся по всем мышам if v.isShaman then -- если нашелся шаман tfm.exec.setPlayerScore(k,1,true) -- добавить 1 очко шаману end end -- конец цикла end function eventChatCommand(name,command) if command=="shop" then local str="" for id,item in pairs(shop) do if (item.forAdmin and table.indexOf(admins, name)) or not item.forAdmin then str=str.."<a href='event:buy "..id.."'>["..item.price.."] "..item.name.."</a><br />" end end ui.addTextArea(1, str, name, 300, 100, 200, 200, nil, nil, 1, true) ui.addTextArea(2, "<b><a href='event:exit'>X</a></b>", name, 485, 100, nil, nil, nil, nil, 0, true) end end function eventTextAreaCallback(id,name,callback) local arg={} for args in callback:gmatch("[^%s]+") do table.insert(arg,args:lower()) end local id=tonumber(arg[2]) if arg[1]=="buy" and id then if shop[id] and tfm.get.room.playerList[name].score>=shop[id].price and ((shop[id].forAdmin and table.indexOf(admins, name)) or not shop[id].forAdmin) then if shop[id].effect then shop[id].effect(name) end -- Действие при покупке. tfm.exec.setPlayerScore(name,-shop[id].price,true) end elseif arg[1]=="exit" then ui.removeTextArea(1, name) ui.removeTextArea(2, name) end end startGame() |
0 | ||
Smgxxx a dit : Работает, только проблема в том что ей может пользаваться любой человек который играет в комнате, не только я. |
![]() ![]() « Citoyen » 1437018120000
| 0 | ||
Dobrjik a dit : Ну у тебя в изначальном коде тоже для всех, поэтому думал надо так делать tfm.exec.disableAutoNewGame(true) tfm.exec.disableAutoScore(true) -- отключить автобалы local players = {} function eventNewPlayer(name) players[name] = {fly = false} tfm.exec.bindKeyboard(name,32,true,true) end for name,player in pairs(tfm.get.room.playerList) do eventNewPlayer(name) end local admins = {"Dobrjik"} local shop={ {name="Умереть",price=0,effect=function(name) tfm.exec.killPlayer(name) end, forAdmin=false}, {name="Возродиться",price=6,effect=function(name) tfm.exec.respawnPlayer(name) end, forAdmin=false}, {name="Получить сыр",price=5,effect=function(name) tfm.exec.giveCheese(name) end, forAdmin=false}, {name="Получить мип",price=3,effect=function(name) tfm.exec.giveMeep(name) end, forAdmin=false}, {name="Стать шаманом",price=10,effect=function(name) tfm.exec.setShaman(name) end, forAdmin=false}, {name="Стать вампиром",price=6,effect=function(name) tfm.exec.setVampirePlayer(name) end, forAdmin=false}, {name="Переключить карту",price=0,effect=function(name) startGame() end, forAdmin=true}, {name="2 минуты до конца карты",price=0,effect=function(name) tfm.exec.setGameTime("121") end, forAdmin=true}, {name="Полет",price=0,effect=function(name) players[name].fly = not(players[name].fly) end, forAdmin=true} } function eventKeyboard(name,key,down,x,y) if key==32 and players[name].fly then tfm.exec.movePlayer(name,0,0,true,0,-50,false) end end function count(t, f) local c = 0 for k,v in pairs(t) do if f == nil or (type(f) == "function" and f(v)) then c = c + 1 end end return c end function table.indexOf(t, value) for i, v in ipairs(t) do if v==value then return i end end return false end function startGame() local maps = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70} tfm.exec.newGame(maps[math.random(#maps)]) tfm.exec.setUIMapName("<J>[BETA] <VP>Golden Cheese") tfm.exec.setPlayerScore("Dobrjik", "10000") tfm.exec.setNameColor("Dobrjik", 0xEB1D51) end function eventPlayerLeft(playerName) print("<VP>"..playerName.." <R>покинул комнату.") end function eventNewPlayer(playerName) print("<VP>"..playerName.." <J>зашел в комнату.") end function eventLoop(currentTime,remaining) if remaining<=0 then startGame() end end function eventPlayerWon(name) -- когда игрок зашел в нору tfm.exec.setPlayerScore(name,3,true) -- добавить 3 очка print("<VP>"..name.."<J> получил 3 очка.") local aliveMouse = count(tfm.get.room.playerList, function(v) return not v.isDead end) if aliveMouse == 0 then startGame() end end function eventPlayerDied(name) -- когда игрок умер tfm.exec.setPlayerScore(name,-1,true) -- отнять 1 очко print("<VP>"..name.."<R> потерял 1 очко.") local aliveMouse = count(tfm.get.room.playerList, function(v) return not v.isDead end) if aliveMouse == 0 then startGame() end end function eventNewGame() -- когда началась новая карта for k,v in pairs(tfm.get.room.playerList) do -- в цикле проходимся по всем мышам if v.isShaman then -- если нашелся шаман tfm.exec.setPlayerScore(k,1,true) -- добавить 1 очко шаману end end -- конец цикла end function eventChatCommand(name,command) if command=="shop" then local str="" for id,item in pairs(shop) do if (item.forAdmin and table.indexOf(admins, name)) or not item.forAdmin then str=str.."<a href='event:buy "..id.."'>["..item.price.."] "..item.name.."</a><br />" end end ui.addTextArea(1, str, name, 300, 100, 200, 200, nil, nil, 1, true) ui.addTextArea(2, "<b><a href='event:exit'>X</a></b>", name, 485, 100, nil, nil, nil, nil, 0, true) end end function eventTextAreaCallback(id,name,callback) local arg={} for args in callback:gmatch("[^%s]+") do table.insert(arg,args:lower()) end local id=tonumber(arg[2]) if arg[1]=="buy" and id then if shop[id] and tfm.get.room.playerList[name].score>=shop[id].price and ((shop[id].forAdmin and table.indexOf(admins, name)) or not shop[id].forAdmin) then if shop[id].effect then shop[id].effect(name) end -- Действие при покупке. tfm.exec.setPlayerScore(name,-shop[id].price,true) end elseif arg[1]=="exit" then ui.removeTextArea(1, name) ui.removeTextArea(2, name) end end startGame() Dernière modification le 1437018180000 |