ID:149545
 
I want to make it so that only the host can use certain commands. I've tried a few things already, but nothing has worked for me. If anyone has done this before, or would care to lend a helping hand, please tell me how, or at least point me in the right direction.

Thanks in advance,
Ashing
this is very easy. here's an example:

var/global/host = 0

mob
Login()
..()
world<<"[usr] has logged in"
if(host == ) {
usr<<"You are the host."
host = "[usr]"
}
In response to The mothball
In response to The mothball
Thanks
In response to The mothball
The mothball wrote:
this is very easy. here's an example:

var/global/host = 0

mob
Login()
..()
world<<"[usr] has logged in"
if(host == ) {
usr<<"You are the host."
host = "[usr]"
}

Careful... just because someone is the first to log in doesn't necessarily mean that they're the host.

A better snippet would be the following:

mob
Login()
..()
if(client.address == "")
usr << "You are the host."
host = src
In response to Strange Kidd
Hey you might just want to go with a IP host login if that is possible if you have a cable modem or DSL this is possible but if you have 56k it might be harder...but anyhow by useing your IP address when you login to show your the host it will auto host you i guess i mean its just my theory i don't know for sure =)
In response to Spuzzum
Spuzzum wrote:
Careful... just because someone is the first to log in doesn't necessarily mean that they're the host.

A better snippet would be the following:

mob
Login()
..()
if(client.address == "")
usr << "You are the host."
host = src

This is one of the things I need to change in Incursion, actually. The assumption is made there that the first player to log in is in fact the host. (I figured it was safe, though, because I've never seen logins happen by any other sequence.)

Or is it that the assumption is valid in DreamSeeker, but not in DreamDaemon?

Lummox JR
In response to Lummox JR
Or is it that the assumption is valid in DreamSeeker, but not in DreamDaemon?

I'm pretty sure it's due to Dream Daemon, though Dantom has (I can't remember when) asserted that it is possible, however remotely, for someone besides the host to log in first when hosting through DS.
In response to Spuzzum
Spuzzum wrote:
Or is it that the assumption is valid in DreamSeeker, but not in DreamDaemon?

I'm pretty sure it's due to Dream Daemon, though Dantom has (I can't remember when) asserted that it is possible, however remotely, for someone besides the host to log in first when hosting through DS.

From 307b33 release notes:
Fixed: Many worlds give special "host" powers to the first player to log in, but rebooting the world was not guaranteed to log that person back in first. It now makes everyone else wait (up to 30 seconds) until the first player reconnects. It is probably not a good idea to ever give system-level powers on the basis of login order alone, but merely giving host status is fine. System-level powers could be granted when client.address is empty, indicating that the person is directly running the game in DS. For remote users, an appropriate mechanism is to check if their key is listed in world.GetConfig("admin"), which is how Dantom.HostServer works.

Just to be safe, I always do something like this:
var/client/host
client/New()
if (!src.address || (src.address == world.address) || (src.address == "127.0.0.1"))
if (!istype(host))
host = src