SA-MP Forums Archive
[HELP] /changepass command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP] /changepass command (/showthread.php?tid=566767)



[HELP] /changepass command - XYZero - 08.03.2015

Код:
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


Re: [HELP] /changepass command - biker122 - 08.03.2015

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;
}



Re: [HELP] /changepass command - XYZero - 08.03.2015

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


Re: [HELP] /changepass command - biker122 - 08.03.2015

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.


Respuesta: [HELP] /changepass command - JuanStone - 08.03.2015

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;




Re: [HELP] /changepass command - XYZero - 08.03.2015

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