ID:154892
 
How would i go about making a round based system that works like Cowed and Space Station 13?

For the ones unfamiliar with the concept: When the world starts, it begins a countdown from 60. Players can click join to join the game, and when the 60 seconds are up, if there are enough players, the game starts. If there aren't enough, the countdown restarts.

Player save files are saved throughout the whole round, and then deleted afterwards, so that they don't retain old variables etc. from the previous round.

I tried making it myself, but it was incredibly buggy. Anybody got any suggestions?
You wouldn't really need save files for round based games, just make sure it doesn't delete your mob upon logging out.

Also, small code example:

var/list/players = new/list() // list of every player

world
New()
world << "Round will start in 60 seconds!" // countdown
sleep(300)
world << "30 seconds until round starts!"
sleep(200)
world << "10 seconds until start!"
sleep(50)
world << "5 seconds!"
sleep(10)
world << "4!"
sleep(10)
world << "3!"
sleep(10)
world << "2!"
sleep(10)
world << "1!"
sleep(10)
if(players.len > 4) // 5 players required to start the round
for(var/mob/O in players)
O.loc = locate(something) // place every player somewhere
else
Reboot() // do it again

mob
Login()
players += src // adds you to players list when you log in

In response to Timelimit
Durr, that was simple. Thanks. I'm not really good at assigning mobs and such, you got any suggestions on how I would do it? The not-deleted-on-logout stuff.
In response to Shaoni
If I'm right, Logout() just leaves your mob where it is by default so if you log back in without the server restarting or something you should automatically connect back to your mob.

If you want the mob to go away when you log out and come back when you log back in you could do something like this:

mob
var/oldloc

Logout()
oldloc = loc
loc = null
Login()
if(oldloc)
loc = oldloc
else
loc = locate(something)
In response to Timelimit
Thanks, I'll try that. :p