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



Change password - _GHT_MarK445 - 11.03.2015

Hi guys,

First of all, i am using a register system by Kush, hope you all know, where you can find it, in tutorials, it is one of the most popular ones.

Anyways, i need to know, how to make a command, for chaning password. I know there is some hash, but.. i was not enable to get a soultion even when i was looking to the login dialogs. I understand almost everything in the register system except this thing, couse the hash is little too weird for me.

So, i need to get some help from you guys, how can i enable player, to change his password. I know how to make command and everything, but i dont know, how to change the password itself.. because it is hashed.

Thanks.


AW: Change password - Kaliber - 11.03.2015

Just like this:

Код:
CMD:changepw(playerid, params[]) {
    if(!params[0]) return SendClientMessage(playerid,-1,"Please enter a password!");
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Password",udb_hash(params));
    INI_Close(File);
    return SendClientMessage(playerid,-1,"Password changed successfully!");
}
Greekz


Respuesta: AW: Change password - JuanStone - 11.03.2015

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
Just like this..
You should ask for a little more information before commenting on, still-that your code works it is possible to enter a password longer than the string that the burden, this would cause errors.

If the player is turned off and the password is saved each that a player leaves the server will not effect the command already that the string "password" will remain the same.

@GHT_MarK445

If you have a variable to identify the users who have logged in you could display it in order to do its command ?. Otherwise, in case of not being registered would create a file with the password only and if you were not registered and logged users change the password of the player.

You could have multiple problems, this is serious, a single error and a player and discover it may need to change the password of all the players and log in with the accounts, by the way, you are still using the hash or eliminated ?.


AW: Respuesta: AW: Change password - Kaliber - 11.03.2015

Quote:
Originally Posted by JuanStone
Посмотреть сообщение
it is possible to enter a password longer than the string that the burden, this would cause errors.
No...because it get hashed to 32 chars

So even if he tip 118 chars (max length he can tip) ...it would be all fine


Re: Change password - _GHT_MarK445 - 11.03.2015

Well, thank you Kaliber!

Juan - I dont really understand you, i am sorry.. i am like not the best in english yet.

I just want to ask, how can i insert IF, for password length. For example from 3 to 15 characters, thank you guys!


AW: Re: Change password - Kaliber - 11.03.2015

Quote:
Originally Posted by _GHT_MarK445
Посмотреть сообщение
I just want to ask, how can i insert IF, for password length. For example from 3 to 15 characters, thank you guys!
Then write it like this:

Код:
CMD:changepw(playerid, params[]) {
    if(!params[0]) return SendClientMessage(playerid,-1,"Please enter a password!");
    if(!(2 < strlen(params) < 16)) return SendClientMessage(playerid,-1,"Your password must be longer then 3 and smaller then 15 chars!");
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Password",udb_hash(params));
    INI_Close(File);
    return SendClientMessage(playerid,-1,"Password changed successfully!");
}
Greekz


Re: Change password - _GHT_MarK445 - 11.03.2015

Can you please explain me that script, that i will understand, what i am adding to my gamemode?

I dont want just copy & paste it, i want help, that i can learn it, and be enable to make it without any forums in future.


AW: Change password - Kaliber - 11.03.2015

Well...okay:

Код:
if(!params[0])
Thats checks the NULL Byte..so when \0 is at the cell 0..the string is empty

Код:
if(!(2 < strlen(params) < 16))
That checks the string length...should be obvious

Then just read the tutorial

You open the file with Yini and set the password

Thats no magic at all


Respuesta: Change password - JuanStone - 11.03.2015

PHP код:
CMD:changepass(playeridparams[])
{
    if(!
fexist(UserPath(playerid))) //We checked if you are registered, if it is not would create a file with the password but would have no statistics:
        
return SendClientMessage(playerid, -1,"You need to be registred in first.");
    if(
isnull(params)) // We note that the text you entered is not null.
        
return SendClientMessage(playerid, -1,"USAGE: /changepass [new pass]");
    if(
strlen(params) < || strlen(params) > 15// We note that the text entered is 3 to 15 characters.
        
return SendClientMessage(playerid, -1"Leght the new password incorrect, min 3 characters, max 15.");
    
SendClientMessage(playerid, -1"You hace successfully changed your password."); // message password changed successfully.
    
new INI:File INI_Open(UserPath(playerid)); // Open file the player.
    
INI_SetTag(File,"data"); // set tag data if exist write tag.
    
INI_WriteInt(File,"Password"udb_hash(params)); // write new password.
    
INI_Close(File); // close file.
    
return true// end command.

The code that left @Kaliber would create one file and change the password to a player that is not registered. Forgive me for my bad english, i'm sorry, my native language is another but i try to do my best, sorry .


AW: Respuesta: Change password - Kaliber - 11.03.2015

Quote:
Originally Posted by JuanStone
Посмотреть сообщение
The code that left @Kaliber would create one file and change the password to a player that is not registered.
What the fuck are you talking about?!

Thats just not true!

Because his Login System is made with this system so he is registred & logged in anyway...

And your Code do the same...with a slower Code...