ID:155316
 
This is what I'm trying to accomplish.
[IMG]http://i53.tinypic.com/ayufq.png[/IMG]


so when the user types in a user name and a password, and then clicks create, it will save the username and password and enable them to use the login button next. Now here is my code

mob/proc
Create(mob.client)
alert("Enter your Username and Password that you want below. You can only do this once, remember it and make sure there is no errors!")
var/P =usr<< winget(src,"Login.Username", "text==true")
var/U =usr<< winget(src,"Login.Password", "text==true")
if(P=="true"||U=="true")
src.UserName = winget(src,"Login.Username", "text==true")
src.Password = winget(src,"Login.Password", "text==true")
var/savefile/F=new("players/[Name],[Password]/.sav")
var/gotit
F["Password"||"Username"]>>gotit
Save(src)



here's the vars


mob/var
Password
UserName
Name
lastx
lasty
lastz
NoMatch
And what's the problem?
In response to Zaoshi
Zaoshi wrote:
And what's the problem?

Exactly, lol
Chaorace wrote:
This is what I'm trying to accomplish.
[IMG]http://i53.tinypic.com/ayufq.png[/IMG]


so when the user types in a user name and a password, and then clicks create, it will save the username and password and enable them to use the login button next. Now here is my code

> mob/proc
> Create(mob.client)
> alert("Enter your Username and Password that you want below. You can only do this once, remember it and make sure there is no errors!")
> var/P =usr<< winget(src,"Login.Username", "text==true")
> var/U =usr<< winget(src,"Login.Password", "text==true")
> if(P=="true"||U=="true")
> src.UserName = winget(src,"Login.Username", "text==true")
> src.Password = winget(src,"Login.Password", "text==true")
> var/savefile/F=new("players/[Name],[Password]/.sav")
> var/gotit
> F["Password"||"Username"]>>gotit
> Save(src)

here's the vars


mob/var
> Password
> UserName
> Name
> lastx
> lasty
> lastz
> NoMatch


I wonder that the trouble,is that he wan't to make an login and register system.
In response to Zaoshi
Zaoshi wrote:
And what's the problem?

It doesn't work, that's the problem xD
1) When you are defining P & U, what's up with the "usr <<" portion?

2) You should encrypt the password, not keep it raw like that. Use md5()

3)
F["Password"||"Username"]

That is an incorrect syntax. In addition, by using new() earlier, you had created that file! What you want to do is, after src.Password, look for if the file exists with fexists: "if(fexists("/file path"))"
In response to GhostAnime
GhostAnime wrote:
1) When you are defining P & U, what's up with the "usr <<" portion?

2) You should encrypt the password, not keep it raw like that. Use md5()

3)
F["Password"||"Username"]

That is an incorrect syntax. In addition, by using new() earlier, you had created that file! What you want to do is, after src.Password, look for if the file exists with fexists: "if(fexists("/file path"))"

Sorry, I've never used md5 before so I think i have it wrong xD

mob/var/hash

mob/proc
Create(mob.client)
alert("Enter your Username and Password that you want below. You can only do this once, remember it and make sure there is no errors!")
var/P =winget(src,"Login.Username", "text==true")
var/U =winget(src,"Login.Password", "text==true")
if(md5("[P]/[U]") != hash)
src.UserName = winget(src,"Login.Username", "text==true")
src.Password = winget(src,"Login.Password", "text==true")
if(fexists("players/[UserName],[Password]/.sav"))
var/savefile/F=new("players/[UserName],[Password]/.sav")
Save(F)



Something like that? Sorry I'm a novice programmer.


Also when I set the button of Create in the Login skin, i set the command to Create, but get inncaccsible verb crap when I click it, am i not allowed to set the command to be a proc?



Also here's my load/save procs, IDK if these will help?


mob/proc/Load(var/savefile/F)
F=new("players/[src.UserName],[Password]/.sav")
if(fexists("players/[UserName],[Password]/.sav"))
F["lastx"] >> src.lastx
F["lasty"] >> src.lasty
F["lastz"] >> src.lastz
F["[src.loc]"] >> src.loc
F["[Password]"] >> src.Password
F["[UserName]"] >> src.UserName
loc=locate(lastx,lasty,lastz)
src.Read(F)
del(F)

