Advertisement
Guest User

Untitled

a guest
May 26th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.75 KB | None | 0 0
  1.  
  2. new QUERY_1;        // Store the result ID
  3.  
  4.  
  5.  
  6. stock DoSomeQuery()
  7. {
  8.     mysql_query("SELECT * FROM Profiles", QUERY_1); // Assigns this query resultid to QUERY_1
  9. }
  10.  
  11. public OnQueryFinish(query[], resultid)
  12. {
  13.     if(resultid == QUERY_1)
  14.     {
  15.         // the SELECT query has finished!
  16.         // Carry on with the code.
  17.     }
  18. }
  19.  
  20.  
  21. //-----------------------------------------------------------------------------------
  22. // Another example
  23.  
  24. #define PLAYER_SAVE_PROCESS_INITIAL     0
  25. #define PLAYER_SAVE_PROCESS_MIDDLE      1
  26. #define PLAYER_SAVE_PROCESS_COMPLETE    2
  27.  
  28. stock SavePlayerData(playerid, process)
  29. {
  30.     // Okay, if the process is 0 the save has only just begun
  31.     if(process == PLAYER_SAVE_PROCESS_INITIAL)
  32.     {
  33.         // Do the first query
  34.         mysql_query("INSERT banned INTO Profiles WHERE PlayerName = 'Jay'", PLAYER_SAVE_PROCESS_INITIAL);
  35.     }
  36.    
  37.     // 2nd query in todays function
  38.     else if(process == PLAYER_SAVE_PROCESS_MIDDLE)
  39.     {
  40.         mysql_query("INSERT active INTO Profiles WHERE PlayerName = 'Jay'", PLAYER_SAVE_PROCESS_MIDDLE);
  41.     }
  42.    
  43.     // And the final query and we're done here!
  44.     else if(process == PLAYER_SAVE_PROCESS_COMPLETE)
  45.     {
  46.         mysql_query("DROP Table Profiles"); // No need to thread it because we're not executing any more code.
  47.     }
  48. }
  49.  
  50. public OnQueryFinish(query[], resultid)
  51. {
  52.     // The first query in SavePlayerData
  53.     // Now we do the second one!
  54.     if(resultid == PLAYER_SAVE_PROCESS_INITAL)
  55.     {
  56.         SavePlayerData(playerid, PLAYER_SAVE_PROCESS_MIDDLE);
  57.     }
  58.  
  59.  
  60.     else if(resultid == PLAYER_SAVE_PROCESS_MIDDLE)
  61.     {
  62.         // 2nd query is done! Now proceed to the last and we're done!
  63.         SavePlayerData(playerid, PLAYER_SAVE_PROCESS_COMPLETE);
  64.     }
  65.    
  66.     // I know I know, could've just used SavePlayerData(playerid, resultid + 1)
  67.     // but you get the idea!
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement