SA-MP Forums Archive
Return query on the same function - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Return query on the same function (/showthread.php?tid=561394)



Return query on the same function - BillieJoe - 02.02.2015

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


Re: Return query on the same function - denNorske - 02.02.2015

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 ?


Re: Return query on the same function - BillieJoe - 02.02.2015

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


Re: Return query on the same function - BillieJoe - 02.02.2015

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);
    }



Re: Return query on the same function - Sime30 - 02.02.2015

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


Re: Return query on the same function - denNorske - 03.02.2015

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


Re: Return query on the same function - Abagail - 03.02.2015

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