Return query on the same function
#1

I wanna do something like this

pawn Код:
CMD:kick(playerid, params[])
{

    new command[8] = "cmdkick";
    new cmdlevel;

    mysql_format(Mysql_users, query, sizeof(query), "SELECT * FROM `commands` WHERE `command` = '%s'", command);
    mysql_tquery(Mysql_users, query, "", "");

    printf("%s", query);
    cmdlevel = cache_get_field_content_int(0, "adminlevel", Mysql_users);
    printf("%s", cmdlevel);

    if(PlayerData[playerid][AdminLevel] < cmdlevel) return SendUnathorizedMessage(playerid);
But after mysql_tquery it doesn't store the value and cmdlevel var is not working... I don't know how to do this on the same function. I don't want to create another function for this. Rep + for helping me to solve my problem
Reply
#2

The easiest way would be to create a new function AFAIK. But:
pawn Код:
CMD:kick(playerid, params[])
{

    new command[8] = "cmdkick";
    new cmdlevel;

    mysql_format(Mysql_users, query, sizeof(query), "SELECT * FROM `commands` WHERE `command` = '%s'", command);

    mysql_query(Mysql_users, query);
    mysql_store_result();

    new rows = mysql_num_rows(); //We get how many rows the query returned.
    if(rows)
    {
          //it found something
         printf("%s", query);
         cmdlevel = cache_get_field_content_int(0, "adminlevel", Mysql_users);
         printf("%s", cmdlevel);

         if(PlayerData[playerid][AdminLevel] < cmdlevel) return SendUnathorizedMessage(playerid);
    }
Im not 100% sure, but try using the mysql_query for this ?
Reply
#3

Seems like mysql_store_result and mysql_num_rows doesn't exist on the BlueG's R39 include
Reply
#4

Well, I don't know how but I did this way and worked

pawn Код:
new command[8] = "cmdkick";
    new cmdlevel;

    mysql_format(Mysql_users, query, sizeof(query), "SELECT * FROM `commands` WHERE `command` = '%s'", command);

    mysql_query(Mysql_users, query);

    new rows = cache_num_rows();
    if(rows) {
        cmdlevel = cache_get_field_content_int(0, "adminlevel", Mysql_users);
    }
Reply
#5

The newest release is only for threaded scripts. That means you cannot use old functions like mysql_store_result and mysql_query
Reply
#6

Quote:
Originally Posted by Sime30
Посмотреть сообщение
The newest release is only for threaded scripts. That means you cannot use old functions like mysql_store_result and mysql_query
Useful information.
Thanks for sharing
Reply
#7

You shouldn't use outdated methods such as non-threaded scripts / plugins. R39 uses threading for a reason...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)