SA-MP Forums Archive
Setpass - 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: Setpass (/showthread.php?tid=637806)



Setpass - Loinal - 21.07.2017

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?


Re: Setpass - DobbysGamertag - 21.07.2017

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.


Re: Setpass - Vince - 21.07.2017

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.


Re: Setpass - Loinal - 21.07.2017

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