mob/proc/Save(mob/M as mob)
var/savefile/F=new("players/[M.UserName],[M.Password]/.sav")
F["lastx"]<<M.lastx
F["lasty"]<<M.lasty
F["lastz"]<<M.lastz
F["UserName"]<<M.UserName
F["Password"]<<M.Password
Write(F)
In response to Chaorace
You are not supposed to call Read() and Write() manually.
In response to Neimo
Neimo wrote:
You are not supposed to call Read() and Write() manually.

SO I should delete the read and write procs under the load and save?
In response to Chaorace
In response to Neimo
Neimo wrote:
[link]

Alright I read that up and I came to this:


mob/proc/Load(var/savefile/F)
F=new("players/[src.UserName],[Password]/.sav")
F["UserName"] >> src.UserName
F["Password"] >> src.Password


mob/proc/Save(mob/M as mob)
var/savefile/F = new("players/[M.UserName],[M.Password]/.sav")
F["UserName"]<<M.UserName
F["Password"]<<M.Password




mob
Write(var/savefile/F)
..()
F["UserName"]<<src.UserName
F["Password"]<<src.Password
F["x"] << x
F["y"] << y
F["z"] << z
Read(var/savefile/F)
..()
F["UserName"]>>src.UserName
F["Password"]>>src.Password
loc = locate(F["x"], F["y"], F["z"])



IS this the correct way? Also, since you can only set the command for buttons to a verb, how would I go about making it so once you click login, it loads all your info etc


I also changed it up a little, show when you connect, it only shows the LOGIN window, instead of the default, and then so when you click the login button, It thud pop up the default window and make the Login window dissappear.
But if I put Load() under the login proc, it'll make the default window show, so that was my test. Here's the updated codes to make it work, but I think I'm doing this the wrong way.

mob/Login()
winshow(src, "Login", 1)
winshow(src, "Default", 0)
winshow(src, "Browser",0)
winshow(src, "Inventory",0)
winshow(src, "Skills",0)
winshow(src, "Info",0)
winshow(src, "Who", 0)






















mob/proc/Load(var/savefile/F)
F=new("players/[src.UserName],[Password]/.sav")
F["UserName"] >> src.UserName
F["Password"] >> src.Password
winshow(src, "Default", 1)
Read(F)


mob/proc/Save(mob/M as mob)
var/savefile/F = new("players/[M.UserName],[M.Password]/.sav")
F["UserName"]<<M.UserName
F["Password"]<<M.Password




mob
Write(var/savefile/F)
..()
F["UserName"]<<src.UserName
F["Password"]<<src.Password
F["x"] << x
F["y"] << y
F["z"] << z
Read(var/savefile/F)
..()
F["UserName"]>>src.UserName
F["Password"]>>src.Password
loc = locate(F["x"], F["y"], F["z"])


mob/var/hash

mob/verb
Create(mob.client)
/* alert("Enter your Username and Password that you want below. You can only do this once, remember it and make sure there is no errors!")*/
var/P =winget(src,"Login.Username", "text==true")
var/U =winget(src,"Login.Password", "text==true")
if(md5("[P]/[U]") != hash)
src.UserName = winget(src,"Login.Username", "text")
src.Password = winget(src,"Login.Password", "text")
winset(src, "Login.CreatingCharacter", "is-visible")
if(fexists("players/[UserName],[Password]/.sav"))
var/savefile/F=new("players/[UserName],[Password]/.sav")
Save(F)



I just need to hurry up and get this complete so I can move on to other things... that are easier.
In response to Chaorace
Anyways I added a few new things



mob/verb
Create(mob.client)
var/U =winget(usr,"Login.Username", "Text")
var/P =winget(usr,"Login.Password", "Text")
usr.UserName = P
usr.Password = U
winshow(src, "Login.CreatingCharacter", 1)
sleep(20)
winshow(src, "Login.CreatingCharacter", 0)
if(fexists("players/[UserName],[Password]/.sav"))
var/savefile/F=new("players/[UserName],[Password]/.sav")
Save(F)



