Little Login Problem. -
Toni - 04.08.2010
Hi there, I'm developing a new GM from scratch, and I am having problems with the login cmd
This is my code for it so far;
pawn Код:
CMD:login(playerid, params[])
{
new str[128], password[58], tmp[256];
format(str, sizeof(str), "RCRP/Users/%s.ini", pName(playerid));
if(!fexist(str))
{
if(PlayerInfo[playerid][pLoggedIn] == 1)
{
SendClientMessage(playerid, RED, "ERROR: You are already logged in!");
return 1;
}
else
{
tmp = dini_Get(str, "Password");
if(sscanf(params, "s[58]", password))
{
return SendClientMessage(playerid, LBLUE, "USAGE: /login (password)");
}
if(!strcmp(password, tmp, false))
{
SendClientMessage(playerid, RED, "ERROR: Logged in failed, wrong password");
}
else
{
PlayerInfo[playerid][pLoggedIn] = 1;
PlayerInfo[playerid][pRegistered] = 1;
GivePlayerMoney(playerid, dini_Int(str, "Money"));
PlayerInfo[playerid][pLevel] = dini_Int(str, "Level");
SendClientMessage(playerid, LBLUE, "[SUCESSS]: You have logged in!");
}
}
}
else
{
SendClientMessage(playerid, RED, "ERROR: That name does not exist!");
}
return 1;
}
This is kinda based off of Eric_'s reg/login tut, but with sscanf and ZCMD. and also without dudb.
The problem is that if i do /login 3 it would say "[SUCESS]: You have logged in!", when thats not even the password,
anyone mind helping me?
Re: Little Login Problem. -
Faith - 04.08.2010
pawn Код:
if(!strcmp(password, tmp, false))
{
SendClientMessage(playerid, RED, "ERROR: Logged in failed, wrong password");
}
I am not sure, I might have missed it, but where did you define password as in strcmp(password, tmp, false))?
Re: Little Login Problem. -
Toni - 04.08.2010
pawn Код:
if(sscanf(params, "s[58]", password))
If i'm not mistaken, sscanf assigns the string to the password?
Re: Little Login Problem. -
Mike Garber - 04.08.2010
if(sscanf(params, "s[58]", password))
Where's "password" defined? And where does that s[58] come from?
Re: Little Login Problem. -
Kar - 04.08.2010
pawn Код:
if(strcmp(password, tmp, false))
{
SendClientMessage(playerid, RED, "ERROR: Logged in failed, wrong password");
}
when strcmp matchs it returns 0
u do !strcmp if its right
Re: Little Login Problem. -
Toni - 04.08.2010
s[58] = string with an array of 58.
and its up at the top, by the other declarations, "new str[128], password[58], tmp[256];"
@ Kar, explain a little more please?
Re: Little Login Problem. -
Faith - 04.08.2010
This is what I use to check codes and such.
pawn Код:
if( strcmp(password, tmp, true)==0 ){
Re: Little Login Problem. -
Kar - 04.08.2010
okay i noticed that people are always telling me to use if "!strmp" but its not actually that if you use "strcmp" without the ! it returns 0
notice some of your old strcmp cmds they are if(!strcmp
and some are if(strcmp == 0 and stuff. anyways fuck that.
pawn Код:
if(strcmp(ppw, inputtext, true) != 0)
{
SendClientMessage(playerid,COLOR_RED,"Wrong Password");
ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Login","Please Type Your Password Below To Login","Login","Cancel");
}
thats my dialog seE? if(strcmp that means it wrong [/pawn]if(!strcmp) this means it matchs and is right[/pawn]
edit. as Faiths code above saying if strcmp , w/e,true = 0 see (True = 0) same as the false in your cmd
Re: Little Login Problem. -
Toni - 04.08.2010
Quote:
Originally Posted by Kar
okay i noticed that people are always telling me to use if "!strmp" but its not actually that if you use "strcmp" without the ! it returns 0
notice some of your old strcmp cmds they are if(!strcmp
and some are if(strcmp == 0 and stuff. anyways fuck that.
pawn Код:
if(strcmp(ppw, inputtext, true) != 0) { SendClientMessage(playerid,COLOR_RED,"Wrong Password"); ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Login","Please Type Your Password Below To Login","Login","Cancel"); }
thats my dialog seE? if(strcmp that means it wrong [/pawn]if(!strcmp) this means it matchs and is right[/pawn]
edit. as Faiths code above saying if strcmp , w/e,true = 0 see (True = 0) same as the false in your cmd
|
Yeah, as Faith said, I'll try changing that, but I thought that params there is "bool:ignorecase = false", which I don't, passwords to be secure should be case sensitive, but okay, I'll try.
Re: Little Login Problem. -
Kar - 04.08.2010
strcmp is kinda weird. if you wanna do it the other way around use strmatch