Setpass
#1

PHP код:
CMD:setpassword(playeridparams[])
{
    if(
pData[playerid][Admin] >= 7)
    {
        new 
query[320], name[24], newpass[34],query1[320];
        if(
sscanf(params"s[24]s[34]"namenewpass)) return SendClientMessage(playeridCOLOR_YELLOW"USAGE: /setpassword <PlayerName> <NewPassword>");
        if(!
AccountExists(name)) return SendClientMessage(playeridred"Account does not exists");
        
mysql_format(mysqlquerysizeof(query),"SELECT `Password` FROM `players` WHERE `Username` = '%e'");
        
mysql_tquery(mysql,query);
        
        
mysql_tquery(mysqlquery"ChangePlayerPassword""iss"playerid,name,newpass);
        
format(query1sizeof(query1), "You have changed %s's password to %s"namenewpass);
        
SendClientMessage(playeridCOLOR_GREENquery1);
        new 
IRC[130];
        
format(IRCsizeof(IRC), "1,8* Admin %s (ID: %d) changed %s's password.",GetName(playerid), playeridname);
        
IRC_GroupSay(groupID"&#ZoneX"IRC);
        
IRC_GroupSay(groupIDIRC_aCHANNELIRC);
        return 
1;
    }
    else return 
ShowMessage(playeridCOLOR_YELLOW17);
}
forward ChangePlayerPassword(admincPlayer[], newpassword[]);
public 
ChangePlayerPassword(admincPlayer[], newpassword[])
{
    new 
query[320];
    
mysql_format(mysqlquerysizeof(query), "UPDATE `players` SET Password=SHA1('%s') WHERE `Username` = '%e'"newpasswordcPlayer);
    
mysql_tquery(mysqlquery);
    return 
true;

That command doesn't change the password why?
Reply
#2

Why are you using SHA1 firstly?, it's no longer secure (source).

Aren't tquery's supposed to be threaded? IE: Called outside of the function.
Reply
#3

Let me just circumvent the entire question by saying that this is bad practice. Admins (and other people for that matter) have no business with a player's password. If a player forgets his password you generate a new random password and you mail it to the e-mail address that you have on file. Then the player can login with that temporary password and set a new password himself by conventional means.

Also never broadcast a password in plain text. There's a reason that you see dots or asterisks when typing a password. It's so people reading over your shoulder can't see your password. If you then loudly announce in the chat "you have changed your password to "MyBrotherIsAnIdiot"" then those people will have a nice conversation.
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
Let me just circumvent the entire question by saying that this is bad practice. Admins (and other people for that matter) have no business with a player's password. If a player forgets his password you generate a new random password and you mail it to the e-mail address that you have on file. Then the player can login with that temporary password and set a new password himself by conventional means.

Also never broadcast a password in plain text. There's a reason that you see dots or asterisks when typing a password. It's so people reading over your shoulder can't see your password. If you then loudly announce in the chat "you have changed your password to "MyBrotherIsAnIdiot"" then those people will have a nice conversation.
ok ty for informations but now that problem is same changing password is not working even if i will make it only for players to change their passwords
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)