ID:867274
 
(See the best response by Albro1.)
Code:
proc
AutoStopTourney()
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 < 2)
world<<"Not enough players for the tournament. Tournament is cancelled."
for(var/mob/M in world)
if(M.tourny)
M.loc=locate(140,57,1)
Winners.Remove(M)
Entries.Remove(M)
M.tourny=0
tournament=0
if(cycle==1)
spawn(36000) AutoStartTourney()
return
Tournament_AI()


Problem description:Ive recently encountered a problem that almost every proc in the code repeats itself while in the game. This proc above specificly, spams the text output with "The Following people are in the tournament:
[M]" like 50 times. the auto repop for when the world runs just repeats itself twice, and keeps doing it every 6 minutes.

I am at a loss here and can not figure out why this is happening.

Any suggestions would be much appreciated. Thanks in advance!

You may want to show us where this proc is being called.
proc
AutoStartTourney()
if(tournament == 1)
return
else
world << "<center><font size=3><font color = red><b><center>The World Tournament has begun! You have 1 minute 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(600)AutoStopTourney()
AutoStopTourney()
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 < 2)
world<<"Not enough players for the tournament. Tournament is cancelled."
for(var/mob/M in world)
if(M.tourny)
M.loc=locate(140,57,1)
Winners.Remove(M)
Entries.Remove(M)
M.tourny=0
tournament=0
if(cycle==1)
spawn(36000) AutoStartTourney()
return
Tournament_AI()


and this whole thing is called here

world
New()
..()
Host = ""
if(RP == 0)
spawn(300)AutoRepop()
RP = 1
if(cycle == 0)
cycle = 1
spawn(300)EventCycle()
if(db == 0)
spawn(300)world.dragonball_loader()
spawn(300)world.dragonball_loadern()
db = 1

cycle being here

proc/EventCycle()
world << "\red World Events have bee turned on!!"
spawn(300) AutoStartTourney()



The reason I add all those variables under New() is so that it wont repeat like it does. But its not supposed to repeat to start with.
Best response
You're calling a new AutoStopTourney() for every mob.
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(600)AutoStopTourney()


Just back that last line up a tab.

Also, your EventCycle() is pretty poorly named. It isn't a cycle at all. It just calls a proc that does a very choppy job of cycling.

for() loops search the world by default, so you don't really need for(var/mob/m in world), you just need for(var/mob/m).

As a final note, you may want to loop through every client and add those verbs to the client.mob. Your method now adds it to all mobs, regardless of whether or not they are even going to use any verbs.
oh wow. Even I should have known that... Such a simple mistake... But what do you have to say about the AutoRepop, Event Cycle, and Dragonball Loader repeating twice at startup?

The Event Cycle is there because Im planning on adding and coding other world events to the game instead of that simple AutoTournament. So that list will be expanded soon.

oh i see! thanks!

Umm, if you dont mind me asking, how exactly can you add those to the client.mob? Would it be just "client.mob.verbs += ...."? (I apologize, I have just begun to program for the first time in my whole life last month. This is me attempting at accomplishing something as practice).
In response to Chiwy8
Chiwy8 wrote:
oh wow. Even I should have known that... Such a simple mistake... But what do you have to say about the AutoRepop, Event Cycle, and Dragonball Loader repeating twice at startup?
I would have to see the code for AutoRepop() and the Dragonball things.

The Event Cycle is there because Im planning on adding and coding other world events to the game instead of that simple AutoTournament. So that list will be expanded soon.
You may want to turn it into a loop, making it an actual cycle. The name is just confusing. All you are doing in it is initializing events - you could be calling it each tick and checking if an event should initialize. This could provide more customization.

Umm, if you dont mind me asking, how exactly can you add those to the client.mob? Would it be just "client.mob.verbs += ...."? (I apologize, I have just begun to program for the first time in my whole life last month. This is me attempting at accomplishing something as practice).

Exactly.
client.mob.verbs


Also, I hope what you are trying to accomplish doesn't involve a DBZ rip. If it does, I strongly urge you to delete it right now. It will only produce bad habits for you. If you just happen to be making something related to DragonBall Z that isn't a ripped source, then don't worry about this paragraph.

Finally: Please vote up the best response to your question by clicking the "[X] Votes" box!
proc/AutoRepop()
world.Repop()
for(var/obj/Kamehameha/O in world)
O.loc = null
for(var/obj/Distructo_Disk/O2 in world)
O2.loc = null
for(var/obj/Fat_Wrap/O3 in world)
del(O3)
for(var/obj/Ki_Blast/O4 in world)
del(O4)
for(var/obj/Saibaman_Corpse/O5 in world)
del(O5)
for(var/obj/Demon_Ki_Blast/O6 in world)
del(O6)
for(var/obj/CH_Distructo_Disk/O7 in world)
del(O7)
for(var/obj/big_bang/O8 in world)
del(O8)
for(var/obj/burning_attack/OO in world)
del(OO)
for(var/obj/masenko/O10 in world)
del(O10)
for(var/obj/final_flash/O11 in world)
del(O11)
for(var/obj/x10_kame/O12 in world)
del(O12)
for(var/obj/Ghost/O13 in world)
O13.loc = null
for(var/obj/SKamehameha/O14 in world)
del(O14)
for(var/obj/ki/hell_flash/O15 in world)
O15.loc = null
for(var/obj/MB/O16 in world)
del(O16)
for(var/obj/death_beam/O17 in world)
del(O17)
for(var/obj/MB/O16 in world)
del(O16)

world<<"<font size=0><font color=green>World Repop."
RP = 1
spawn(3600)AutoRepop()


The Event Cycle is also an admin verb that I added so that we have the power to turn on and off the Events in the world. Thats why I added it.

cool thanks!

And no worries, I very much disagree with the idea of ripping or copying. I have a friend that runs a DBZ game that comes from Lost Saiyans. He allowed me to practice coding for the actualy game, so I handle all the updates and such. Im attempting to break out of the DBZ monotony and make it...semi DBZ with a lot of original stuff.
Don't use the source. It will only teach you bad habits that will cause you to either give up later when you try to kick them or kick yourself for meddling with it in the first place. I know from experience, trust me.

As for the repeating - I don't see it. I'll look at it again when it isn't 2:46 AM if someone hasn't answered it by then.
I wont, no worries! I've seen what that causes, and i really do not want to go there. Im looking at learning Java and C++ later on. Its just a personal hobby that I have for now.


alright! thanks!