ID:262162
 
    Login()


if(Locked)
if(Admin.Find(src.key))
return
usr << "<B><font size = 2><font color = red>Sorry, the world is locked"
del(src.client)

if(Players == MaxPlayers)
if(Admin.Find(src.key))
return
usr << "<B><font size = 2><font color = red>Sorry, the world is full"
del(src.client)


Ok, people can login and everythign they can see the title screen but once they click new char or load char THEN they get kicked. I want it so they cant even get in. How can I fix this I thought this would work but it isnt..Is it broken or?
New()


if(Locked)
if(Admin.Find(src.key))
return
usr << "<B><font size = 2><font color = red>Sorry, the world is locked"
del(src.client)

if(Players >= MaxPlayers)
if(Admin.Find(src.key))
return
usr << "<B><font size = 2><font color = red>Sorry, the world is full"
del(src.client)


_> Try that
In response to Hell Ramen
mob
new() ? right if so nope it is still doing it accept this time i got tons of runetimes
In response to Dranzer_Solo
Dranzer_Solo wrote:
mob
new() ? right if so nope it is still doing it accept this time i got tons of runetimes

Try client/New(). That REALLY should work.
In response to Lenox
ok where gettign somewhere now .... lol

client/New()
if(Locked)
if(Admin.Find(src.key))
return
usr << "<B><font size = 2><font color = red>Sorry, the world is locked"
del(src.client)

if(Players == MaxPlayers)
if(Admin.Find(src.key))
return
usr << "<B><font size = 2><font color = red>Sorry, the world is full"
del(src.client)
ok i did all this now im just getting a client underfind ed var
In response to Dranzer_Solo
Try..
var/client/client


maybe that'll work, just put that somewhere outside of the proc.
In response to Lenox
Darn it's still giveing me that same error
In response to Dranzer_Solo
Try mob.client?
In response to Hell Ramen
mob.client? so like

mob
client
//blabla

In response to Dranzer_Solo
You might have better luck calling a proc in New() that checks for that stuff instead of trying to do it all inside the proc.
In response to N1ghtW1ng
How would I do something like that?
In response to Dranzer_Solo
I THINK what he means is:

proc/Checker(client/C in world)
//insert all that you had above, and put src.C or C, I believe it automatically assumes C == src.C

Then call it like so:

client/New()
Checker(src)
In response to Lenox
yeh ok so something liek this

client/New()
Checker(src)
proc
Checker(client/C in world)
if(Locked)
if(Admin.Find(src.key))
return
usr << "<B><font size = 2><font color = red>Sorry, the world is locked"
del(src.C)

if(Players == MaxPlayers)
if(Admin.Find(src.key))
return
usr << "<B><font size = 2><font color = red>Sorry, the world is full"
del(src.C)

but now im still getting the same problem but instead of 2 undedifined vars its 4

Coding\Player Systems\Admin.dm:47:error:src.key:undefined var
Coding\Player Systems\Admin.dm:50:error:src.C:undefined var
Coding\Player Systems\Admin.dm:53:error:src.key:undefined var
Coding\Player Systems\Admin.dm:56:error:src.C:undefined var


In response to Lenox
Lenox wrote:
Try..
var/client/client

maybe that'll work, just put that somewhere outside of the proc.

Random suggestions don't benefit anyone. A var like that has nothing to do with this situation. You're trying to make a compile-time error go away by just adding stuff haphazardly without any regard to what it is or does. The correct approach is to actually fix the error, not to try to suppress it shotgun-style.

Lummox JR
In response to Dranzer_Solo
client/New()
mob.Checkthing()
var/
Locked
Players
MaxPlayers
mob
proc
Checkthing(mob/M)
if(Locked)
if(Admin.Find(M.key))
return // You might want to put Login() here
M << "<B><font size = 2><font color = red>Sorry, the world is locked"
del(M)

if(Players == MaxPlayers)
if(Admin.Find(M.key))
return // You might want to put Login() here
M << "<B><font size = 2><font color = red>Sorry, the world is full"
del(M)


This is untested, but should work.
In response to N1ghtW1ng
ok 2 things what did you mean by "you might want to put the Login() here


and it keeps me out now but i also get this runtime with it but it also keeps the admin out too

proc name: New (/client/New)
source file: Admin.dm,43
usr: null
src: Dranzer_Solo (/client)
call stack:
Dranzer_Solo (/client): New()
Connection closed.

Line 43 is mob.Checkthing()
In response to Dranzer_Solo
Should be CheckThing(mob) I believe.
In response to Dranzer_Solo
client/New()
..()
mob.Checkthing(mob)

var/
Locked
Players
MaxPlayers
mob
proc
Checkthing(mob/M)
if(Locked)
if(Admin.Find(M.key))
return // You might want to put Login() here
M << "<B><font size = 2><font color = red>Sorry, the world is locked"
del(M)

if(Players == MaxPlayers)
if(Admin.Find(M.key))
return // You might want to put Login() here
M << "<B><font size = 2><font color = red>Sorry, the world is full"
del(M)


No more runtimes as far as I can tell. Try that.
To answer your question, here's what you're doing wrong:

  • You're using src and usr interchangeably. Use one or the other. Since this is Login(), where src is always right and usr isn't necessarily so, use src.
  • The == test with Players==MaxPlayers is brittle; use >= instead, which is robust. In case the number of players was ever incorrectly set to more than MaxPlayers or to a fractional value, the test would still work.
  • if(key in Admin) is infinitely preferable to if(Admin.Find(key)).
  • Always always always close your HTML tags.
  • You could combine these two tests with a simple || in the if() statement, and use [Locked?"locked":"full"] to print whether the world is locked or full. The way this is done now is a waste of code.

    As to wanting this lockout to happen prior to an actual login, you need to do this in client/New(). Just remember in client/New() to call ..() during the proc. I'd do the test first, then call ..() if the login is allowed. Remember also you need to change src.client to src for this, since this will be a client proc instead of a mob proc.

    Lummox JR
In response to N1ghtW1ng
Yay thank you for all your help guys it works !!! it works prfectly
Page: 1 2