ID:139140
 
Code:
mob
Login()
src.LoadStats()
src << "Welcome to KatChat - The official Chat Room of SadKat Gaming."
src << "<a href = 'http://skgproductions.forumotion.co.uk/'>Click here to go to the Official SadKat Forums.</a>"
if(src.key == "Darkoro" || src.key == "King_Artos3" || src.key == "SadKat_Gaming" || src.key == "SolarNews" || src.key == "Katona" || src.key == "Licht44" || src.key == "Raimo" || src.key == "Risecurve")
src.staff = 1
winset(src, "Admin", "is-disabled=false")
world << "\[[time2text(world.timeofday, "hh:mm")]\] <b>{Dev}</b> [src] has entered the chat room."
else
world << "\[[time2text(world.timeofday, "hh:mm")]\] [src] has entered the chat room."
..()


Problem description:
It gives me both the Dev and non-Dev message when I login, or Darkoro logs in:
Welcome to KatChat - The official Chat Room of SadKat Gaming.
Click here to go to the Official SadKat Forums.
[17:29] {Dev} Raimo has entered the chat room.
[17:29] Raimo has entered the chat room.

As far as I can see, I'm not doing anything wrong here.
I also tried:
if(!src.staff)
instead of the else clause, but that didn't work out either.
First off, I suggest using a list instead of checking at runtime.

var/list/admins = list("Albro1", "Raimo")

