ID:145951
 
I made it so, when my key (Souloron) or my friend's key (Lord Dist) log into game, it worldsay something special... heres the code,
mob/Login()
if(usr!=null)
var/hostcheck=0
for(var/mob/M in world)
if(M.key)
hostcheck+=1
if(hostcheck==1)
world.status="Souloron -- Version Alpha 1.00 | Host: [usr]"
for(var/mob/M in world)
if(M.name==src.key)
if(M.key)
sleep(1)
else
del M
CheckBan(src)
var/random = rand(1,3)
if(random >= 1)
src.loc = locate(7,7,20)
if(random >= 2)
src.loc = locate(7,50,20)
if(random >= 3)
src.loc = locate(7,94,20)
if(usr.key in players)
usr.guildcheck()
usr.Update_Status()
usr.gmcheck()
usr.loc=locate(usr.lastx,usr.lasty,usr.lastz)
usr<<"<font color = red><B><CENTER>~Welcome to §ouloron~<BR><font color = white><BR>~~~~~Rules~~~~~</B></center><font color = blue><br>1.AFK/EZ Macroing/Training is NOT allowed. If you are caught doing that your character will be permanently deleted.<BR>2.Killing/Attacking players under level 5 is illegal.<BR>3.Be nice to people and GMs, and listen to all what GMs say.<BR>4.DO NOT rip from the game (Souloron).<BR>5.Execssive mass player killing is bannable offense. <BR>6.If you know about a bug/exploit and either abuse it or not report it, you can get banned.<BR><font color = yellow><B><CENTER>Enjoy playing §ouloron!</CENTER></b></font>"
usr.client.AutoSave()
usr.talk=1
if(src.key=="Souloron")
world<<"<B><Font color = yellow>The earth start shaking, and fire explode out of it as Souloron, the king of the world enter!</B></FONT>"
else
if(src.key=="Lord Dist")
world<<"<B><font color = yellow>The earth starts shaking, and fire explodes out of it as Lord Dist, the Prince of the world enters!</B></font>"
else
world<<"<B><font size = 1>System Message: <font color = red>[usr.name] has entered!</b>"

else
usr.verbs -= usr.verbs
players+=usr.key
world<<"<B><font size = 1>System Message: <font color = blue>[usr.name] has been connected!"
usr<<sound('enter.wav')


But instand of saying something special, it doesnt say anything... not even entered, but it does show me the rules... and my other bug is, I made HUD, that show ur hp / xp / mp, same as in my old game which worked fine but when I did it on this game, it says:

runtime error: Division by zero
proc name: Update Status (/mob/proc/Update_Status)
source file: HUD.dm,33
usr: Souloron (/mob)
src: Souloron (/mob)
call stack:
Souloron (/mob): Update Status()
Souloron (/mob): Login()
REMOVED.
Ew, just.. ew.

<Font color = yellow></font>
and other of its like needs to be
<font color=yellow></font>

You also have usr abuse, and I suspect there's something wrong with your meter algorithm which is why it's saying division by 0. Might help to show line 33 of HUD.dm.
In response to Artemio
Artemio wrote:
Ew, just.. ew.

<Font color = yellow></font>
and other of its like needs to be
<font color=yellow></font>

You also have usr abuse, and I suspect there's something wrong with your meter algorithm which is why it's saying division by 0. Might help to show line 33 of HUD.dm.
Ok made it font from Font, and here line 33 of HUD.dm:
        H.icon_state = num2text(round(usr.hp/usr.max_hp,0.1)*100)



and here is the whole HUD
//HUD
client
New()
..()
new/obj/hp(src)
new/obj/mp(src)
new/obj/xp(src)

obj
hp
layer = 200
icon = 'HP.dmi'
screen_loc = "1,1"
icon_state = "100"
New(client/C)
C.screen+=src
mp
layer = 200
icon = 'MP.dmi'
screen_loc = "13,1"
icon_state = "100"
New(client/C)
C.screen+=src
xp
layer = 200
icon = 'XP.dmi'
screen_loc = "7,1"
icon_state = "100"
New(client/C)
C.screen+=src
mob/proc/Update_Status()
for(var/obj/hp/H in usr.client.screen)
H.icon_state = num2text(round(usr.hp/usr.max_hp,0.1)*100)
for(var/obj/mp/M in usr.client.screen).
M.icon_state = num2text(round(usr.mp/usr.max_mp,0.1)*100)
for(var/obj/xp/X in usr.client.screen).
X.icon_state = num2text(round(usr.xp/usr.max_xp,0.1)*100)
spawn(2)
if(usr) Update_Status(usr)


BTW, I changed a bit code and now when I log on, it suppose say that thing and also make my gm 4... and it doesnt do that as well...
In response to Souloron
REMOVED
In response to Zmadpeter
Okay I fixed the HUD, but now I gotta fix the problem that dun worldsay what I want it to, and doesnt make my gm 4...
In response to Zmadpeter
Zmadpeter wrote:
Im sorry but im not allowed to help.

<_<

you need to put a check in to make sure that the current max HP value is not 0 before you try to / it.

It's perfectly valid to have a 0 in the numerator, its when you have a 0 in the denominator that you run into problems.

What was pointed out in the font tags was not to put spaces between attributes and their values (ie. 'color = yellow' should be 'color=yellow').

In your mob/Login() your using src and usr interchangably, src is the more correct of the two in this case.

