Setpass
#1

PHP код:
CMD:setpass(playeridparams[])
{
 if(
pData[playerid][Admin] >= 9)
 {
  new 
accname[MAX_PLAYER_NAME+2], newpass[60], str[128];
  if(
sscanf(params"s[24]s[60]"accnamenewpass))
  {
   
SendClientMessage(playeridCOLOR_ORANGE"USAGE : /setpass [Account Name] [New Password]");
   return 
SendClientMessage(playeridorange"Function : Will set a new password for the account specified as 'playername'");
  }
  if(
strlen(accname) > 24 || strlen(accname) < 0) return SendClientMessage(playeridred"ERROR : Account name out of bounds! (Character limit : 0-24)");
  if(
strlen(newpass) > 60 || strlen(newpass) < 0) return SendClientMessage(playeridred"ERROR : Password input out of bounds! (Character limit : 0-60)");
  new 
query[200];
  
format(query256"SELECT `username` FROM `players` WHERE `username` = '%s'"accname);
  
mysql_query(query);
  
mysql_store_result();
  if(
cache_num_rows() > 0)
  {
   
format(strsizeof(str), "You've successfully set '%s' as password for the account : '%s'"newpassaccname);
   
SendClientMessage(playeridCOLOR_GREENstr);
   
PlayerPlaySound(playerid10570.00.00.0);
   
format(querysizeof(query), "UPDATE `playerdata` SET password=SHA1('%s') WHERE user='%s'"newpassaccname);
   
mysql_query(query);
  }
  else if(
cache_num_rows() <= 0)
  {
  
format(strsizeof(str), "ERROR : The account named '%s' does not exist on the database!"accname);
  
SendClientMessage(playeridredstr); }
  
mysql_free_result();
 }
 else return 
SendClientMessage(playeridCOLOR_YELLOW"Sorry, Only +level 9 can use this command.");
 return 
1;

I was having a problem with that iam using mysql R41-2 but since i converted from R33 to R40 i can't convert this code also how can i find the changes?

Код:
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12681) : error 035: argument type mismatch (argument 1)
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12682) : error 017: undefined symbol "mysql_store_result"
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12689) : error 035: argument type mismatch (argument 1)
D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(12695) : error 017: undefined symbol "mysql_free_result"
Reply
#2

Just remove mysql_free_result and use ( cache_get_row_int/float )
Reply
#3

Quote:
Originally Posted by Bolex_
Посмотреть сообщение
Just remove mysql_free_result and use ( cache_get_row_int/float )
What do you mean by that?

I just need the convert from R33 to R41
Reply
#4

mysql_free_result and mysql_store_result is not available on R41.
check this out:
https://sampforum.blast.hk/showthread.php?tid=616103
Reply
#5

Quote:
Originally Posted by Dice_
Посмотреть сообщение
mysql_free_result and mysql_store_result is not available on R41.
check this out:
https://sampforum.blast.hk/showthread.php?tid=616103
So it should be??

Should i remove my codes?

If i should then can you help me create onther?
Reply
#6

Any one?
Reply
#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


Forum Jump:


Users browsing this thread: 2 Guest(s)