Jump to content
  • 0

Coupon / Promo Code


Question

Posted

I need a npc that if you will designate a specific code. 

Example the code is "jdsa41jd" and if a player put that code on the npc he will receive a specific Item(s) 

(Can only be used 1 per IP or 1 Per Account)

5 answers to this question

Recommended Posts

Posted (edited)

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

Edited by Shakto

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...