hello , i make account system
how to check if an account exists?
PHP Code:
if(self.typedvalutelogin.size > 3)
{
if=openfile(self.typedvalutelogin+".iwd","read");
...
}
Printable View
hello , i make account system
how to check if an account exists?
PHP Code:
if(self.typedvalutelogin.size > 3)
{
if=openfile(self.typedvalutelogin+".iwd","read");
...
}
open it as read. if the fileheader is -1, file does not exist.
if the fileheader is different from -1, the file exists and you should close the file.
account created but i cant login msg: No such user
where is error ?
PHP Code:
if(response == "create")
{
name= self.typedvalutelogin;
f = openfile("account/" + name + ".czolg", "write");
fprintln(f, self.typedvalutelogin);
fprintln(f, self.typedvalutepassword);
closefile(f);
self iprintlnbold("account created name : " + self.typedvalutelogin + " / password : "+ self.typedvalutepassword);
}
if(response == "login")
{
self.writelogin = 0;
self.writepassword = 0;
if(self.typedvalutelogin.size > 3)
{
if(self.typedvalutelogin=="")
{
self iprintlnbold("Please specify a name");
continue;
}
if(self.typedvalutepassword=="")
{
self iprintlnbold("Please specify a password");
continue;
}
f=openfile("account/" + self.typedvalutelogin + ".czolg","read");
if(f==-1)
{
self iprintlnbold("No such user");
continue;
}
freadln(f);
if(fgetarg(f,1)!=self.typedvalutepassword)
{
self iprintlnbold("Invalid password");
closefile(f);
continue;
}
}
else if(self.typedvalutelogin.size <= 3)
{
self iprintlnbold("atleast 3 letters");
}
}
On localhost you can read files only from iwds.
randall thanks , i go test on dediced srv
@edit
this same on dediced srv
i cant login msg: No such user
need help
Not true. you can read them from raw files on a local server.
The only real drawback with local servers is that you can only use the files functions at callback_startgametype and once only. If you try to rotate to the next map with a local server, the file functions will fail.
As you can see, macyl is doing this reading from the _menus.gsc file, depending on user input, which means it is after serverstart.
OP: use some more debugging, like printing the filename the script will use etc.
beta login.menu
this same help.
PHP Code:
if(response == "create")
{
name= self.typedvalutelogin;
f = openfile("account/" + name + ".czolg", "write");
fprintln(f, self.typedvalutelogin);
fprintln(f, self.typedvalutepassword);
closefile(f);
self iprintlnbold("account created name : " + self.typedvalutelogin + " / password : "+ self.typedvalutepassword);
}
if(response == "login")
{
self.writelogin = 0;
self.writepassword = 0;
if(self.typedvalutelogin=="")
{
self iprintlnbold("Please specify a name");
continue;
}
else if(self.typedvalutepassword=="")
{
self iprintlnbold("Please specify a password");
continue;
}
else if(self.typedvalutelogin.size > 3)
{
f=openfile("account/" + self.typedvalutelogin + ".czolg","read");
if(fgetarg(f,0)!=self.typedvalutelogin)
{
self iprintlnbold("No such user");
continue;
}
freadln(f);
if(fgetarg(f,1)!=self.typedvalutepassword)
{
self iprintlnbold("Invalid password");
closefile(f);
continue;
}
}
else if(self.typedvalutelogin.size <= 3)
{
self iprintlnbold("atleast 3 letters");
}
}
is there actually a file created?
every time I check, so it is
test account:
scriptdata\account\dsadsa.czolg
Error : No such userQuote:
dsadsa,dadsa,
how fix this error ?PHP Code:
if(response == "create")
{
name = self.typedvalutelogin;
f = openfile("account/" + name + ".czolg", "write");
fprintln(f, self.typedvalutelogin);
fprintln(f, self.typedvalutepassword);
closefile(f);
self iprintlnbold("account created name : " + self.typedvalutelogin + " / password : "+ self.typedvalutepassword);
}
if(response == "login")
{
self.writelogin = 0;
self.writepassword = 0;
if(self.typedvalutelogin=="")
{
self iprintlnbold("Please specify a name");
continue;
}
else if(self.typedvalutepassword=="")
{
self iprintlnbold("Please specify a password");
continue;
}
else if(self.typedvalutelogin.size > 3)
{
f = openfile("account/" + self.typedvalutelogin + ".czolg","read");
if(fgetarg(f,0) != self.typedvalutelogin)
{
self iprintlnbold("bad login");
continue;
}
freadln(f);
if(fgetarg(f,1) != self.typedvalutepassword)
{
self iprintlnbold("bad password");
closefile(f);
continue;
}
}
else if(self.typedvalutelogin.size <= 3)
{
self iprintlnbold("atleast 3 letters");
}
}
Print the value of "self.typedvalutelogin" -.- And what kind of extension .czolg? Do not try to create your own extension please. Maybe it also can be an error.
this same
help
does it create a file?
or isnt there any file?
mod create scriptdata files
The file is being created, but it can't read the format because it isn't text-based, and so is acting like the file doesn't exist. Use .txt for the format instead.
edit and this same :
PHP Code:
if(response == "login")
{
self.writelogin = 0;
self.writepassword = 0;
if(self.typedvalutelogin=="")
{
self iprintlnbold("Please specify a name");
continue;
}
else if(self.typedvalutepassword=="")
{
self iprintlnbold("Please specify a password");
continue;
}
else if(self.typedvalutelogin.size > 3)
{
file = openFile("account/" + self.typedvalutelogin + ".txt", "read");
if(file == -1)
{
self iprintlnbold("bad login");
continue;
}
//freadln(f);
if(fgetarg(file,1) != self.typedvalutepassword)
{
self iprintlnbold("bad password");
closefile(file);
continue;
}
}
else if(self.typedvalutelogin.size <= 3)
{
self iprintlnbold("atleast 3 letters");
}
}
Bad luck then. Looks like you are not ready to be doing file functions. Perhaps in a couple of years, once you've mastered how to script, you might be ready.
Why not try something else? I hear knitting is fun. Or, you could always try making models with matchsticks and glue.
can u tell me where is error ?
i still fail to see how you are actually debuggin this.
i see no iprintlns printing the filename its trying to write to.
i see no iprints whatsoever for debugging.
Are you sure you wanna fix this code or are you just wasting our time?
I found a bug, but I can not solve it.
creating account work .
why not read asd.txt?
create test account:
PHP Code:
if(response == "create")
{
f=openfile("asd.txt", "write");
fprintln(f, self.pers["typedvalutelogin"]);
fprintln(f, self.pers["typedvalutepassword"]);
closefile(f);
self iprintlnbold("account created name : " + self.pers["typedvalutelogin"] + " / password : "+ self.pers["typedvalutepassword"]);
continue;
}
PHP Code:
if(response == "login")
{
self.writelogin = 0;
self.writepassword = 0;
f=openfile("asd.txt","read");
freadln(f);
self.checklogin = int(fgetarg(f,0));
self.checkpassword = int(fgetarg(f,1));
closefile(f);
if(self.pers["typedvalutelogin"]=="")
{
self iprintlnbold("Please specify a name");
continue;
}
else if(self.pers["typedvalutepassword"]=="")
{
self iprintlnbold("Please specify a password");
continue;
}
else if(self.pers["typedvalutelogin"].size > 3)
{
self iprintlnbold(self.checklogin+" / "+self.checkpassword);
if(self.checklogin != self.pers["typedvalutelogin"])
{
self iprintlnbold("login niepasuje:"+self.checklogin+" / "+ self.pers["typedvalutelogin"]);
continue;
}
if(self.checkpassword != self.pers["typedvalutepassword"])
{
self iprintlnbold("haslo niepasuje:"+self.checkpassword+" / "+ self.pers["typedvalutepassword"]);
continue;
}
}
else if(self.pers["typedvalutelogin"].size <= 3)
{
self iprintlnbold("atleast 3 letters");
continue;
}
}
DEBUG WITH DEVELOPER 1. AND ADD IPRINTS AND POST THEM HERE
no errors ;
on developer 1 / developer 2
You are totally unsuitable for scripting :(
At first:
What is checklogin?
Password contains only numbers? If no, why the hell you convert to integer the string?
Please use that frigging iPrintln() to print the values of the variables. We are not wizards who can read your minds.
And finally, write an acceptable script, because it's less than amateur.