ID:178939
 
How do you make only a certian amount of characters join a game?
var/maxplayers = 4

mob/Login()
if(maxplayer >= 4)
src << "World is full!"
del(src)
else
..()
maxplayers++

mob/Logout()
if(maxplayers)
maxplayers--
del(src)
else
del(src)
Tazor07 wrote:
How do you make only a certian amount of characters join a game?

If you set up joining with a verb, you might do this:
var/list/players=list()   // global players list
var/list/standby=list() // players waiting to join
var/maxplayers=4

mob
verb/Join()
set src=usr
if(usr in players) return
standby-=usr
if(players.len>=maxplayers)
standby+=usr
world << "[usr.name] is [standby.len]\th in line for the next game."
else
players+=usr
world << "[usr.name] is the [players.len]\th player."

This is only one way to do it. When I started Incursion I had two separate lists like this, but I found that handling the cases where players log in or out, this can cause bugs to crop up if you're not careful in handling the lists.

Lummox JR