ID:1195459
 
(See the best response by The Motto.)
Code:
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<<"The tournament has already started"
return
if(tournament == 0)
usr<<"Tournament isn't open yet."
return
if(usr.tourny)
usr<<"You're already in the tournament!"
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!"
Leave_Tournament()
set category = "Channels"
set name = "Leave Tournament"
if(tournament == 0)
usr<<"Tournament isn't open yet."
return
if(usr.tourny == 0)
usr<<"You're not in the tournament!"
return
else
usr.loc = locate(154,165,1)
usr.tourny=0
Entries.Remove(usr)
world<<"<font color=white><b><u>[usr] left the tournament!"


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!
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 << "
The tournament entry has now ended."

world << "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<<"
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<<"You have been blessed with more Strength."
if("Defence")
M.defence_max+=1000000
M.defence = M.defence_max
M<<"You have been blessed with more Defence."
if("Ki")
M.ki_max+=1000000
M.ki = M.ki_max
M<<"You have been blessed with more Ki."
if("PowerLevel")
M.powerlevel_max+=1000000
M.powerlevel = M.powerlevel_max
M<<"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 << "
The World Tournament has begun! You have 2 minutes to enter.
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 << "
The tournament entry has now ended."

world << "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<<"
Not enough players, Tournament cancelled."

tournament=0
KILLTOURNY()
Tournament_AI()

proc
Tournament_AI()
started=1
if(Entries.len<1 && Winners.len<1)
world<<"
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<<"
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<<"
Tournament Announcer: Are you ready for battle?"

world<<"
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<<"
Tournament Announcer:
[A] V.S. [B]!"
world<<"
Tournament Announcer: You have 30 seconds to prepare yourselves!"

sleep(300)
world<<"
Tournament Announcer: 3!"

sleep(10)
world<<"
Tournament Announcer: 2!"

sleep(10)
world<<"
Tournament Announcer: 1!"

sleep(10)
if(!A||!B||A==B||A.z!=7||B.z!=7)
match=0
world<<"
Tournament Announcer: Match Cancelled..."

Tournament_AI()
return
world<<"
Tournament Announcer: FIGHT!"

sleep(1)
if(!A||!B||A==B||A.z!=7||B.z!=7)
match=0
world<<"
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<<"
Tournament News: The next round will now begin!"

Tournament_AI()


Problem description: When the tournament entry closes it gets cancelled even if 4-5 players have joined it..i dont know what i did wrong.

Gokussj22 wrote:
i dont know what i did wrong.

Are you sure you've done anything at all? This doesn't look like your source, otherwise you'd know what's the problem.
can u tell me the error??
Best response
your error come from this line
if(Entries.len>=1 && Winners.len<1)

The way you have it, its saying if Entries list is bigger or equal to 1 player then cancel the tournament, it should be less or equal to 1 player.
if(Entries.len<=1 && Winners.len<=1)

And The Winners.len was missing the = sign
thnks alot :)