Use the sql table with all you coupon
You have to delete the row in the script :
query_sql "DELETE FROM `coupons` WHERE `code`='"+@my_code$+"'";
query_sql "SELECT `code`, `item_id`, `item_amount` FROM `coupons`", .@available_code$, .@available_item, .@available_amount;
for (set @i, 0; @i < getarraysize(.@available_code$); set @i, @i+1)
{
if(@my_code$==.@available_code$[@i])
{
mes "[^FF7700Coupon Jack^000000]";
mes "You get ^0000FF" + getitemname(.@available_item[@i]) + " - " + .@available_amount[@i] + " ea.^000000";
getitem .@available_item[@i],.@available_amount[@i];
//announce "Coupon Jack: " + strcharinfo(0) + " got " + .@available_amount[@i] + getitemname(.@available_item[@i]) + "(s).",0;
close;
}
}
And for IP verification : create an other table (code of coupon,player ip), you can have player ip by checking the login table :
query_sql "SELECT `last_ip` FROM `login` WHERE `account_id` = "+getcharid(3)+"", .@IP;
You can do that for both account_id or ip, like you want
And you fill the new table with a query ; INSERT INTO
After you just have to check if the player already used his coupon