[HELP] /changepass command
#1

Код:
CMD:changepass(playerid,params[]) {
	if(PlayerInfo[playerid][LoggedIn] == 0)	{
		if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /changepass [new password]");
		if(strlen(params) < 4) return SendClientMessage(playerid,red,"ERROR: Incorrect password length");
		new string[128];
		dUserSetINT(PlayerName2(playerid)).("password_hash",udb_hash(params) );
		PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
        format(string, sizeof(string),"|- ACCOUNT: You have successfully changed your password to \"%s\" -|",params);
		return SendClientMessage(playerid,yellow,string);
	} else return SendClientMessage(playerid,red, "ERROR: You must have an account to use this command");
}
When someone type /changepass it always says ERROR: You must have an account to use this command
Reply
#2

Yes, this looks like you don't set the PlayerInfo[playerid][LoggedIn] value to 1 upon logging in.
Better check if you're setting its value to 1 after logging in, and try to run the code again.
pawn Код:
CMD:changepass(playerid,params[])
{
    if(PlayerInfo[playerid][LoggedIn] == 0) return SendClientMessage(playerid,red, "ERROR: You must have an account to use this command");
    if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /changepass [new password]");
    if(strlen(params) < 4) return SendClientMessage(playerid,red,"ERROR: Incorrect password length");
    new string[128];
    dUserSetINT(PlayerName2(playerid)).("password_hash",udb_hash(params) );
    PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
        format(string, sizeof(string),"|- ACCOUNT: You have successfully changed your password to \"%s\" -|",params);
    SendClientMessage(playerid,yellow,string);
    return 1;
}
Reply
#3

I got this
error 029: invalid expression, assumed zero
error 001: expected token: ";", but found "return"
warning 225: unreachable code
Reply
#4

Show which lines they are. Also, show me your Login dialog (code)
[pawn]
pawn Код:
CMD:changepass(playerid,params[])
{
    if(PlayerInfo[playerid][LoggedIn] == 0) return SendClientMessage(playerid,red, "ERROR: You must have an account to use this command");
    if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /changepass [new password]");
    if(strlen(params) < 4) return SendClientMessage(playerid,red,"ERROR: Incorrect password length");
    new string[128];
    dUserSetINT(PlayerName2(playerid)).("password_hash",udb_hash(params) );
    PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
        format(string, sizeof(string),"|- ACCOUNT: You have successfully changed your password to \"%s\" -|",params);
    SendClientMessage(playerid,yellow,string);
    return 1;
}
Noticed some mistakes in the last post, updated.
Reply
#5

PHP код:
CMD:changepass(playeridparams[])
{
    if(
PlayerInfo[playerid][LoggedIn] == 1)
    {
        if(
isnull(params))
            return 
SendClientMessage(playeridred"USAGE: /changepass [new password]");
        if(
strlen(params) < 4)
            return 
SendClientMessage(playeridred"ERROR: Incorrect password length");
            
        new 
string[128];
        
format(stringsizeof(string),"|- ACCOUNT: You have successfully changed your password to \"%s\" -|",params);
        
SendClientMessage(playeridyellowstring);
        
dUserSetINT(PlayerName2(playerid)).("password_hash"udb_hash(params));
        
PlayerPlaySound(playerid10570.00.00.0);
    }
    else 
SendClientMessage(playerid,red"ERROR: You must have an account to use this command");
    
//..
    
return true;

Reply
#6

Quote:
Originally Posted by biker122
Посмотреть сообщение
Show which lines they are. Also, show me your Login dialog (code)
[pawn]
pawn Код:
CMD:changepass(playerid,params[])
{
    if(PlayerInfo[playerid][LoggedIn] == 0) return SendClientMessage(playerid,red, "ERROR: You must have an account to use this command");
    if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /changepass [new password]");
    if(strlen(params) < 4) return SendClientMessage(playerid,red,"ERROR: Incorrect password length");
    new string[128];
    dUserSetINT(PlayerName2(playerid)).("password_hash",udb_hash(params) );
    PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
        format(string, sizeof(string),"|- ACCOUNT: You have successfully changed your password to \"%s\" -|",params);
    SendClientMessage(playerid,yellow,string);
    return 1;
}
Noticed some mistakes in the last post, updated.
It works, thank you man
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)