26.06.2013, 15:09
Hello, how can i make an changepass cmd with YINI i tried everything and nothing works.
CMD:password(playerid,params[]) { new Old[32],New[32],string[128]; if(sscanf(params, "ss", old,new)) return SendClientMessage(playerid, CO_IVORY, "Command: /passowrd old new"); else if(strlen(old) != pInfo[playerid][Your Pass Variable])) return SendClientMessage(playerid, CO_IVORY, "The old password is incorrect"); else if(strlen(old) < 4 || strlen(old) > 32) return SCM(message with characters 4 - 10); else if(strlen(old) == strlen(new)) SCM(message with old is new); else { new INI:File = INI_Open(YourPath(playerid)); INI_SetTag(File,"Player Info"); INI_WriteInt(File,"Password",new); INI_Close(File); } return 1; }
CMD:password(playerid, params[]) { new New[50], Old[50],Password[129]; if(sscanf(params, "s[50]s[50]", OldPass, NewPass))return SendClientMessage(playerid, COLOR_WHITE, "cmd: old new"); else if(strcmp(old, yourvariable, false) != 0)return SendClientMessage(playerid, COLOR_RED, "old pass is bad"); else if(strlen(New) < 4 || strlen(New) > 15)return SendClientMessage(playerid, COLOR_RED, "4 - 15."); else { new INI:file = INI_Open(Your path(playerid)); INI_WriteString(file, "Password",strlen(New)); // try with strlen or not INI_Close(file); } return 1; }
CMD:changepass(playerid, params[])
{
new player[MAX_PLAYER_NAME],string[256]; // the player name, // and the string for the path
if(sscanf(params, "s[256]", parms))return SendClientMessage(playerid, -1, "/changepassword [password]");//sscanf, what ever u write after /change
format(string, 256, "/%s.ini", player);//put ur ini path here but keep the player
new INI:file = INI_Open(string); // opening the path
INI_WriteString(file, "Password", params);//writing in the path
INI_Close(file);// close the file
return 1;
}
CMD:changepass(playerid, params[])
{
new player[MAX_PLAYER_NAME],string[256], hashpass[129]; // the player name, // and the string for the path
if(sscanf(params, "s[32]s[50]", player, params))return SendClientMessage(playerid, -1, "/changepassword [password]");//sscanf, what ever u write after /change
format(string, 256, "/%s.ini", player);//put ur ini path here but keep the player
new INI:file = INI_Open(string); // opening the path
WP_Hash(hashpass,sizeof(hashpass),params);
INI_WriteString(file, "Password", hashpass);//writing in the path
INI_Close(file);// close the file
return 1;
}
/*
Okay Here what is wrong
*/
INI_WriteString(file, "Password", hashpass);//writing in the path
/* Why is it so hard to see you have two different variabls one is password the other is pPasspword
so change this line to
INI_WriteString(file, "pPassword", hashpass);//writing in the path
*/
CMD:changepass(playerid, params[])
{
new string[256], hashpass[129], playername[MAX_PLAYER_NAME]; // the player name, // and the string for the path
if(sscanf(params, "s[256]", params))return SendClientMessage(playerid, -1, "/changepass [password]");//sscanf, what ever u write after /change
GetPlayerName(playerid, sizeof(playername), playername);
format(string, 256, "/Users/%s.ini", playername);//put ur ini path here but keep the player
new INI:file = INI_Open(string); // opening the path
WP_Hash(hashpass,sizeof(hashpass),params);
INI_SetTag(file,"data");
INI_WriteString(file, "pPassword", hashpass);//writing in the path
INI_Close(file);// close the file
return 1;
}
CMD:changepass(playerid, params[])
{
new player[MAX_PLAYER_NAME],string[256], hashpass[129]; // the player name, // and the string for the path
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You Are Not Rcon"); // make sure online admins can do this cause this is to change any play password
if(sscanf(params, "s[32]s[50]", player, params))return SendClientMessage(playerid, -1, "/changepass [Username] [password]");//sscanf, what ever u write after /change
format(string, 256, "/Users/%s.ini", player);//put ur ini path here but keep the player
new INI:file = INI_Open(string); // opening the path
WP_Hash(hashpass,sizeof(hashpass),params);
INI_SetTag(file,"data");
INI_WriteString(file, "pPassword", hashpass);//writing in the path
INI_Close(file);// close the file
return 1;
}
new hashpass[129],string[200];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
new INI:File = INI_Open(Path(playerid));
INI_SetTag(File,"Player's Info");
INI_WriteString(File,"Password", hashpass);
INI_Close(File);
SCM(playerid,COLOR_LIGHTBLUE,"You've successfully changed your password");
format(string,200,"[AdmWarn]: %s has changed his password",GetName(playerid));
SAM(string);