In response to Android Data
world/var
maxplayers=1000
players=0

mob
Login()
players+=1
if(players > maxplayers)
usr << "The Server do not need more players now return tomorow"
del(M)
In response to Sasuke portela
This is wrong. First off, M is not defined. Second, there's nothing there to reduce the number of players. Third, this doesn't belong in Login(), it belongs in client/New(), like so:

var/maxplayers = 10
var/players = 0

client/New()
players++
if(players <= maxplayers)
//allow login
return ..()

client/Del()
players--
..()


Most importantly: this thread was over a week ago. Why'd you have to dredge it up?
In response to Garthor
Garthor wrote:
Third, this doesn't belong in Login(), it belongs in client/New()

You are correct here, although an even better alternative would be to use world/IsBanned(). That way you can handle a player connection even before the /client is created, not only before the mob is.

Also, by the nature of the ++ operator, it'd be a fuller use of it to use it directly in the if() check.
In response to Kaioken
Kaioken wrote:
Also, by the nature of the ++ operator, it'd be a fuller use of it to use it directly in the if() check.

I'd put it in there but it might not be clear as to what it's doing.
var/Max_Players=0
var/Players=0
mob/Login()
..()
if(world.host==key) Max_Players=input("Max players?") as num
if(Players>=Max_Players)
src<<"This server is maxed"
del(src)
else
Players+=1
mob/Logout()
Players-=1
..()


Whoa this post is old, I didn't realize
In response to Dragonn
No, that won't work. First, you're not doing anything with the input(). Second, you're still putting that in Login() where it doesn't belong. Third, all failed logins will reduce the Players variable by 1, so people could get in just by trying to log in twice. Fourth, you aren't calling the parent in Login() and so your mob isn't likely to get onto the map at any point.
In response to Garthor
Oh yea...Fixed

Also it wont decrease the player count by 1 because it plain out deletes them without calling logout()

And this post is old, I wonder why its still on the front page
In response to Dragonn
You didn't fix two of the things he said, first, that should go in Client/New and Client/Del, not Mob/Login and Mob/Logout. Second, a failed login will reduce the players variable by one without first raising it, so anyone could take advantage of this and bypass the limit. It would be better to have a for loop count all players online.
In response to Nickr5
Nickr5 wrote:
first, that should go in Client/New and Client/Del, not Mob/Login and Mob/Logout.

FIRST! we DID already go over this, though i tried implementing this into my games and it totaly screwed everything over, running world.Reboot() caused the player count to drop to like negative 10. When having it in login/logout works correctly for the most part

Second, a failed login will reduce the players variable by one without first raising it, so anyone could take advantage of this and bypass the limit.

wtf is a failed login?

It would be better to have a for loop count all players online.

waste of CPU
In response to Falacy
When having it in login/logout works correctly for the most part
When changing mobs, this will get called, which it shouldn't. Also, since it has nothing to do with the mob, it really shouldn't go here.

running world.Reboot() caused the player count to drop to like negative 10

A strange result, no idea why that would happen, but instead of finding a not-so-great workaround, it would be better to find out what's why it's happening and how to fix it properly.

wtf is a failed login?

I see them all the time, it's when they connect to the server but get disconnected before anything seems to be called (don't quote me on that or anything, not quite sure what causes it)
Usually when the player clicks exit in options and messages after "Connected" appears, but before the game comes up.
In response to Nickr5
Nickr5 wrote:
When changing mobs, this will get called, which it shouldn't. Also, since it has nothing to do with the mob, it really shouldn't go here.

I never change mobs in my games, i think its an idiotic thing to do, and even if you did do it youd have to have something to detect changing in the login code in the first place or youd get innacurate messages about logins.
EDIT: and how do you figure a player logging in or out shouldnt effect the player count?

I see them all the time, it's when they connect to the server but get disconnected before anything seems to be called

id assume this would then ONLY effect the client new/del code and therefore only enforces my decision to use login/logout
In response to Falacy
I never change mobs in my games, i think its an idiotic thing to do,
It's not an idiotic thing to do, what if you have different races, characters, whatever and want to change a player into one of them?

and even if you did do it youd have to have something to detect changing in the login code in the first place or youd get innacurate messages about logins.
Exactly why you should use Client/New and Client/Del for that...

EDIT: and how do you figure a player logging in or out shouldnt effect the player count?
If you're referring to what I said about your world/Reboot problems, then it shouldn't affect the player count because the variable that holds it would go back to 0 after a restart and Client/New would be called for each new player, so it doesn't make any sense that you would get -10.
Page: 1 2