09.03.2015, 22:14
pawn Код:
// somewhere
new query[100];
format(query, sizeof(query), "SELECT * FROM `players` WHERE `Premium` > 0 AND `Online` = 0");
mysql_tquery(MySQL, query, "OnPremiumDepleteResponse", "");
pawn Код:
public OnPremiumDepleteResponse()
{
new numrows = cache_get_row_count();
if(numrows)
{
new tmpstring[5], intval, userid;
new rows, field, idx;
cache_get_data(rows, field);
while(idx >= rows)
{
cache_get_field_content(idx, "UserID", tmpstring, sizeof(tmpstring)), userid = strval(tmpstring));
cache_get_field_content(idx, "VIPExpire", tmpstring, sizeof(tmpstring));
intval = strval(tmpstring);
intval--;
new query[125];
format(query, sizeof(query), "UPDATE `players` SET `Expire` = '%d' WHERE `UserID` = '%d'", intval, userid);
mysql_tquery(MySQL, query, "", "");
idx++;
}
}
return 1;
}