ID:161446
 
How do i make so that when the host logs on it makes you ask what max players to logon like the limit of people can join.
mob/Login()
if(src.key==world.host)
spawn() PlayerLimit=input(src,"Input Max Players","Player Limit",PlayerLimit)as num
In response to Falacy
Well how do i make it so that ppl cant log in if the limit is full.
In response to SoloKid
var/PlayerCount=0
var/PlayerLimit=10

mob/Logout()
PlayerCount-=1

mob/Login()
if(PlayerCount>=PlayerLimit)
src<<"Server is Full"
del src;return
PlayerCount+=1

of course youll have to merge that with the previous code...
In response to Falacy
Wrong place to put that.

client/New()
if(players < limit)
players++
..()

client/Del()
players--
In response to Falacy
Thanks Fal.
In response to Garthor
HM, is that why my player count gets off sometimes! interesting theory
In response to Falacy
That isn't a theory in the smallest amount.
In response to Garthor
So whos right Garthor or Fal ?
var
PlayerCount=0
PlayerLimit=10

client/New()
if(PlayerCount>=PlayerLimit)
src<<"<font color=White><b>The server is currently occupied. Try again later.</b></font>"
del(src)
else
PlayerCount++

client/Del()
PlayerCount--


just trying to help, would this work? o.o
In response to Eternity Productions
Garthor is, put it in the client/Del and New and itll work more effeciently
In response to SoloKid
If you have to choose between Garthor and Falacy, choose Garthor every single time, without fail.
In response to Popisfizzy
lol fizzle just peruses the forums waiting to pounce on me. Though i think i have to give him this round!
In response to Popisfizzy
Popisfizzy wrote:
If you have to choose between Garthor and Falacy, choose Garthor every single time, without fail.

would my method work though ;o
In response to Eternity Productions
Eternity Productions wrote:
would my method work though ;o

It would not work. You fail to call ..() in client/New() or client/Del(). Failing to call the default behaviour for client/New() will result in a mob not being created for the client, thus logging the client off.
In response to Eternity Productions
Eternity Productions wrote:
would my method work though ;o

yours is pretty much what Garthor put <.<
though for some reason neither of you have it call the parent in client/Del o.O
In response to Unknown Person
Unknown Person wrote:
Eternity Productions wrote:
would my method work though ;o

It would not work. You fail to call ..() in client/New() or client/Del(). Failing to call the default behaviour for client/New() will result in a mob not being created for the client, thus logging the client off.
did that because i dont need people ripping D:
Use world/IsBanned() to determine if a player can join or not because of too many players being logged in.
In response to Popisfizzy
Can i ask one more thing ? So on status i would put something like this [PlayerCount]/[PlayerLimit]?
SoloKid wrote:
How do i make so that when the host logs on it makes you ask what max players to logon like the limit of people can join.

var/list/clients[0] //list of currently online players
client
New()
if(key != world.host && clients.len > playerlimit)
src << "<font color=\"white\"><b>This server has reached it's maximum amount of players. You can't join right now; please try again later.</b></font>"
return null
clients += src
world.update_status()
return ..()
Del()
if(src in clients)
clients -= src
world.update_status()
return ..()

world
New()
.=..()
update_status()
proc
update_status()
if(host) . += "[host]'s Server"
. += " ([clients.len] [playerlimit ? "out of [clients.len > playerlimit ? clients.len : playerlimit] ":]players online)"
status = .

//why I use the clients list in favor of an integer
admin/verb
kick(client/C in clients)
set category = "Admin"
del C
set_player_limit(var/limit as num)
set category = "Admin"
if(limit != round(limit)) return
limit = max(0, min(limit, 100))
if(limit == 100) limit = null
playerlimit = limit
world.update_status()
usr << "The new player limit is [playerlimit ? playerlimit : "unlimited"].\
Note that existing players will not be kicked, even if the limit is reached."


mob/Login()
.=..()
if(key == world.host)
verbs += typesof(/admin/verb)
src << "<b>You are the host.</b> Do not abuse your powers."
if(playerlimit == -1)
src << "The game is currently locked. To unlock it, set a player limit with the \"set player limit\" verb."


Exercise #1: Implement this snippet in your game, without blatantly copying and pasting it. Keep in mind that some procs such as client/New(), client/Del(), mob/Login() and world/New() should not be overridden at another point in the project, as it will cause confusion later on.

Exercise #2: Try to make a list of reserved players. This list should be editable by the host. Players on this list will receive immunity from the player limit, and may login even if the limit has been reached.

-- Data
Page: 1 2