#1

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);
        return 
1;
    }
    else return 
ShowMessage(playeridCOLOR_YELLOW17);

In game when i try to set some one password he can also use the old one how?
Reply
#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
#3

Quote:
Originally Posted by Meller
Посмотреть сообщение
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.
Could you explain the last part you have added also iam getting error

Код:
format(pData[playerid][Password], sizeof(Password), "%s", hash1);

D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(3058) : error 039: constant symbol has no size
Reply
#4

Replace sizeof(Password) with the cell usage of Password, it should be easy to find if you actually know what you're doing:

Go to the enum you're storing the player variables at and look for Password[cells], take that cell number and replace it with sizeof(..)
Reply
#5

Quote:
Originally Posted by Meller
Посмотреть сообщение
Replace sizeof(Password) with the cell usage of Password, it should be easy to find if you actually know what you're doing:

Go to the enum you're storing the player variables at and look for Password[cells], take that cell number and replace it with sizeof(..)
done, also the same problem password doesn't change
Reply
#6

Or create a define MAX_PASS_SIZE and use that for any and all of your password strings.


Just rather than putting in [34] in to code, to find out later you need to change it somewhere and because you hardcoded the value rather than making something like this, you have more bugs and confusion.


I'm just gonna say, are you sure the password set feature is actually working?
Reply
#7

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Or create a define MAX_PASS_SIZE and use that for any and all of your password strings.


Just rather than putting in [34] in to code, to find out later you need to change it somewhere and because you hardcoded the value rather than making something like this, you have more bugs and confusion.


I'm just gonna say, are you sure the password set feature is actually working?
I'm just gonna say, are you sure the password set feature is actually working?
No.
Reply
#8

What I'm more hinting at, is the login system actually accepting all passwords, and not just the ones you are using here.

The first 2 lines of my response were in response to Mellers suggestion to use hardcoded sizes for the string. (Make define of MAX_PASS_SIZE)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)