21.07.2017, 17:57
PHP код:
CMD:setpassword(playerid, params[])
{
if(pData[playerid][Admin] >= 7)
{
new query[320], name[24], newpass[34],query1[320];
if(sscanf(params, "s[24]s[34]", name, newpass)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setpassword <PlayerName> <NewPassword>");
if(!AccountExists(name)) return SendClientMessage(playerid, red, "Account does not exists");
mysql_format(mysql, query, sizeof(query),"SELECT `Password` FROM `players` WHERE `Username` = '%e'");
mysql_tquery(mysql,query);
mysql_tquery(mysql, query, "ChangePlayerPassword", "iss", playerid,name,newpass);
format(query1, sizeof(query1), "You have changed %s's password to %s", name, newpass);
SendClientMessage(playerid, COLOR_GREEN, query1);
new IRC[130];
format(IRC, sizeof(IRC), "1,8* Admin %s (ID: %d) changed %s's password.",GetName(playerid), playerid, name);
IRC_GroupSay(groupID, "&#ZoneX", IRC);
IRC_GroupSay(groupID, IRC_aCHANNEL, IRC);
return 1;
}
else return ShowMessage(playerid, COLOR_YELLOW, 1, 7);
}
forward ChangePlayerPassword(admin, cPlayer[], newpassword[]);
public ChangePlayerPassword(admin, cPlayer[], newpassword[])
{
new query[320];
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET Password=SHA1('%s') WHERE `Username` = '%e'", newpassword, cPlayer);
mysql_tquery(mysql, query);
return true;
}