The way you are checking to see who the host is also isn't foolproof, and its likely that at some point in time someone else will end up as host (while that person isn't actually the host). You should be checking for client.address being null, aswell as compairing it to world.address.

The reason its not giving you any of the special login messages or doing a GM check is because your not adding the persons key to the player list, your checking the list then adding them if their not (and since you haven't added them they won't be in it).
In response to Nick231
I did add em, players+=usr.key, and it does take me to last x/y/z and updatestatus work now as well... so that show im in the list... but it doesnt make my gm to 4 or worldsay what I want it 2...
In response to Souloron
Souloron wrote:
I did add em, players+=usr.key, and it does take me to last x/y/z and updatestatus work now as well... so that show im in the list... but it doesnt make my gm to 4 or worldsay what I want it 2...

Your adding usr.key to players after you have checked if they are in it or not, so they will never be in it. You need to check if they are in it, if they're not add them to it, then go on with the rest of the regular login stuff.

    if(!(src.key in players))
src.verbs -= src.verbs
players+=src.key
src<<sound('enter.wav')
src.guildcheck()
src.Update_Status()
src.gmcheck()
src.loc=locate(src.lastx,src.lasty,src.lastz)
src<<"<font color = red><B><CENTER>~Welcome to §ouloron~<BR><font color = white><BR>~~~~~Rules~~~~~</B></center><font color = blue><br>1.AFK/EZ Macroing/Training is NOT allowed. If you are caught doing that your character will be permanently deleted.<BR>2.Killing/Attacking players under level 5 is illegal.<BR>3.Be nice to people and GMs, and listen to all what GMs say.<BR>4.DO NOT rip from the game (Souloron).<BR>5.Execssive mass player killing is bannable offense. <BR>6.If you know about a bug/exploit and either abuse it or not report it, you can get banned.<BR><font color = yellow><B><CENTER>Enjoy playing §ouloron!</CENTER></b></font>"
src.client.AutoSave()
src.talk=1
if(src.key=="Souloron")
world<<"<B><Font color = yellow>The earth start shaking, and fire explode out of it as Souloron, the king of the world enter!</B></FONT>"
else if(src.key=="Lord Dist")
world<<"<B><font color = yellow>The earth starts shaking, and fire explodes out of it as Lord Dist, the Prince of the world enters!</B></font>"
else
world<<"<B><font size = 1>System Message: <font color = red>[src.name] has entered!</b>"


Another thing to note, rather than do 3 if checks for random you can use a switch() statement:

switch(rand(1,3))
if(1)
src.loc = locate(7,7,20)
if(2)
src.loc = locate(7,50,20)
if(3)
src.loc = locate(7,94,20)

In response to Nick231
Still dun worldsay that thing, and dun make my gm lvl 4...
mob/Login()
if(usr!=null)
var/hostcheck=0
for(var/mob/M in world)
if(M.key)
hostcheck+=1
if(hostcheck==1)
world.status="Souloron -- Version Alpha 1.00 | Host: [usr]"
for(var/mob/M in world)
if(M.name==src.key)
if(M.key)
sleep(1)
else
del M

CheckBan(src)
switch(rand(1,3))
if(1)
src.loc = locate(7,7,20)
if(2)
src.loc = locate(7,50,20)
if(3)
src.loc = locate(7,94,20)
if(!(src.key in players))
src.verbs -= src.verbs
world<<"<B><font size = 1>System Message: <font color = blue>[usr.name] has been connected!"
players+=src.key
src<<sound('enter.wav')
else
src.guildcheck()
src.Update_Status()
src.gmcheck()
src.loc=locate(src.lastx,src.lasty,src.lastz)
src<<"<font color = red><B><CENTER>~Welcome to §ouloron~<BR><font color = white><BR>~~~~~Rules~~~~~</B></center><font color = blue><br>1.AFK/EZ Macroing/Training is NOT allowed. If you are caught doing that your character will be permanently deleted.<BR>2.Killing/Attacking players under level 5 is illegal.<BR>3.Be nice to people and GMs, and listen to all what GMs say.<BR>4.DO NOT rip from the game (Souloron).<BR>5.Execssive mass player killing is bannable offense. <BR>6.If you know about a bug/exploit and either abuse it or not report it, you can get banned.<BR><font color = yellow><B><CENTER>Enjoy playing §ouloron!</CENTER></b></font>"
src.client.AutoSave()
src.talk=1
if(src.key=="Souloron")
world<<"<B><font color = yellow>The earth start shaking, and fire explode out of it as Souloron, the king of the world enter!</B></FONT>"
usr.gm=4
usr.gmcheck()
else
if(src.key=="Lord Dist")
world<<"<B><font color = yellow>The earth starts shaking, and fire explodes out of it as Lord Dist, the Prince of the world enters!</B></font>"
usr.gm=4
usr.gmcheck()
else
world<<"<B><font size = 1>System Message: <font color = red>[src.name] has entered!</b>"
In response to Souloron
My guess then would be AutoSave() never returns (this can be caused simply by having a while() loop running within it). spawn it off:

spawn()src.client.AutoSave()
In response to Nick231
Ahhhhhhhh yes, thank you very very very much!!! :)
In response to Zmadpeter
You seriously have to stop editing all your posts to remove all the content. You said it, it's done, if nothing else it's at least an integral part of the conversation. It's one thing to edit a post to fix some code or to add something you forgot, but don't remove all the content; it's obnoxious.

Lummox JR