Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new QUERY_1; // Store the result ID
- stock DoSomeQuery()
- {
- mysql_query("SELECT * FROM Profiles", QUERY_1); // Assigns this query resultid to QUERY_1
- }
- public OnQueryFinish(query[], resultid)
- {
- if(resultid == QUERY_1)
- {
- // the SELECT query has finished!
- // Carry on with the code.
- }
- }
- //-----------------------------------------------------------------------------------
- // Another example
- #define PLAYER_SAVE_PROCESS_INITIAL 0
- #define PLAYER_SAVE_PROCESS_MIDDLE 1
- #define PLAYER_SAVE_PROCESS_COMPLETE 2
- stock SavePlayerData(playerid, process)
- {
- // Okay, if the process is 0 the save has only just begun
- if(process == PLAYER_SAVE_PROCESS_INITIAL)
- {
- // Do the first query
- mysql_query("INSERT banned INTO Profiles WHERE PlayerName = 'Jay'", PLAYER_SAVE_PROCESS_INITIAL);
- }
- // 2nd query in todays function
- else if(process == PLAYER_SAVE_PROCESS_MIDDLE)
- {
- mysql_query("INSERT active INTO Profiles WHERE PlayerName = 'Jay'", PLAYER_SAVE_PROCESS_MIDDLE);
- }
- // And the final query and we're done here!
- else if(process == PLAYER_SAVE_PROCESS_COMPLETE)
- {
- mysql_query("DROP Table Profiles"); // No need to thread it because we're not executing any more code.
- }
- }
- public OnQueryFinish(query[], resultid)
- {
- // The first query in SavePlayerData
- // Now we do the second one!
- if(resultid == PLAYER_SAVE_PROCESS_INITAL)
- {
- SavePlayerData(playerid, PLAYER_SAVE_PROCESS_MIDDLE);
- }
- else if(resultid == PLAYER_SAVE_PROCESS_MIDDLE)
- {
- // 2nd query is done! Now proceed to the last and we're done!
- SavePlayerData(playerid, PLAYER_SAVE_PROCESS_COMPLETE);
- }
- // I know I know, could've just used SavePlayerData(playerid, resultid + 1)
- // but you get the idea!
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement