var/tournament = 0
var/match = 0
var/list/Entries = list()
var/started=0
var/list/Winners = list()
mob/var/tmp/tourny=0
mob/Tournament
verb
Enter_Tournament()
set category = "Channels"
set name = "Enter Tournament"
if(usr.dead)
usr<<"\red You are dead!"
return
if(usr.level<=500)
usr<<"You are not a combatant, train more!"
return
if(started)
usr<<"<font color=white>The tournament has already started</font></b></u>"
return
if(tournament == 0)
usr<<"<font color=white>Tournament isn't open yet."
return
if(usr.tourny)
usr<<"<font color=white><b><u>You're already in the tournament!</font></b></u>"
return
else
usr.loc=locate(rand(76,96),rand(69,74),7)
Entries.Add(usr)
usr.tourny=1
world<<"<font color=white><b><u>[usr] joined the tournament!</font></b></u>"
Leave_Tournament()
set category = "Channels"
set name = "Leave Tournament"
if(tournament == 0)
usr<<"<font color=white>Tournament isn't open yet."
return
if(usr.tourny == 0)
usr<<"<font color=white><b><u>You're not in the tournament!</font></b></u>"
return
else
usr.loc = locate(154,165,1)
usr.tourny=0
Entries.Remove(usr)
world<<"<font color=white><b><u>[usr] left the tournament!</font></b></u>"
mob/System/Admin/Verbs
LowGM/verb
Begin()
set category="Admin"
set name="Start Auto Tournament"
switch(alert("Are you sure you wish to start an automatic tournament?","Confirm","Yes","No"))
if("No")
return
if("Yes")
if(tournament)
usr<<"There's already a tournament going on!"
return
tournament=1
for(var/mob/M in world)
if(M.client)
M.verbs += typesof(/mob/Tournament/verb)
world << "<center><font size=3><font color = red><b><center>[usr] has started an automatic tournament, the prize is your choice!<br><font size = 1>To join please go to Channels tab and select Enter Tournament."
Stop_Tourny_Entance()
set category="Admin"
set name="Stop Auto Tournament"
if(tournament&&!started&&!match)
started=1
world << "<center><font size=3><font color = red><b><center>The tournament entry has now ended."
world << "<font size=1><font color = red><b>The following people are in the tournament"
for(var/mob/M in world)
if(M.tourny)
world << "[M]"
if(Entries.len<=1 && Winners.len<1)
started=0
world<<"<center><font size=3><font color=#5f9ea0>Not enough players, tournament cancelled."
tournament=0
KILLTOURNY()
else
Tournament_AI()
proc
Prize(var/mob/M in Winners)
world<<"Tournament News: [M] has won the world tournament and will recieve a prize of their choice"
started=0
var/prize
prize=input(M,"Congratulations, You Won! Please Select Your Prize")in list("Strength","Defence","Ki","PowerLevel")
switch(prize)
if("Strength")
M.strength_max+=1000000
M.strength = M.strength_max
M<<"<font color=#5f9ea0>You have been blessed with more Strength."
if("Defence")
M.defence_max+=1000000
M.defence = M.defence_max
M<<"<font color=#5f9ea0>You have been blessed with more Defence."
if("Ki")
M.ki_max+=1000000
M.ki = M.ki_max
M<<"<font color=#5f9ea0>You have been blessed with more Ki."
if("PowerLevel")
M.powerlevel_max+=1000000
M.powerlevel = M.powerlevel_max
M<<"<font color=#5f9ea0>You have been blessed with more Power."
M.loc = locate(154,165,1)
proc
KILLTOURNY()
for(var/mob/M in world)
M.verbs -= typesof(/mob/Tournament/verb)
if(M.tourny)
M.tourny = 0
Entries.Remove(M)
M.loc = locate(154,165,1)
tournament=0
started=0
proc
AutoStartTourney()
if(tournament == 1)
return
else
world << "<center><font size=3><font color = red><b><center>The World Tournament has begun! You have 2 minutes to enter.<br><font size = 1>To join please go to Channels tab and select Enter Tournament."
tournament = 1
for(var/mob/M in world)
M.verbs += new/mob/Tournament/verb/Enter_Tournament()
M.verbs += new/mob/Tournament/verb/Leave_Tournament()
for(var/mob/Q in Entries)
Entries.Remove(Q)
for(var/mob/S in Winners)
Winners.Remove(S)
spawn(1200) AutoStopTourney()
AutoStopTourney()
if(tournament == 1)
world << "<center><font size=3><font color = red><b><center>The tournament entry has now ended."
world << "<font size=1><font color = red><b>The following people are in the tournament"
for(var/mob/M in world)
if(M.tourny)
world << "[M]"
for(var/mob/M in world)
M.verbs -= new/mob/Tournament/verb/Enter_Tournament()
M.verbs -= new/mob/Tournament/verb/Leave_Tournament()
if(Entries.len>=1 && Winners.len<1)
started=0
world<<"<center><font size=3><font color=#5f9ea0>Not enough players, Tournament cancelled."
tournament=0
KILLTOURNY()
Tournament_AI()
proc
Tournament_AI()
started=1
if(Entries.len<1 && Winners.len<1)
world<<"<center><font size=3><font color=#5f9ea0>Tournament over, all contestants have left..."
for(var/mob/C in world)
if(C.client)
C.tourny=0
KILLTOURNY()
started=0
return
if(Entries.len<1 && Winners.len==1)
tournament=0
world<<"<center><font size=3><font color=#5f9ea0>Tournament over, winner is:"
for(var/mob/M in Winners)
world<<M
Prize(M)
Entries=list()
Winners=list()
for(var/mob/C in world)
if(C.client)
C.tourny=0
started=0
return
if(Entries.len < 2)
NextRound()
else
FixEntries()
if(match)
return
if(!Entries||Entries.len<2)
Tournament_AI()
return
world<<"<center><font size=3><font color=#5f9ea0>Tournament Announcer: Are you ready for battle?"
world<<"<center><font size=3><font color=#5f9ea0>Tournament Announcer: Next up is..."
sleep(15)
Matches()
FixEntries()
var/list/Cop=list()
for(var/mob/A in Entries)
var/good=1
if(A&&ismob(A)&&A.client&&A.z==5)
for(var/mob/B in Cop)
if(A==B)
good=0
if(good)
Cop+=A
else
Entries=Cop
Matches()
FixEntries()
if(!Entries||Entries.len<2)
Tournament_AI()
return
var/mob/A=Entries[1]
var/mob/B=Entries[2]
if(!A||!B||A==B||A.z!=7||B.z!=7)
Matches()
return
match=1
if(!(A && B))
match=0
Tournament_AI()
return
world<<"<center><font size=3><font color=#5f9ea0>Tournament Announcer: [A] V.S. [B]!"
world<<"<center><font size=3><font color=#5f9ea0>Tournament Announcer: You have 30 seconds to prepare yourselves!"
sleep(300)
world<<"<center><font size=3><font color=#5f9ea0>Tournament Announcer: 3!"
sleep(10)
world<<"<center><font size=3><font color=#5f9ea0>Tournament Announcer: 2!"
sleep(10)
world<<"<center><font size=3><font color=#5f9ea0>Tournament Announcer: 1!"
sleep(10)
if(!A||!B||A==B||A.z!=7||B.z!=7)
match=0
world<<"<center><font size=3><font color=#5f9ea0>Tournament Announcer: Match Cancelled..."
Tournament_AI()
return
world<<"<center><font size=3><font color=#5f9ea0>Tournament Announcer: FIGHT!"
sleep(1)
if(!A||!B||A==B||A.z!=7||B.z!=7)
match=0
world<<"<center><font size=3><font color=#5f9ea0>Tournament Announcer: Match Cancelled..."
Tournament_AI()
return
if(A)A.loc=locate(82,57,7)
if(B)B.loc=locate(90,57,7)
Fight(A,B)
FixEntries()
match=0
Tournament_AI()
proc
Fight(mob/A,mob/B)
while(1)
if(!B || B.z != 7 || B.dead)
if(!B)
world<<"<center><font size=3><font color=#5f9ea0>[A] has won his round because his opponent has left!"
else
world<<"<center><font size=3><font color=#5f9ea0>[A] has eliminated [B]!"
Entries.Remove(B)
B.tourny=0
Winners.Add(A)
Entries.Remove(A)
A.loc=locate(rand(76,96),rand(69,74),7)
return
if( !A || A.z != 7 ||A.dead)
if(!A)
world<<"<center><font size=3><font color=#5f9ea0>[B] has won his round because his opponent has left!"
else
world<<"<center><font size=3><font color=#5f9ea0>[B] has eliminated [A]!"
Entries.Remove(A)
A.tourny=0
Winners.Add(B)
Entries.Remove(B)
B.loc=locate(rand(76,96),rand(69,74),7)
return
else
sleep(1)
NextRound()
for(var/mob/M in Winners)
Entries.Add(M)
M.loc=locate(rand(76,96),rand(69,74),7)
sleep(10)
Winners.Remove(M)
if(Entries.len<2)
return
world<<"<center><font size=3><font color=#5f9ea0>Tournament News: The next round will now begin!"
Tournament_AI()
PROBLEM : the problem is that the tourney entry does not close and if i manually close it..it says "Not enought players. canceled"
I would suggest creating a datum to handle tournaments instead of having a bunch of variables, procs, and lists like that.
Also your HTML tags are completely wrong; some aren't closed and some are...
The proper format for closing HTML tags is
You seem to be highly inconsistent with how you're handling booleans (you're alternating between if(tournament) and if(tourmanent == 1)). Did you program this yourself or is it some awful code you lifted from a source?