Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- forward mysql_PromoCheck(playerid,code[]);
- public mysql_PromoCheck(playerid,code[])
- {
- new rows,fields;
- cache_get_data(rows, fields);
- if(!rows) return SendClientMessage(playerid, -1, "Промокод не обнаружен");
- static const fmt_str[] = "SELECT `date` FROM `promo_activate` WHERE `name` = '%s' AND `code` = '%s'";
- new string[sizeof(fmt_str) + (-2 + MAX_PLAYER_NAME) + (-2 + 16)],date[32];
- format(string, sizeof(string), fmt_str, Name(playerid),code);
- new Cache:result = mysql_query(mysql, string);
- if(cache_get_row_count(mysql) > 0)
- {
- cache_get_row(0, 0, date, mysql);
- format(string,sizeof(string),"Вы уже активировали промокод '%s'. Дата активации: %s",code,date);
- SendClientMessage(playerid,COLOR_GREY,string);
- cache_delete(result, mysql);
- return true;
- }
- new days,months,years,minutes,hours;
- getdate(years,months,days),gettime(hours,minutes);
- new vipka = cache_get_field_content_int(0, "vip");
- new money = cache_get_field_content_int(0, "money");
- new license = cache_get_field_content_int(0, "lic");
- new ludi = cache_get_field_content_int(0, "ludi");
- SendClientMessage(playerid,COLOR_GREEN,"Промокод содержит:");
- if(vipka >= 1) SendClientMessage(playerid,COLOR_GREEN,"VIP на"),PlayerInfo[playerid][pVIP] = vipka;
- if(license >= 1) SendClientMessage(playerid,COLOR_GREEN,"Водительские права"),PlayerInfo[playerid][pCarLic] = 1;
- SendClientMessage(playerid,COLOR_GREEN,"Деньги "),GiveMoney(playerid,money);
- 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);
- mysql_function_query(mysql, string, false, "", "");
- ludi --;
- format(string,sizeof(string),"UPDATE `promo` SET `ludi` = '%d' WHERE `code` = '%s'",ludi,code);
- mysql_function_query(mysql, string, false, "", "");
- if(ludi == 0)
- {
- format(string,sizeof(string), "DELETE FROM `promo` WHERE `code`='%s'", code);
- mysql_function_query(mysql, string, false, "", "");
- }
- if(gettime() >= cache_get_field_content_int(0, "data") && ludi == 0)
- {
- format(string,sizeof(string), "DELETE FROM `promo` WHERE `code`='%s'", code);
- mysql_function_query(mysql, string, false, "", "");
- }
- return cache_delete(result, mysql);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement