Module imaginé par
Module conceived by
DeathWar", nil, 0, 30, 800, 150, 0x0)
reloadTeams()
tfm.exec.respawnPlayer(name)
end
table.foreach({0,1,2,3,32,76}, function(k,v) system.bindKeyboard(name, v, true, true) end)
end
function eventPlayerLeft(name)
if players[name] and players[name].team~=0 then
teams[players[name].team].listPl[name] = 0
if checkTeamActivity(players[name].team) then
if lobby then
reloadTeams(true)
else
local count = 0
for key, data in pairs(teams) do
if not data.hide then
count = count +1
end
end
if count<=1 then
end
end
end
end
end
function eventPlayerDied(name)
if lobby then tfm.exec.respawnPlayer(name)
elseif win and players[name].team~=0 then
if countPl().alive<=1 then
tfm.exec.setGameTime(5)
end
local team = leftTeam()
if team~=0 and teams[team] then
win = false
uwin = true
tfm.exec.setGameTime(5)
end
end
end
function eventKeyboard(name, key, down, x, y)
local data = tfm.get.room.playerList[name]
local pl = players[name]
if key==0 then
data.isFacingRight = false
pl.isFacingRight = false
end
if key==2 then
data.isFacingRight = true
pl.isFacingRight = true
end
if (key==3 or key==32) and pl.timestamp<=os.time() and (not data.isDead) and start then
local id = tfm.exec.addShamanObject(17, x+(pl.isFacingRight and pl.offset.x or -pl.offset.x), y+pl.offset.y, pl.isFacingRight and 90 or 270)
table.insert(todespawn, {time = os.time()+1000, id = id})
pl.timestamp = os.time() +1500
end
if key==76 and #teams>0 then
if not players[name].down then
players[name].down = true
local txt = " Scoreboard
V"..version, name, 50, 357, 697, nil, 0x0, 0x0, 0, true)
else
--77, 111, 100, 117, 108, 101, 32, 99, 114, 101, 97, 116, 101, 100, 32, 98, 121, 32, 65, 116, 104, 101, 115, 100, 114, 97, 107, 101
ui.removeBox(id_scoreboard, name)
players[name].down = false
end
end
end
function eventChatCommand(name, cmd)
players[name].afk_time = os.time()
local arg = {}
for w in cmd:gmatch("%S+") do
table.insert(arg, w)
end
if arg[1]=="lang" or arg[1]=="language" then
if (not arg[2]) or arg[2]=="" then
ui.addTextArea(idLang, " "..tostring(math.ceil((timer-os.time())/1000)), nil, 0, 300+t[i].x, 800+t[i].y, nil, 0x0, 0x0, 0, true)
end
ui.addTextArea(idTimer, " "..tostring(math.ceil((timer-os.time())/1000)), nil, 0, 300, 800, nil, 0x0, 0x0, 0, true)
end
if t2<0 and uwin and currentMap~="@0" and (not lobby) then
local team, pl = leftTeam(), {}
for k,v in roomPl() do
if not v.isDead then
if teams[team] then
tfm.exec.giveCheese(k)
tfm.exec.playerVictory(k)
end
if nextRecord then
if teams[team] then players[k].points = players[k].points +1 end
players[k].survies = players[k].survies +1
end
table.insert(pl, k)
end
end
if nextRecord then
if teams[team] then
teams[team].victory = teams[team].victory +1
if teams[team].victory>=limite then
nextMap = "end"
end
end
table.insert(record, {team=team, pl=pl})
end
nextRecord = true
lastRecord = true
if teams[team] and teams[team].victory>=limite then
nextMap = "end"
end
newMap()
end
if pause.p then
if pause.t2 then
if pause.t2<=os.time() then
pause.p = false
joinQuit = true
for i=idTeam, idTeam+100 do ui.removeTextArea(i) end
newMap()
end
elseif pause.t1<=os.time() then
ui.removeTextArea(idPause)
nextMap = "pause"
end
end
if fireworks then
local tbl = {1,4,9}
for i=1, (math.random(1,5)==1 and 2 or 1) do
firework(tbl[math.random(#tbl)], math.random(100, 700), math.random(100, 400))
end
end
if setup then
for pl, data in pairs(players) do
if data.chef and data.afk_time<=os.time()-30000 and not teams[data.team].done then
eventTextAreaCallback(1, pl, format("quit$%d", data.team))
end
end
end
end
function eventNewGame()
lobby = false
tfm.exec.disableAfkDeath(tfm.get.room.currentMap=="@0")
if tfm.get.room.currentMap=="@0" then
timer = false
lobby = true
ui.setMapName(" DeathWar", nil, 0, 30, 800, 150, 0x0)
-- font: Wide Latin, Algerian, Bauhaus 93, Castellar, Goudy Stout
-- font: ui.addTextArea(1, "DeathWar\nDeathWar\nDeathWar\nDeathWar\nDeathWar\n\n\n\n+", nil, 5, 155, 790, 237, nil, nil, 0.5)
end
function reloadTeams(tp)
local sep = setup and (#teams+1==6 and 5 or #teams+1) or #teams
table.foreach(teams, function(k,v) if v.hide then sep = sep -1 end end)
table.sort(teams,
function(a, b)
if a.hide and not b.hide then
return false
end
return true
end
)
for k,v in pairs(teams) do
v.id = k
if v.hide then
for i=idTeam+k*10+1,idTeam+k*10+4 do
tfm.exec.removePhysicObject(i)
ui.removeTextArea(i)
end
else
v.spawn = (400*(2*(k-1)+1)/sep)
tfm.exec.addPhysicObject(idTeam+k*10+1, (k-1)*(800/sep)+5, 275, {type=12, width=10, height=250, color=v.color})
tfm.exec.addPhysicObject(idTeam+k*10+2, k*(800/sep)-5, 275, {type=12, width=10, height=250, color=v.color})
tfm.exec.addPhysicObject(idTeam+k*10+3, v.spawn, 175, {type=12, width=800/sep, height=50, color=v.color})
tfm.exec.addPhysicObject(idTeam+k*10+4, v.spawn, 395, {type=12, width=800/sep, height=10, color=v.color, friction=0.3})
ui.addTextArea(idTeam+k*10+1, format(" %s",#v.name>15 and 15 or 25, v.name), nil, (k-1)*(800/sep)+5, 150, 800/sep-10, nil, 0x0, 0x0, 0)
if joinQuit then
if v.done then
for pl in roomPl() do
ui.addTextArea(idTeam+k*10+2, " "..translate("team", pl).done, pl, (k-1)*(800/sep)+5, 350, 800/sep-10, nil, 0x0, 0x0, 0)
end
else
for pl in roomPl() do
if players[pl].team==k then
ui.addTextArea(idTeam+k*10+2, format(" "..translate("team", pl).join, k), pl, (k-1)*(800/sep)+5, 350, 800/sep-10, nil, 0x0, 0x0, 0)
end
end
end
end
end
for pl,ishere in pairs(v.listPl) do
if tp then
tfm.exec.movePlayer(pl, v.spawn, 350)
end
tfm.exec.setNameColor(pl, v.color)
players[pl].team = k
end
end
if #teams~=5 and joinQuit then
ui.addTextArea(idTeam, " \n\n\n+", nil, 800-800/sep, 155, 800/sep, 237, nil, nil, 0.5)
else
ui.removeTextArea(idTeam)
end
end
function newMap()
joinQuit, fireworks, setup = false, false, false
if nextMap=="normal" then
local temp_map = ""
repeat
temp_map = maps[math.random(#maps)]
until temp_map~=currentMap
currentMap = temp_map
tfm.exec.newGame(temp_map)
elseif nextMap=="pause" then
tfm.exec.newGame(lobby_map)
nextMap = "normal"
pause.t2 = os.time() +300000
pause.t1 = false
for k,v in pairs(teams) do v.done = false end
after(1, function() reloadTeams(true) end)
elseif nextMap=="end" then
tfm.exec.newGame(lobby_map)
nextMap = "normal"
after(1, function() reloadTeams(true);win_() end)
end
end
function roomPl() return next, tfm.get.room.playerList, nil end
function countPl()
local all, alive, dead = 0, 0, 0
for k,v in roomPl() do
all = all +1
if v.isDead then
dead = dead +1
else
alive = alive +1
end
end
return {
all = all,
alive = alive,
dead = dead
}
end
function capitalize(str) return str:sub(0,1):upper()..str:sub(2):lower() end
function wHtml(str)
if type(str)=="string" then
return str:gsub("<[^>]+",""):gsub(">","") -- Supprime toutes la balises HTML
end
end
function leftTeam()
local team = 0
for k,v in roomPl() do
if not v.isDead then
if team==0 then team = players[k].team end
if team~=players[k].team then return 0 end
end
end
return team
end
function help(name, page)
if page==0 then
ui.addTextPopup(idHelp, format(translate("help_txt", name), version), name, 225, 58, 350, 280)
elseif page==1 then
local HELP = translate("HELP", name)
local H = HELP.title
local f = H.txt
if H.bcolor then f = format("<%s>%s%s>", H.bcolor, f, H.bcolor) end
if H.b then f = format("%s", f) end;if H.u then f = format("%s", f) end;if H.i then f = format("%s", f) end
local txt = format(" %s %s >", name, x , y-3, width , 20, 0x0, 0x0, 0, true)
elseif page==2 then
local HELP = translate("HELP", name)
local H = HELP.title
local f = H.txt
if H.bcolor then f = format("<%s>%s%s>", H.bcolor, f, H.bcolor) end
if H.b then f = format("%s", f) end;if H.u then f = format("%s", f) end;if H.i then f = format("%s", f) end
local txt = format(" %s %s