mob/var/Loggedin=0



mob/Login()
src.Loggedin=1
if(Loggedin==1) return
else
winshow(src, "Default", 0)
winshow(src, "Browser",0)
winshow(src, "Inventory",0)
winshow(src, "Skills",0)
winshow(src, "Info",0)
winshow(src, "Who", 0)
for(var/T in nulliparae(/obj/Skillcards/))
contents+= new T()
usr.icon = 'BaseW.dmi'
health_bar = new(src, 'HealthBar.dmi', 14, "health", "health_max", pixel_y =-8)
chakra_bar = new(src, 'ChakraBar.dmi', 10, "chakra", "chakra_max", pixel_y=-16)
Online_Players+=src
GetScreenResolution(src)
usr.client.StartKeys()
usr.client.StartHUDs()
UpdateSkillsGrid(src)
health_bar.Update()
src.Update()
src.Update2()
client.view="30x19"







mob/verb/Finished()
winshow(src, "Login.LoadingCharacter",1)
sleep(20)
var/savefile/F = new("players/.sav")
var/P =winget(src,"Login.Password", "Text")
if(fexists("players/.sav"))
F["username"]>>usr.UserName
F["password"]>>usr.Password
Read(F)
winshow(src, "Login.LoadingCharacter",0)
else
winshow(src, "Login.PasswordWrong",1)
if(P==usr.Password)
winshow(src, "Login.LoadingCharacter", 0)
winshow(src, "Login.PasswordWrong",0)
winshow(src, "Login.Success",1)
sleep(20)
src.Loggedin=0
Login()
src.Read(F)


I made a finished verb to set the Login Button too. so it checks if the Password the person entered is correct if it's not the label PasswordWrong will show, and the user will have to enter the Password again until it's correct.

On the login thing, I made it so login proc isn't called yet until the person clicks Finished or Load button, well that's what I want to happend anyways... And the create, it just doesn't save the users password and username, I had it workin earlier but IDK what happened :S.

And, here are the save/load procs

mob/proc/Load(var/savefile/F)
F=new("players/[src.UserName],[Password]/.sav")
F["UserName"] >> src.UserName
F["Password"] >> src.Password
Read(F)


mob/proc/Save(mob/M as mob)
var/savefile/F = new("players/[M.UserName],[M.Password]/.sav")
F["UserName"]<<M.UserName
F["Password"]<<M.Password
Write(F)




mob
Write(var/savefile/F)
..()
F["UserName"]<<src.UserName
F["Password"]<<src.Password
F["x"] << x
F["y"] << y
F["z"] << z
Read(var/savefile/F)
..()
F["UserName"]>>src.UserName
F["Password"]>>src.Password
loc = locate(F["x"], F["y"], F["z"])
In response to Chaorace
I haven't read through all of this, but after looking at your last post, I highly recommend you use md5() proc on the player's password, for security reasons. md5() is a one-way hash.
md5("hi")

This line will return a text string that will always be the same as long as you always use md5("hi"). In other words, and I quote, "The same value will always have the same hash." This means that you don't have to fret about it being a one-way hash. You can easily check the password like so:
var/entered_password = "hi"
var/password = //use your code to find their hashed password from the savefile
if(md5(entered_password) == password)
return TRUE


Use the DM Reference if any more explanation is required.


Also.
mob/proc/Load(var/savefile/F)
F=new("players/[src.UserName],[Password]/.sav")
F["UserName"] >> src.UserName //UNNECESSARY
F["Password"] >> src.Password //UNNECESSARY
Read(F)


mob/proc/Save(mob/M as mob)
var/savefile/F = new("players/[M.UserName],[M.Password]/.sav")
F["UserName"]<<M.UserName //UNNECESSARY
F["Password"]<<M.Password //UNNECESSARY
Write(F)