//blabla
if(key in admins)
//do admin stuff
else
//do normal stuff
In response to Albro1 (#1)
Well, I have this now;
mob
Login()
src.LoadStats()
src << "Welcome to KatChat - The official Chat Room of SadKat Gaming."
src << "<a href = 'http://skgproductions.forumotion.co.uk/'>Click here to go to the Official SadKat Forums.</a>"
if(src.key in Devs)
src.staff = 1
winset(src, "Admin", "is-disabled=false")
world << "\[[time2text(world.timeofday, "hh:mm")]\] <b>{Dev}</b> [src] has entered the chat room."
else
world << "\[[time2text(world.timeofday, "hh:mm")]\] [src] has entered the chat room."
..()


And it still gives this;
[18:00] {Dev} Sparta Matthews  has entered the chat room.
[18:00] King_Artos3 has entered the chat room.

Sparta Matthews is normally in HTML and is the name of the person, King_Artos3 is his key.
In response to Raimo (#2)
I used this and ran it, and it worked just fine:
var/list/Devs = list("Albro1")

mob
Login()
//src.LoadStats()
src << "Welcome to KatChat - The official Chat Room of SadKat Gaming."
src << "<a href = 'http://skgproductions.forumotion.co.uk/'>Click here to go to the Official SadKat Forums.</a>"
if(src.key in Devs)
world << "\[[time2text(world.timeofday, "hh:mm")]\] <b>{Dev}</b> [src] has entered the chat room."
else
world << "\[[time2text(world.timeofday, "hh:mm")]\] [src] has entered the chat room."
..()
In response to Albro1 (#3)
It may work for you if you try using the ? operator.

world<<"\[[time2text(world.timeofday, "hh:mm")]\] [staff ? "<b>{Dev}</b>" : ""] [src] has entered the chat room."


In case you don't know, the ? operator works as follows:

param_to_check ? if_param_true : if_param_false

If you don't understand that, use F1.
In response to Albro1 (#4)
I understand that, but it gives me now this double message;
[18:20] {Dev} Jack the Ripper has entered the chat room.
[18:20] {Dev} Jack the Ripper has entered the chat room.
In response to Raimo (#5)
Well then, are you changing mobs at all?
When you change a client's mob, that mob's Login() is called.
It is either that or you have 2 Login() codes somewhere.
In response to Albro1 (#6)
I'm not changing them nor do I have two Login() codes. =O
In response to Raimo (#7)
Then I have no idea of the problem. Maybe try doing the login announcing in client/New() instead?
In response to Albro1 (#8)
mob
Login()
//src.LoadStats()
src << "Welcome to KatChat - The official Chat Room of SadKat Gaming."
src << "<a href = 'http://skgproductions.forumotion.co.uk/'>Click here to go to the Official SadKat Forums.</a>"
if(getDevStatus())
//src.staff = 1
winset(src, "Admin", "is-disabled=false")
world << "\[[time2text(world.timeofday, "hh:mm")]\] [getDevStatus()] [src] has entered the chat room."
..()
proc/getDevStatus()
if(key in Devs) return "<b>{Dev}</b>"
else return ""


Try that ^

:)

Made a proc to get Dev status. If that doubles up your problem lies elsewhere, as it only has a single output action :)

Output tests:
Guest
Welcome to KatChat - The official Chat Room of SadKat Gaming.
Click here to go to the Official SadKat Forums.
[13:23] Guest-2943133698 has entered the chat room.


Dev
Welcome to KatChat - The official Chat Room of SadKat Gaming.
Click here to go to the Official SadKat Forums.
[13:24] KingCold999 has entered the chat room.
In response to KingCold999 (#9)
My reply with the ? operator does that exact same thing with less code.
In response to Albro1 (#10)
Oh... well.... then I have no clue. Sorry ^^;
In response to Albro1 (#8)
The problem is with the LoadStats. I am assuming it is a load protocol. Most of time these create a new mob, and reassign it. This would also explain the differnce of messages.

Please will you post that section of code for review?
In response to Pirion (#12)
Yeah, what he said. ^
When you load stuff into a mob it creates a new one.
In response to Pirion (#12)
Here you go guys;
mob
proc
SaveStats()
var/savefile/F = new("saves/[src.key].sav")
F["mob"] << src
LoadStats()
if(fexists("saves/[src.key].sav"))
var/savefile/F = new("saves/[src.key].sav")
F["mob"] >> src

mob
Write(var/savefile/F)
..()
F["name"] << src.name
F["Name Colour"] << src.NameColour
F["Staff"] << src.staff
F["muted"] << src.muted
F["status"] << src.status
F["TextColour"] << src.TextColour
Read(var/savefile/F)
..()
F["name"] >> src.name
F["Name Colour"] >> src.NameColour
F["Staff"] >> src.staff
F["muted"] >> src.muted
F["status"] >> src.status
F["TextColour"] >> src.TextColour
In response to Raimo (#14)
Yup. That is what is creating a new mob. Do a failsafe to get around it. Like...
mob/Login()
.=..()
var/loaded = FALSE
LoadStats()
loaded = TRUE
if(loaded)
//Do all that other stuff

Granted that isn't the best way around it, so I suggest you keep brainstorming. ^_^
In response to Albro1 (#15)
Or he could nip it in the bud before he even gets to the loading by sending out login information under client/New(), as was previously suggested.
In response to F0lak (#16)
Yeah, that was me. That would work, too, unless he wants to display the name of his loaded character.

On second thought Raimo, that was a terrible code suggestion from me. I just woke up, so forgive me.

Have your LoadStats set a var to 1 when it is loaded.
Make another proc, like displayMessage(), where you do the login message.
Then do:
displayMessage()
if(loaded)
//blabla

And call it after LoadStats()

Again, that is just if you want to display the loaded mob's name.
In response to Albro1 (#17)
Like I said, nip it in the bud with client/New()
client
New() // Called when a client connects to a world
..()
mob.LoadStats()
src << "Welcome to KatChat - The official Chat Room of SadKat Gaming."
src << "<a href = 'http://skgproductions.forumotion.co.uk/'>Click here to go to the Official SadKat Forums.</a>"
if(src.key in admins)
src.staff = 1
winset(src, "Admin", "is-disabled=false")
world << "\[[time2text(world.timeofday, "hh:mm")]\] <b>{Dev}</b> [src] has entered the chat room."
else
world << "\[[time2text(world.timeofday, "hh:mm")]\] [src] has entered the chat room."
In response to F0lak (#18)
Eh, yeah. Go with his reply, I seem to be too out-of-it to really give a good suggestion right now. Sorry.
Page: 1 2