Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. task checkForDonations[20000]()
  2. {
  3. mysql_tquery(gSQL, "SELECT * FROM `donations` WHERE `received` = '0' AND `completed` = '1'", "checkDonations", "");
  4. return true;
  5. }
  6.  
  7. function checkDonations()
  8. {
  9. if(!cache_num_rows())
  10. return true;
  11.  
  12. for(new i = 0, j = cache_num_rows(); i != j; ++i)
  13. {
  14. gQuery[0] = (EOS);
  15. mysql_format(gSQL, gQuery, sizeof gQuery, "UPDATE `donations` SET `received` = '1' WHERE `id` = '%d'", cache_get_field_content_int(i, "id"));
  16. mysql_tquery(gSQL, gQuery, "", "");
  17.  
  18. gQuery[0] = (EOS);
  19. mysql_format(gSQL, gQuery, sizeof gQuery, "UPDATE `users` SET `GoldPoints` = `GoldPoints` + '%d' WHERE `id` = '%d' LIMIT 1", cache_get_field_content_int(i, "amount"), cache_get_field_content_int(i, "userid"));
  20. mysql_tquery(gSQL, gQuery, "giveDonation", "dd", cache_get_field_content_int(i, "userid"), cache_get_field_content_int(i, "amount"), cache_get_field_content_int(i, "id"));
  21. }
  22.  
  23. return true;
  24. }
  25.  
  26. function giveDonation(userid, amount, donationid)
  27. {
  28. new name;
  29.  
  30. cache_get_field_content(0, "name", name);
  31.  
  32. gString[0] = (EOS);
  33. format(gString, sizeof gString, "(Donation): %s [db:%d] has received %d premium points from a donation [donation:%d].", name, userid, amount, donationid);
  34. SendAdminMessage(COLOR_LOGS, gString, 5);
  35.  
  36. foreach(new x : Player)
  37. {
  38. if(PlayerInfo[x][pSQLID] == userid)
  39. {
  40. SCMex(x, COLOR_GREEN, "Ai primit %d premium points de la donatia cu numarul %d.", amount, donationid);
  41. PlayerInfo[x][pPremiumPoints] += amount;
  42. }
  43. }
  44.  
  45. return true;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement