ID:160459
 
Ive seen this done before (Naruto GOA newest version) where theres a limit on number of players the person is banned before they download the resources, I was wondering what the best way to do that would be. And I have been searching on the forums and everything ive found so far only works after they download resources.
world/IsBanned() procedure is what you're looking for.
In response to Andre-g1
ok i was looking at it and this is what ive done but it doesnt seem to work.
var
max_players=60
players=60
world/IsBanned(key,address)
if(players>=max_players)
return 0
else
return ..()

Right now i have the max and regular set to the same to see if it would boot me. Also i change the players variable like this
client
Del()
if(src.mob)
src.mob.SaveExit()
players-=1
..()
New()
players+=1
..()
In response to NightJumper88
world/IsBanned(key,address)
. = ..()
if(istype(., /list))
if(players >= max_players)
.["Login"] = 0
else
.["Login"] = 1


I never worked with world/IsBanned() but I think that might work. *shrug*
In response to NightJumper88
Make sure you thoroughly read the whole reference entry for new (to you) procs you're gonna use! It is essential. Look forth:

The DM Reference states:
<font size=1>Returns:
True value if user is banned from this world.
[...]
This procedure is called internally whenever a new user connects (before client/New() is called). If the result is true, access is denied</font>

What you need to do is return a true value to prevent the player from joining the game, not a false one! A false one allows the player to login. To disconnect the player, just return 1.

Oh, also, it isn't critical, but you should use the ++ and -- operators instead of += and -= to modify a variable by the value of 1. They're just a little faster and shorter to type. =P
In response to Kaioken
Ok i got the boot to work but i dont know how to output a message to the player saying the max number of players are on. here my code now
world/IsBanned(key,address)
if(players>=max_players)
return 1
else
return ..()
In response to NightJumper88
Read up on the world/IsBanned() and take a look at the desc parameter.
In response to Andre-g1
i have but im having trouble on how to set it up I tried to do it like they do the Login on the example but it comes up with an error
In response to NightJumper88
world/IsBanned(key,address)
if(players >= max_players)
return list("desc" = "Login failed due to server player limit reached.","Login" = 1)
else
return list("desc"="Login access granted.","Login"=0)


That should work <.<
In response to Andre-g1
I somewhat confused it too, but you're using the Login parameter wrong. It should only be used mainly to allow a banned player to login, and nothing else. Login=0 won't have any impact as far as I know; you're already returning a true value (a list reference), which signals the player should be disconnected, anyway.

Also, the Login parameter uses 1 to allow a (banned) connection, not 0, so your code is quite messed. >_> Basically it should be like this:
world/IsBanned() //don't need args >_>
if(players >= max_players)
return list("desc" = "Sorry, server is full.")
return ..() //do the default behavior (block pager-banned players) and act upon it
In response to Kaioken
Ha, sorry. I haven't worked with IsBanned() up until now, which I looked up to try and answer him.

Thanks for explaining some stuff that were 'clouding' my mind.
In response to Kaioken
Thanks ill try this when i get back home later, hopefully it will work