You have the UserName and Password being saved/read twice. You are saving/reading them before the Write() and Read() procs, and also inside them. Oh, and why do you have no name for your savefiles? That may be your issue. You have a folder that is named with their username and password(Which isn't smart. You don't want just anyone who has access to the saves to be able to log in as anyone.), then just a file called ".sav".
In response to Albro1
Albro1 wrote:
I haven't read through all of this, but after looking at your last post, I highly recommend you use md5() proc on the player's password, for security reasons. md5() is a one-way hash.
> md5("hi")
>

This line will return a text string that will always be the same as long as you always use md5("hi"). In other words, and I quote, "The same value will always have the same hash." This means that you don't have to fret about it being a one-way hash. You can easily check the password like so:
> var/entered_password = "hi"
> var/password = //use your code to find their hashed password from the savefile
> if(md5(entered_password) == password)
> return TRUE
>

Use the DM Reference if any more explanation is required.


Also.
> mob/proc/Load(var/savefile/F)
> F=new("players/[src.UserName],[Password]/.sav")
> F["UserName"] >> src.UserName //UNNECESSARY
> F["Password"] >> src.Password //UNNECESSARY
> Read(F)
>
>
> mob/proc/Save(mob/M as mob)
> var/savefile/F = new("players/[M.UserName],[M.Password]/.sav")
> F["UserName"]<<M.UserName //UNNECESSARY
> F["Password"]<<M.Password //UNNECESSARY
> Write(F)
>

You have the UserName and Password being saved/read twice. You are saving/reading them before the Write() and Read() procs, and also inside them. Oh, and why do you have no name for your savefiles? That may be your issue. You have a folder that is named with their username and password(Which isn't smart. You don't want just anyone who has access to the saves to be able to log in as anyone.), then just a file called ".sav".


Well I didn't use md5 because I wanted it so I know there passwords so if they forget they can come to me and ask me. But I might use md5 just so if anyone doesn't trust me but I still don't understand it, you cleared it up just a little
but if md5("hi") how do i make it so the user can enter anything for the password? so i'd do md5("")? ALso I fixed up those load and save procs

mob/proc/Load(var/savefile/F)
F=new("players/[src.UserName]/[src].sav")
Read(F)


mob/proc/Save(mob/M as mob)
var/savefile/F = new("players/[M.UserName]/[src].sav")
Write(F)




mob
Write(var/savefile/F)
..()
F["UserName"]<<src.UserName
F["Password"]<<src.Password
F["x"] << x
F["y"] << y
F["z"] << z
Read(var/savefile/F)
..()
F["UserName"]>>src.UserName
F["Password"]>>src.Password
loc = locate(F["x"], F["y"], F["z"])
In response to Chaorace
Just do what you are doing. They enter what they want in the password input box, then you use winget() and grab it. Then simply md5() the password you grabbed and shove it in their savefile.
In response to Albro1
OK also, I changed the sav proc to [usr] or whatever and i tested it and it doesn't create a save file =S
In response to Chaorace
You are only saving your x, y, z, password and username; nothing else.

var/savefile/savefile = new( "directory/[src.key].sav" )


Do not use <small>[usr]</small> in procs.

Also, I suggest not manually calling Read() and Write().
In response to Chaorace
If it doesn't create the savefile, then there is an issue with the Save() proc. Simply calling the new() and designating the location will create the savefile, whether you populate it or not. Something is stopping that.
In response to Neimo
Neimo wrote:
You are only saving your x, y, z, password and username; nothing else.

This too.

EDIT: You will need to do a:
F["vars"]<<vars

And anything else you want to save. You should probably save their overlays. Don't use:
F<<src

It is a waste of space by sending your whole mob into the savefile. Populate it with the mob's information, Read() sends the client to a new mob anyways.

As I said though, the issue is BEFORE this if the savefile isn't even being created.
In response to Albro1
You're also doing something very.. odd with your save verb.

mob/proc/Save(mob/M as mob)


<small>M</small> is already you; src.

In order to save the mob and all modified variables, add this in your save proc.

f[ "mob" ] << mob


(Do not copy and paste that, this is for using client/proc/Save())

Edit: >_> @ above.

Do not save icon data in your save files, creates a huge mess.

f.dir.Remove( "icon" , "overlays" , "underlays" )
Page: 1 2