19.05.2018, 05:20
Is there any way to pass this code to sql?
Yes, my question is something stupid, but i do not know anything about mysql.
Yes, my question is something stupid, but i do not know anything about mysql.
Код:
stock LoadTop10() { new Query[128]; mysql_format(mysql, Query, sizeof(Query), "SELECT * FROM `players` ORDER BY `score` DESC LIMIT 10 "); //not tested, might need to fix the query mysql_function_query(mysql, Query, false, "LoadScores", "", ""); //init the load scores function with no cache return 1; // returning the function true } public LoadScores() { new rows, fields; cache_get_data(rows, fields, mysql); //returning all 10 players & all their rows/fields if(rows)//if there are rows to be retrived continue { for(new i = 0; i < rows; i++) //loop through all the found rows and pull the following { new dest[24], score; cache_get_row(i, "pName", dest); //get all the player names pulled from the query score = cache_get_row_int(i, "score"); //pull all the scores from the rows retrived printf("top 10 players are %s wtih scores of %d", dest, scores); //print the result when ever LoadScores is called. } else { printf("There are no players saved with score.."); //if there were no rows found in the query called in LoadTop10 //escape ect.. } return 1; }