Mysql
#2

PHP код:
CMD:setpassword(playeridparams[]) 

    if(
pData[playerid][Admin] >= 7
    { 
        new 
query[320], name[24], newpass[34], hash1[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"); 
        
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); 
        
WP_Hash(hash1129newpass); 
        
mysql_format(mysqlquerysizeof(query), "UPDATE `players` SET `Password` = '%s' WHERE `Username` = '%e'"hash1name); 
        
mysql_tquery(mysqlquery); 
        new 
name2[MAX_PLAYER_NAME];
        for(new 
targetid 0maxid GetPlayerPoolSize(); targetid <= maxidtargetid++) {
            if(
IsPlayerConnected(targetid)) {
                
GetPlayerName(targetidname2MAX_PLAYER_NAME);
                if(!
strcmp(namename2)) {
                    
//Player is online, set his password variable to new password, example:
                    
format(pData[playerid][Password], sizeof(Password), "%s"hash1);
                    break;
                }
            }
        }
        return 
1
    } 
    else return 
ShowMessage(playeridCOLOR_YELLOW17); 

You must set his variable to the new has aswell if he's online, otherwise when he log out, it'll save the old one.
Reply


Messages In This Thread
Mysql - by Loinal - 03.07.2017, 22:54
Re: Mysql - by Meller - 03.07.2017, 23:07
Re: Mysql - by Loinal - 03.07.2017, 23:10
Re: Mysql - by Meller - 03.07.2017, 23:13
Re: Mysql - by Loinal - 03.07.2017, 23:24
Re: Mysql - by Sew_Sumi - 03.07.2017, 23:26
Re: Mysql - by Loinal - 03.07.2017, 23:33
Re: Mysql - by Sew_Sumi - 04.07.2017, 00:29

Forum Jump:


Users browsing this thread: 1 Guest(s)