ID:174855
 
You know when someone puts a game up for playing, how do you code it so that it shows the host's name and game version and whatever else you want? Like this:


Join [Version 22 - Host: Mr.X - Players: 254]
//then it shows the list of players down here as usual


-Dagolar

world.status = "Version 22 - Host: Mr.X - Players: 254"
In response to Jon88
Uh..That's not quite what I meant. I meant how do you get the name of the host on that list? If I put Mr.X, it will be Mr.X regardless. How do I get the host's actual name on there? Is it like: [host name] or something like that?
What about the number of players? [player num]? I do not know these things...

And what is the exact line of programming for this?
world
world.status = (stuff)

? Give me the whole breakdown, please...

-Dagolar
In response to Dagolar
var
host

mob/Login
if(host == null)
host = usr.key
..()

world
world.status = "[host] is hosting!"

Dodgy code but it works to an extent, just don't reboot the server ;)
Try this:
var
host=""
version="V.1.0"
players=0
mob
Login()
players++
if(!src.client.address)
host=src.name
world.status="[world.name] ([version]) Host - [host], Players - [players]"
..()
mob
Logout()
players--
del(src)
..()
In response to Goku72
Goku72 wrote:
host=src.name

No, no, no. Make the host var a reference to the host's client, like so:

var/client/host=null

host=src.client

Then if you need to find the host (to, for example, tell them something), just use the host var.

host << "This is a message to the host..."

If host just holds the host's NAME, then to find the host you have to do something semi-complicated with a for() loop. Much easier my way. =)