ID:145279
 
Code:
mob
proc
NameCheck(var/mob/M)
if(M.key in Admins)
if(!findtext(M.name,"(Admin)",1,7))
M.name = "(Admin)[M.name]"
if(M.key in MGMs && !(M.key in Creators))
if(!findtext(M.name,"(MGM)",1,5))
M.name = "(MGM)[M.name]"
else if(M.key in MGMs && M.key in Creators)
if(!findtext(M.name,"(Creator)",1,9))
M.name = "(Creator)[M.name]"


Problem description:

I put that in Stat() and ever since, all of the Admins in my game have been complaining that sometimes their name get's changed to:

(Admin)(Admin)(Admin)(Admin)(Admin)(Admin)(Admin)(Admin)(Admi n)(Admin)(Admin)(Admin)(Admin)(Admin)(Admin)(Admin)(Admin)(A dmin)(Admin)(Admin)(Admin)(Admin)(Admin)(Admin)(Admin)(Admin )(Admin)(Admin)(Admin)(Admin)(Admin)(Admin)(Admin)(Admin)(Admi n)(Admin)(Admin)(Admin)(Admin)(Admin)(Admin)(Admin)(Admin)(A dmin)(Admin)(Admin)[their name]
Euh. Stat = refreshes = calls that proc over and over.
Consider calling it only on Login() or after you've handled adding/removing administrative access. Calling it in Stat() may cause lag if more people venture in your game.

You should also use a better method to do this. I recommend making two variables, "prefix" and "rname", where "prefix" is set to "(Admin)" on the NameCheck and "rname" is the actual name of the player. Your NameCheck proc can then set the "name" variable to "[prefix] [rname]".

mob
var
prefix
rname
proc
NameCheck() //you don't need var/mob/M if src really is the only person using it
if(M.key in Creators)prefix="(Creator)"
else if(M.key in MGMs)prefix="(MGM)"
else if(M.key in Admins)prefix="(Admin)"
else prefix=null
if(rname)name="[prefix] [rname]"
else rname=name //note that this might go wrong if rname is accidentally set to null with the prefix. Consider setting rname instead of name in your character handling and calling this to set the name.


01000100011000010111010001100001
In response to Android Data
Thanks for the advice, but I just made a proc to add in the Admin/MGM/ect part when needed. Also...

Android Data wrote:
01000100011000010111010001100001

I don't read binary... Translate?
In response to KirbyRules
I think it means: Data. A guess from his name, since.. yea.
In response to Mechanios
His signature i think
In response to Mechanios
Mechanios wrote:
I think it means: Data. A guess from his name, since.. yea.

Actually, it does mean Data! I went on to an Ascii generator and I typed in "Data" and turned it to Binary, and this came up:

01000100011000010111010001100001

Compare that to what Android Data wrote:
01000100011000010111010001100001

Oh, and while you guys are helping me, I might as well post another problem I'm having...

mob/verb
Who()
set desc = "Shows the players online. Click a name to show their stats."
usr << "<b>Players online:"
for(var/mob/M in world)
if(M.client)
usr << " <a href=?Check\ref=M>[AdminCheck(M,0,1)][M.name]</a></b>"
mob/Topic(action,mob/M)
if(action == "Check")
src << browse("<body bgcolor=#F0F8FF><font color=\"black\"><hr>\
[M.name] [AdminCheck(M,0,1)]<br>\
<hr><br>\
Key:
[M.key]<br>\
Level:
[M.LVL]<br>\
HP:
[M.HP]/[M.MHP]<br>\
SP:
[M.SP]/[M.MSP]<br>\
AP:
[M.ATK]<br>\
DP:
[M.DEF]<br>\
PP:
[M.POW]<br>\
BP:
[M.BRR]<br>[M.AFK ? "Status = AFK<br>":""]\
Likes:
[M.like]<br>\
Dislikes:
[M.dislike]<br>\
Nickel:
[M.N]<br><hr>",\
"can_close=1;can_resize=1;can_minimize=0;border=3;\
window=\"
[M.name]\";size=350x400")


What it's supposed to do is show you a list of players, each of them having their status (Admin, MGM, Creator, or Normal Player) and name in a link, where when you click the link, a popup comes up and tells you their stats. It does the list of names and link part right, only instead of showing "(Creator)" behind me name, it shows "[0x600016c]", like this:
Players online:
<font color = blue>[0x600016c]KirbyRules</font>
(And when I click the link nothing happens.)
In response to KirbyRules
Well your whole code is messey and is one of the problems

and your topic isn't coded correctly

mob/verb
Who()
set desc = "Shows the players online. Click a name to show their stats."
usr << "<b>Players online:"
for(var/mob/M in world)
if(M.client)
usr << " <a href='?src=\ref[src];Player=[M.name];action=Check'>[AdminCheck(M,0,1)][M.name]</a></b>"
mob/Topic(href,href_list[])
switch(href_list["action"])
if("Check")
var/A = href_list["Player"]
var/html
for(var/mob/M in world)
if(M.name == A)
html += {"
<body bgcolor=#F0F8FF><font color=\"black\"><hr>
[M.name] [AdminCheck(M,0,1)]<br>
<hr><br>
Key:
[M.key]<br>
Level:
[M.LVL]<br>
HP:
[M.HP]/[M.MHP]<br>
SP:
[M.SP]/[M.MSP]<br>
AP:
[M.ATK]<br>
DP:
[M.DEF]<br>
PP:
[M.POW]<br>
BP:
[M.BRR]<br>[M.AFK ? "Status = AFK<br>":""]
Likes:
[M.like]<br>
Dislikes:
[M.dislike]<br>
Nickel:
[M.N]<br><hr>",
"}

src << browse(html,"window=\"[M.name]\";size=350x400;can_close=1;can_resize=1;can_minimize=0;border=3")


Something like should do
In response to KirbyRules
Are you sure it doesn't have anything to do with the Admincheck() proc? Post that so we can help out a bit more.
In response to Android Data
'prefix' is actually an inbuilt variable for all atoms - you don't need to declare a new one. Just FYI.
In response to Jp
Dat made meyes bleed ><

Try working with this
client
Topic(href,h[])
switch(h["action"])
if("showstat")
var/client/target=locate(h["target"])
if(target)
//the who thing here
verb
testWho()
for(var/client/c) src<<"<a href=?action=showstat&target=\ref[c]>[c]</a>"


I maybe able to help further if it looked more clear =o
In response to DivineO'peanut
DivineO'peanut wrote:
client
> Topic(href,h[])
> switch(h["action"])
> if("showstat")
> var/client/target=locate(h["target"])
> if(target)
> //the who thing here
> verb
> testWho()
> for(var/client/c) src<<"<a href=?action=showstat&target=\ref[c]>[c]</a>"


I worked that into the current code and now it works fine. Thanks!