Little Login Problem.
#1

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?
Reply
#2

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))?
Reply
#3

pawn Код:
if(sscanf(params, "s[58]", password))
If i'm not mistaken, sscanf assigns the string to the password?
Reply
#4

if(sscanf(params, "s[58]", password))

Where's "password" defined? And where does that s[58] come from?
Reply
#5

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
Reply
#6

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?
Reply
#7

This is what I use to check codes and such.

pawn Код:
if( strcmp(password, tmp, true)==0 ){
Reply
#8

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
Reply
#9

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.
Reply
#10

strcmp is kinda weird. if you wanna do it the other way around use strmatch
Reply


Forum Jump:


Users browsing this thread: