Advertisement
Guest User

SAMP example 2

a guest
Jun 17th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.22 KB | None | 0 0
  1. // Inside admin system (the functions are bellow):
  2. static load_id;
  3. hook OnGameModeInit()
  4. {
  5.     load_id = AddLoginData("SELECT admin FROM admins WHERE id=%i", "i");
  6.     return 1;
  7. }
  8. hook OnPlayerLoad()
  9. {
  10.     cache_set_result(load_id);
  11.  
  12.     cache_get_value_name_int(0, "admin", AdminLevel[playerid]);
  13.     if(AdminLevel[playerid] > 0)
  14.         Iter_Add(admins, playerid);
  15.     return 1;
  16. }
  17.  
  18. //Functions used:
  19. static queries;
  20. static formatted_QUERY[4096];
  21. static Functions[500];
  22. AddLoginData(q[], func[])
  23. {
  24.     strcat(formatted_QUERY, q);
  25.     strcat(Functions, func);
  26.     return queries++;
  27. }
  28.  
  29. hook OnUserFound(playerid)
  30. {
  31.     new values[500];
  32.     for(new i = 0; Functions[i]; i++)
  33.     {
  34.         switch(Function[i])
  35.         {
  36.             case 'i': values[i] = GetPlayerId(playerid);
  37.             case 't': values[i] = gettime();
  38.             default: printf("forgot to add some functions? (%c)", Function[i]);
  39.         }
  40.     }
  41.  
  42.     new q[4096];
  43.     format(q, sizeof(q), formatted_QUERY, /* ?? */ ) // Pass values here
  44.  
  45.     mysql_pquery(db, q, "_load_User_data", "ii", playerid, PlayerChecker[playerid]);
  46.     return 1;
  47. }
  48. forward _load_User_data(playerid, checker);
  49. public _load_User_data(playerid, checker)
  50. {
  51.     // check for race condition here
  52.  
  53.     CallLocalFunction("OnPlayerLoad", "i", playerid);
  54.     return 1;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement