Setpass
#7

pawn Код:
CMD:setpass(playerid, params[])
{
    if(pData[playerid][Admin] < 9) SendClientMessage(playerid, COLOR_YELLOW, "Sorry, Only +level 9 can use this command.");
    else
    {
        new accname[MAX_PLAYER_NAME+2], newpass[60];
        if(sscanf(params, "s[24]s[60]", accname, newpass))
        {
            SendClientMessage(playerid, COLOR_ORANGE, "USAGE : /setpass [Account Name] [New Password]");
            return SendClientMessage(playerid, orange, "Function : Will set a new password for the account specified as 'playername'");
        }
        if(!(2 < strlen(accname) < MAX_PLAYER_NAME)) SendClientMessage(playerid, red, "ERROR : Account name out of bounds! (Character limit : 3-24)");
        else if(!(2 < strlen(newpass) < 61)) SendClientMessage(playerid, red, "ERROR : Password input out of bounds! (Character limit : 3-60)");
        else
        {
            new query[256];
            format(query, sizeof(query), "SELECT `username` FROM `players` WHERE `username` = '%q' LIMIT 1;", accname);
            new Cache:result = mysql_query(MySQL:handle, query);
            query[0] = cache_num_rows();
            cache_delete(result);

            if(query[0])
            {
                format(query, 144, "You've successfully set '%s' as password for the account : '%s'", newpass, accname);
                SendClientMessage(playerid, COLOR_GREEN, query);
                PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
                format(query, sizeof(query), "UPDATE `playerdata` SET password=SHA1('%q') WHERE user='%q'", newpass, accname);
                mysql_tquery(MySQL:handle, query);
            }
            else
            {
                format(query, 128, "ERROR : The account named '%s' does not exist on the database!", accname);
                SendClientMessage(playerid, red, query);
            }
        }
    }
    return 1;
}
Reply


Messages In This Thread
Setpass - by Loinal - 14.05.2017, 07:42
Re: Setpass - by Bolex_ - 14.05.2017, 09:33
Re: Setpass - by Loinal - 14.05.2017, 10:02
Re: Setpass - by Dice_ - 14.05.2017, 10:44
Re: Setpass - by Loinal - 14.05.2017, 11:26
Re: Setpass - by Loinal - 14.05.2017, 17:30
Re: Setpass - by Jefff - 14.05.2017, 18:41

Forum Jump:


Users browsing this thread: 1 Guest(s)