Advertisement
Guest User

Untitled

a guest
Apr 19th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. forward mysql_PromoCheck(playerid,code[]);
  2. public mysql_PromoCheck(playerid,code[])
  3. {
  4. new rows,fields;
  5. cache_get_data(rows, fields);
  6. if(!rows) return SendClientMessage(playerid, -1, "Промокод не обнаружен");
  7.  
  8. static const fmt_str[] = "SELECT `date` FROM `promo_activate` WHERE `name` = '%s' AND `code` = '%s'";
  9. new string[sizeof(fmt_str) + (-2 + MAX_PLAYER_NAME) + (-2 + 16)],date[32];
  10. format(string, sizeof(string), fmt_str, Name(playerid),code);
  11. new Cache:result = mysql_query(mysql, string);
  12. if(cache_get_row_count(mysql) > 0)
  13. {
  14. cache_get_row(0, 0, date, mysql);
  15. format(string,sizeof(string),"Вы уже активировали промокод '%s'. Дата активации: %s",code,date);
  16. SendClientMessage(playerid,COLOR_GREY,string);
  17. cache_delete(result, mysql);
  18. return true;
  19. }
  20.  
  21. new days,months,years,minutes,hours;
  22. getdate(years,months,days),gettime(hours,minutes);
  23. new vipka = cache_get_field_content_int(0, "vip");
  24. new money = cache_get_field_content_int(0, "money");
  25. new license = cache_get_field_content_int(0, "lic");
  26. new ludi = cache_get_field_content_int(0, "ludi");
  27.  
  28. SendClientMessage(playerid,COLOR_GREEN,"Промокод содержит:");
  29. if(vipka >= 1) SendClientMessage(playerid,COLOR_GREEN,"VIP на"),PlayerInfo[playerid][pVIP] = vipka;
  30. if(license >= 1) SendClientMessage(playerid,COLOR_GREEN,"Водительские права"),PlayerInfo[playerid][pCarLic] = 1;
  31. SendClientMessage(playerid,COLOR_GREEN,"Деньги "),GiveMoney(playerid,money);
  32.  
  33. format(string,sizeof(string),"INSERT INTO `promo_activate` (`name`,`promo`,`date`) VALUES ('%s','%s','%02d.%02d.%04d %02d:02d')",Name(playerid),code,days,months,years,hours,minutes);
  34. mysql_function_query(mysql, string, false, "", "");
  35.  
  36. ludi --;
  37. format(string,sizeof(string),"UPDATE `promo` SET `ludi` = '%d' WHERE `code` = '%s'",ludi,code);
  38. mysql_function_query(mysql, string, false, "", "");
  39. if(ludi == 0)
  40. {
  41. format(string,sizeof(string), "DELETE FROM `promo` WHERE `code`='%s'", code);
  42. mysql_function_query(mysql, string, false, "", "");
  43. }
  44. if(gettime() >= cache_get_field_content_int(0, "data") && ludi == 0)
  45. {
  46. format(string,sizeof(string), "DELETE FROM `promo` WHERE `code`='%s'", code);
  47. mysql_function_query(mysql, string, false, "", "");
  48. }
  49. return cache_delete(result, mysql);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement