ID:140995
 
Code:
    Login()
icon_state = gender
/*var/ini_reader/IRead = new("Settings.ini", INIREADER_INI)
var/list/Dict = IRead.ReadSetting("motdi")
if( Dict )*/

//usr << Dict["motd"]
world << "[usr] has logged in."
if (fexists("saves/[copytext(ckey(src.key),1,2)]/[ckey(src.key)].sav") == 1)
var/savefile/si = new("saves/[copytext(ckey(src.key),1,2)]/[ckey(src.key)].sav")
si["HP"] >> HP
si["MHP"] >> MHP
si["MP"] >> MP
si["MMP"] >> MMP
si["wealth"] >> wealth
si["Level"] >> level
si["xp"] >> xp
si["str"] >> str
si["def"] >> def
si["adminlevel"] >> adminlevel
si["last_x"] >> hx
si["last_y"] >> hy
si["last_z"] >> hz
si["weapon"] >> weapon
si["helm"] >> helm
si["body"] >> body
si["legs"] >> legs
si["feet"] >> feet
si["cape"] >> cape
si["shield"] >> shield
si["ring"] >> neck
si["neck"] >> neck
if (adminlevel == 1)
GetAdmin(src)
..()
else
usr << "It appars this is your first time playing YOUR GAME NAME! Welcome!"
//put the code for first time users here.


Problem description:

Gives me these errors:
base.dm:125:error:usr:duplicate definition
base.dm:125:error:"It appars this is your first time playing YOUR GAME NAME! Welcome!":duplicate definition
base.dm:125:error:<< :instruction not allowed here


IS my compiler messed up?
You need to tab "else" and the lines beneath that. They aren't indented under Login() correctly.
To see your tabs, press Ctrl+T.
No, you messed up the indentation.

Also: that's terrible. Where did you get that so that I can yell at the person who made it? Along the same lines, I suggest deleting what you have and starting from scratch.
Thanks everyone
In response to Garthor
I made it, thank you very much.

Suggest an alternative?

Also, why is it bad?
In response to Neos300
        usr << "It appars this is your first time playing YOUR GAME NAME! Welcome!"
//put the code for first time users here.


This strongly implies that it was not, in fact, made by you.

And I already suggested my alternative: start from scratch.

As for why it's bad: it's using usr in procs, not using savefiles correctly, and (on a minor point) doing silly if(fexists() == 1) instead of just if(fexists()). And that's just from looking at Login().
In response to Garthor
The first thing: I am making a game engine for others to use, not a game. So thats my placeholder text.

2nd: This is some really old code i wrote about 2 years ago, and i didnt know much that then. I am working on improving it.

Can you please xpalin why the saving system in particular is bad? Im afrad i just dont see it.
In response to Neos300
You're manually saving every var individually, manually. That's not conveniently manageable, nor robust, needless extra work, etc. Virtually all you need to do is save the whole object automatically using DM's built-in object saving methods (e.g. Savefile << Object). Then if you need extra control over it you could override Write()&Read(), declare vars as 'tmp' to prevent them being saved, etc.
In response to Kaioken
Is this good?

Login()
if (fexists blah)
var/savefile/s = new("hi.save")
s["mob"] >> src

Logout()
var/savefile/s = new("hi.save")
s["mob"] << src
In response to Neos300
To make savefiles even more confusing, read this.
In response to Neos300
Close, but you really need to be doing this stuff in client/New(). Loading the mob from a savefile is going to be creating a new mob and logging you into that one, which calls Logout() and Login(). So:

client/New()
if(fexists())
var/savefile/S = new()
//we'll load it into mob but it doesn't particularly matter what we load it into: we'll log into it because it has our key anyway
S >> mob
else
src << "U NU"
//this will create a mob for us if one was not loaded (whether because there was no save file or the save file was loaded improperly)
..()

client/Del()
var/savefile/S = new()
S << mob
del(mob)
..()
In response to Neos300
Neos300 wrote:
The first thing: I am making a game engine for others to use, not a game. So thats my placeholder text.

2nd: This is some really old code i wrote about 2 years ago, and i didnt know much that then. I am working on improving it.

Can you please xpalin why the saving system in particular is bad? Im afrad i just dont see it.

If you want to make a game engine for other to use, you should better learn professional coding techniques for yourself first, because you don't want to carry the responsibility of bad-coded games popping up on BYOND.

I've already been scolded at for showing a beginner coder to use 'goto', and believe me, it didn't make me feel good. :-/
In response to Nielz
I've already been scolded at for showing a beginner coder to use 'goto', and believe me, it didn't make me feel good. :-/

Being scolded about goto may hurt now, but, behold the horrid fate that awaits those who use it unthinkingly! http://www.xkcd.com/292/

See what we have disaster we have saved you from, now that you are on the Right Path?
In response to Nielz
Nielz wrote:
I've already been scolded at for showing a beginner coder to use 'goto', and believe me, it didn't make me feel good. :-/

It's good that you take things into consideration and I applaud you for it, but you don't need to actually take things to heart. Remember, these are only words from some people, on the internet, even.