/Changename command & /Changepassword
#4

PHP код:
#include <a_samp>
#include <zcmd>
#include <YSI\y_ini>
#include <sscanf>
#define HASH // Put '//' in front of define if you don't want a hash for your password ..
// udb_hash can be modified with your hasher if you have another one (if you don't have one you need to put '//' in front of define)
#define TAG // Put '//' if you don't use a tag where you save password.
 #if defined HASH
udb_hash(buf[]) // By darcoblue | Password hasher .
{
    new 
s1=1s2;
    for(new 
nn<strlen(buf); n++) { s1 = (s1 buf[n]) % 65521s2 = (s2 s1)     % 65521; }
    return (
s2 << 16) + s1;
}
 
#endif
CMD:changepassword(playeridparams[])
{
    new 
pPass[16], pName[32]; // some news ..
    
GetPlayerName(playeridpNamesizeof(pName)); // get the player name (who typed)
    
    
if(sscanf(params,"s"pPass)) return SendClientMessage(playerid, -"/changepassword [NewPassword]"); // Return a message if parameters are null ..
    
if(strlen(pPass) < || strlen(pPass) > 15) return SendClientMessage(playerid, -1"Your new password need to be between 3 and 15 characters.");
    if(
strfind(pPass"/") != -|| strfind(pPass"\\") != -|| strfind(pPass":") != -|| strfind(pPass"*") != -||
    
strfind(pPass"?") != -|| strfind(pPass"\"") != -|| strfind(pPass"<") != -|| strfind(pPass">") != -||
    
strfind(pPass"|") != -|| strfind(pPass"@")) return SendClientMessage(playerid, -1"INVALID CHARACTERS: '/' '\' ':' '?' '\' '<' '>' '*' '|' '@'"); // Characters black list .
    
new fPath[64]; // create a string
    
format(fPathsizeof(fPath), "/Users/%s.ini"pName); // Format the fPath string array
    
new INI:File INI_Open(fPath); // a new initialiser for our INI_Open ..
    
 #if defined TAG
    
INI_SetTag(File"data"); // We set tag 'data'
 #endif
    
 #if defined HASH
    
INI_WriteInt(File"Password"udb_hash(pPass)); // Write our hashed password
 #else
    
INI_WriteString(File"Password"pPass); // Write our string password
 #endif
    
INI_Close(File); // Close the file
    
    
SendClientMessage(playerid, -1"You changed your password , at next login you need to type new password.");
    return 
1;

Reply


Messages In This Thread
/Changename command & /Changepassword - by SalmaN97 - 19.08.2015, 04:39
Re: /Changename command & /Changepassword - by ThePhenix - 19.08.2015, 04:45
Re: /Changename command & /Changepassword - by SalmaN97 - 19.08.2015, 05:31
Re: /Changename command & /Changepassword - by Mariciuc223 - 19.08.2015, 08:06
Re: /Changename command & /Changepassword - by Evocator - 19.08.2015, 08:23
Re: /Changename command & /Changepassword - by Mariciuc223 - 19.08.2015, 08:29
Re: /Changename command & /Changepassword - by SalmaN97 - 20.08.2015, 05:08
Re: /Changename command & /Changepassword - by Mariciuc223 - 20.08.2015, 06:53

Forum Jump:


Users browsing this thread: 3 Guest(s)