Jump to content
  • 0

Promotionial Codes Script


uDe

Question


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  400
  • Reputation:   5
  • Joined:  12/05/11
  • Last Seen:  

Nice little promotion script.

i have tested it. then a player can spam it!

Posted 28 March 2013 - 09:14 PM - no answer?

here's a little edit, i hope it's okay Arzzzae

http://pastebin.com/TY4cPbS0

http://pastebin.com/q2eKrzhf

 

ORIGINAL THREAD : http://goo.gl/e1LGXT

 

I'm using this script and maybe found some bugs.

1. No update on reward_codes.sql

UzGOu0N.jpg

but I think rewardlogs.sql just doing fine.

2. Referring to SS above, there are 2 codes has been given. But there's no update also when I use "View existing codes" in-game.

SuDctTt.jpg

3.

After ADMIN use @code > setup the code > finish. He can't move, seems like stuck with npc. Need to @load or @go. I found no problems with @claim commands.

Note :

  • I have restart the server after adding the script.
  • I also has tried topic starter script and found all those bug mentioned by other members.
Edited by uDe
Link to comment
Share on other sites

16 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  38
  • Topics Per Day:  0.01
  • Content Count:  276
  • Reputation:   24
  • Joined:  07/06/13
  • Last Seen:  

It's mean that only 1 person per item and the code still can be use by other players. Personally for me, this is an another way to distribute rewards for players instead of talking to NPC.

 

For example, I'm going to use this script to promote my server at facebook and I just need to use 1 code only. Instead of giving 100+ codes. And don't worry, I won't give any trade-able items to prevent players to exploit this codes by creating new characters on their ID. It's good to have an option though..

 

Thanks for the opinion by the way. Still, I would really need that function.  /kis2

I did all what you like! And I added more features!

 

I edit the whole script modified by sir patskie, took me almost 12hours LOL! New milestone achievement for me, I can finally manage to mess with SQL-Thingy! :)

 

Visit the post. :)

 

http://rathena.org/board/topic/87212-utility-promotional-code/

Edited by Lil Troll
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  50
  • Topics Per Day:  0.01
  • Content Count:  1702
  • Reputation:   238
  • Joined:  09/05/12
  • Last Seen:  

Try this one : 

//===== Custom Script ========================================
//= Promotional Codes
//===== By: ==================================================
//= Arzzzae
//===== Current Version: =====================================
//= 1.0
//===== Compatible With: =====================================
//= Latest svn
//===== Description: ========================================= 
//= Adds 2 custom atcommands. @claim for players to claim
//= promotional code created by Game Masters. @code is for
//= administrators to add/view/delete promotional codes.
//===== Additional Comments: ================================= 
//= 1.0 - Initial Release.
//============================================================


-    script    promoclaim    -1,{




OnInit:
    bindatcmd "claim",strnpcinfo(3)+"::OnClaim";
    bindatcmd "code",strnpcinfo(3)+"::OnEditCode",99,0;
    end;
    
OnClaim:


    mes "^FF0000 Enter a new promotional code.";
    input .@pc$;
    close2;
    


                if ( query_sql("SELECT nameid,amount FROM `reward_codes` WHERE `code`='"+escape_sql(.@pc$)+"'", .@item,.@amt) == 0) {
                    dispbottom "Invalid promotional code.";
                    end;
            
                    }
                    
                else if (query_logsql("SELECT code,account_id FROM `rewardlogs` WHERE `code`='"+escape_sql(.@pc$)+"' AND `account_id`='"+getcharid(3)+"'")) {
                    dispbottom "You already claimed this promotional code.";
                    end;
                    
                    }


                else {
                    getitem .@item,.@amt;
                    dispbottom "Promotional code successfuly redeemed.";
                    query_logsql("INSERT INTO `rewardlogs` (code,redeem_time,account_id) VALUES ('"+.@pc$+"', NOW(), '"+getcharid(3)+"')");
                    query_sql("DELETE FROM `reward_codes` WHERE `code` = '" +escape_sql(.@pc$)+ "'");
                    end;
                    }
    
        
    
OnEditCode:
    
    menu "Setup a new promotional code",ncode,"View existing codes",vcode,"Delete exisiting codes",dcode,"Cancel",cancel;
    
    ncode:
        
        set .@clength,10; //Promotional Code Length
        
        input .@pcode$;
        
            if (getstrlen(.@pcode$)!=.@clength) {
                dispbottom "Codes must be 10 characters long.";
                end;
                }
                
            mes "You have entered ^FF0000"+.@pcode$+"^000000 as the code.";
            mes "Are you sure?";
            next;
            if(select("Yes:No, thanks")==2) close;
            
            query_sql ("SELECT COUNT(code) FROM `reward_codes` WHERE `code`='"+escape_sql(.@pcode$)+"'", .@pcode_exists);
            if (.@pcode_exists) {
                dispbottom "Sorry, that code already exist.";
                end;
            }
            
            mes "Please set a reward for the players who has entered the code.";
            input .@reward;
            next;
            
            if (.@reward == 0) {
                dispbottom "Sorry, that is an invalid item id.";
                close;
            }
            
            set .@iname$, getitemname(.@reward);
            mes "Item number ^FF0000"+.@reward+"^000000";
            mes "is equivalent to ^FF0000"+.@iname$+"^000000.";
            mes "Are you sure?";
            next;
            if(select("Yes:No, thanks")==2) close;
            
            
            mes "How many ^FF0000"+.@iname$+"^000000.?";
            input .@amount;
            next;
            
            if (.@amount == 0) {
                dispbottom "Sorry, that is an invalid amount number.";
                close;
            }
            
            mes "Are you sure?";
            next;
            if(select("Yes:No, thanks")==2) close;
            
            query_sql ("INSERT INTO `reward_codes` (code,nameid,item_name,amount,time_created) VALUES ('"+.@pcode$+"', "+.@reward+", '"+.@iname$+"', "+.@amount+", NOW())");
            dispbottom "Promotional Code ^FF0000"+.@pcode$+" ^000000is now activated and the reward is ^FF0000"+.@amount+" "+.@iname$+".";
            end;
    
    vcode:
    
        set .@nb, query_sql("SELECT code, item_name, amount FROM `reward_codes` ORDER BY time_created DESC LIMIT 20", .@code$, .@nid$, .@amount);    
        
            if (.@nb == 0) {
            dispbottom "No exisiting codes.";
            end;
            }
        
            dispbottom "=============================================";
            dispbottom "==============  EXISITING CODES  ==============";
            dispbottom "=============================================";
            for(set .@i,0; .@i < .@nb; set .@i,.@i+1)
            dispbottom ""+.@code$[.@i]+" (  Reward: "+.@amount[.@i]+" "+.@nid$[.@i]+"  )";
            dispbottom "=============================================";
            end;
            
    dcode:
    
        input .@dcode$;
        
            query_sql ("SELECT COUNT(code) FROM `reward_codes` WHERE `code`='"+escape_sql(.@dcode$)+"'", .@pcode_exists);
            if (.@pcode_exists) {
                mes "Would you like to delete that code?";
                next;
                if(select("Yes:No, thanks")==2) close;
                
                query_sql ("DELETE FROM `reward_codes` WHERE `code`='"+escape_sql(.@dcode$)+"'");
                dispbottom "Promotional code successfuly deleted.";
                close;
            }
            
            dispbottom "Promotional code not found.";
            end;
    
    cancel:
        close;
}
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  400
  • Reputation:   5
  • Joined:  12/05/11
  • Last Seen:  

Thanks for your help @Patskie..

 

But I don't think there's any changes in game because it's still the same.. No update on reward_codes.sql for redeem time, accound id and confirmed column.

Seems like all 3 problems I had above still occurs.

 

1fnIsGV.jpg

 

This is the previous script that I've used :promo_code_ori.txt

 

And this is yours : promo_code_patskie.txt

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2347
  • Joined:  10/28/11
  • Last Seen:  

query_logsql("INSERT INTO `rewardlogs` (code,redeem_time,account_id) VALUES ('"+.@pc$+"', NOW(), '"+getcharid(3)+"')");

your reward logs was saved in a different table .....in the log scheme.

 

the sql table you shown above...is it the rewardlogs ??? or reward_codes ??? or ???

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  400
  • Reputation:   5
  • Joined:  12/05/11
  • Last Seen:  

query_logsql("INSERT INTO `rewardlogs` (code,redeem_time,account_id) VALUES ('"+.@pc"', NOW(), '"+getcharid(3)+"')");

your reward logs was saved in a different table .....in the log scheme.

 

the sql table you shown above...is it the rewardlogs ??? or reward_codes ??? or ???

 

The screen shot above is from reward_codes

 

This is the rewardlogs :

 

9hLJ1Wr.jpg

and I think it's working fine.. Right?

 

There are 2 sql table that need to be install :

 

//===============================================================================
//SQL for DBmain
/*
DROP TABLE IF EXISTS `reward_codes`;
CREATE TABLE IF NOT EXISTS `reward_codes` (
  `code` VARCHAR(10) NOT NULL DEFAULT '',
  `nameid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `item_name` VARCHAR(45) NOT NULL DEFAULT '',
  `amount` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',
  `time_created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
  `redeem_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
  `account_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `confirmed` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY (`code`)
) ENGINE=MYISAM;
*/
// SQL for DBlog
/*
DROP TABLE IF EXISTS `rewardlogs`;
CREATE TABLE `rewardlogs` (
`account_id` INT( 10 ) NOT NULL ,
`code` VARCHAR( 10 ) NOT NULL
) ENGINE = InnoDB;
*/
//===============================================================================
Edited by uDe
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2347
  • Joined:  10/28/11
  • Last Seen:  

yes....the saved contents from reward_codes should be deleted upon other players claimed the items..so it's pointless to save the redeem time there...

query_sql("DELETE FROM `reward_codes` WHERE `code` = '" +escape_sql(.@pc$)+ "'");
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  400
  • Reputation:   5
  • Joined:  12/05/11
  • Last Seen:  

Hmm.. Why it will be deleted? @Patskie add it that right?

 

I think, from original script from here , it will saved right?

 

It really got me confuse. So, I just need the same thing like this post.

 

I really need the full 'logs'.. So I'm hoping that there are no conflicts with players. You know what happen when they got something 'free' right? Always want more.. Like me. Now. /sob

Edited by uDe
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2347
  • Joined:  10/28/11
  • Last Seen:  

which script are you using now ....

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  400
  • Reputation:   5
  • Joined:  12/05/11
  • Last Seen:  

Currently I'm using this : http://rathena.org/board/topic/86986-promotionial-codes-script/#entry220578

 

Thought that @Patskie had it fixed.. But the 3 problems from my 1st post still didn't fix.

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2347
  • Joined:  10/28/11
  • Last Seen:  

 

yes....the saved contents from reward_codes should be deleted upon other players claimed the items..so it's pointless to save the redeem time there...

query_sql("DELETE FROM `reward_codes` WHERE `code` = '" +escape_sql(.@pc$)+ "'");
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  400
  • Reputation:   5
  • Joined:  12/05/11
  • Last Seen:  

So, then, I want to use the script that will save the redeem_time, accound_id and confirmed /panic

 

and script than can fix those problems also :

 


2. Referring to SS above, there are 2 codes has been given. But there's no update also when I use "View existing codes" in-game.

SuDctTt.jpg


3.

After ADMIN use @code > setup the code > finish. He can't move, seems like stuck with npc. Need to @load or @go. I found no problems with @claim commands.



BUMP

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  50
  • Topics Per Day:  0.01
  • Content Count:  1702
  • Reputation:   238
  • Joined:  09/05/12
  • Last Seen:  

If you try to download the original file here http://rathena.org/board/files/file/2862-utility-promotional-codes/ you can find his sql file. That is my basis on this script :
 

The original reward code sql :

CREATE TABLE IF NOT EXISTS `reward_codes` (
  `code` VARCHAR(10) NOT NULL DEFAULT '',
  `nameid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `item_name` VARCHAR(45) NOT NULL DEFAULT '',
  `amount` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',
  `time_created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`code`)
) ENGINE=MYISAM;
and log : 
CREATE TABLE IF NOT EXISTS `rewardlogs` (
  `code` VARCHAR(10) NOT NULL DEFAULT '',
  `redeem_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
  `account_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY (`code`)
) ENGINE=MYISAM;

EDIT : Try this new one, i fix them, remove some, add some. and so on xD. Execute first the commented line. If error occur, post it

/*
DROP TABLE IF EXISTS `reward_codes`;
CREATE TABLE IF NOT EXISTS `reward_codes` (
    `code` VARCHAR(10) NOT NULL DEFAULT '',
    `nameid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
    `item_name` VARCHAR(45) NOT NULL DEFAULT '',
    `amount` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',
    `time_created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'
    PRIMARY KEY (`code`)
) ENGINE = MYISAM;

DROP TABLE IF EXISTS `rewardlogs`;
CREATE TABLE `rewardlogs` (
    `account_id` INT( 10 ) NOT NULL,
    `code` VARCHAR( 10 ) NOT NULL,
    `redeem_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE = MyISAM;
*/


-    script    promoclaim    -1,{


OnInit:
    bindatcmd "claim",strnpcinfo(3)+"::OnClaim";
    bindatcmd "code",strnpcinfo(3)+"::OnEditCode";
    end;
    
OnClaim:
    // if ( getgmlevel() ) end;
    mes "^FF0000 Enter a new promotional code.";
    input .@pc$;
    close2;
    
    query_sql "SELECT `nameid`, `amount` FROM `reward_codes` WHERE `code` = '" + escape_sql(.@pc$) + "'", .@item, .@amt;
    
    if ( !.@item ) 
        dispbottom "Either invalid code or the code is already claimed by other people";
    else {
        getitem .@item, .@amt;
        dispbottom "Promotional code successfully redeemed.";
        query_sql "DELETE FROM `reward_codes` WHERE `code` = '" + escape_sql(.@pc$) + "'";
        query_logsql "INSERT INTO `rewardlogs` VALUES ( '" + getcharid(3) + "', '" + escape_sql(.@pc$) + "', NOW() )";
    }
    
    end;
    
OnEditCode:
    if ( getgmlevel() < 99 ) end;
    set .@choice$, "Setup a new promotional code:View existing codes:Delete exisiting codes:Cancel";
    setarray .@length, 4,10; // <min>,<max>
    
    switch ( select( .@choice$ ) ) {
        case 1:
                input .@pcode$;
                if ( getstrlen( .@pcode$ ) < .@length[0] || getstrlen( .@pcode$ ) > .@length[1] ) {
                        dispbottom "Codes must not be less than " +.@length[0]+ " and must be greater than " +.@length[1]+ ".";
                        end;
                }
                mes "You have entered ^FF0000"+.@pcode$+"^000000 as the code.";
                mes "Are you sure?";
                if ( select("Yes:No, thanks") - 1 ) end;
                query_sql "SELECT `code` FROM `reward_codes` WHERE `code` = '" + escape_sql(.@pcode$) + "'", .@pcode_exists;
                if ( .@pcode_exists ) {
                        dispbottom "Sorry, that code already exist.";
                        end;
                }
                mes "Please set a reward for the players who has entered the code.";
                input .@reward;
                next;
                if ( !.@reward || getitemname(.@reward) == "null" ) {
                        dispbottom "Sorry, that is an invalid item id.";
                        end;
                }
                set .@iname$, getitemname(.@reward);
                mes "Item number ^FF0000"+.@reward+"^000000";
                mes "is equivalent to ^FF0000"+.@iname$+"^000000.";
                mes "Are you sure?";
                next;
                if ( select("Yes:No, thanks") - 1 ) end;
                mes "How many ^FF0000"+.@iname$+"^000000.?";
                input .@amount;
                next;
                if ( !.@amount ) {
                    dispbottom "Sorry, that is an invalid amount number.";
                    end;
                }
                mes "Are you sure?";
                next;
                if ( select("Yes:No, thanks") - 1 ) end;
                query_sql "INSERT INTO `reward_codes` VALUES ( '" + escape_sql(.@pcode$) + "', '" + .@reward + "', '" + escape_sql(.@iname$) + "', '" + .@amount + "', NOW() )";
                dispbottom "Done creating code!";
                break;
        case 2:
                set .@nb, query_sql("SELECT code, item_name, amount FROM `reward_codes` ORDER BY time_created DESC LIMIT 20", .@code$, .@nid$, .@amount);    
                if ( !.@nb ) {
                    dispbottom "No exisiting codes.";
                    end;
                }
                dispbottom "=============================================";
                dispbottom "==============  EXISITING CODES  ==============";
                dispbottom "=============================================";
                for(set .@i,0; .@i < .@nb; set .@i,.@i+1)
                dispbottom ""+.@code$[.@i]+" (  Reward: "+.@amount[.@i]+" "+.@nid$[.@i]+" ) ";
                dispbottom "=============================================";
                break;
        case 3:
                input .@dcode$;
                query_sql "SELECT `code` FROM `reward_codes` WHERE `code` = '" + escape_sql(.@dcode$) + "'", .@dcode_exists;
                if ( !.@dcode_exists ) {
                    dispbottom "Promotional code not found.";
                    end;
                }
                mes "Would you like to delete that code?";
                next;
                if ( select("Yes:No, thanks") - 1 ) end;
                query_sql "DELETE FROM `reward_codes` WHERE `code` = '" + escape_sql(.@dcode$) + "'";
                break;
        case 4: close; break;
        default: break;
    }
    end;
}
Edited by Patskie
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  400
  • Reputation:   5
  • Joined:  12/05/11
  • Last Seen:  

What's wrong with rAthena Quote function? Loading so long and nothing..? /yawn

 

BTW, here's the problems from your script and sql queries above

 

1. No close button.

 

YOzXA8u.jpg

 

2. Still no close button.

 

kuGr6SL.jpg

 

 

3. SQL error?

 

koYyAST.jpg

 

4. No update on sql because of the errors above?

 

5. After using @code command, I can't move.

 

I really do want the important function from this script :

 

			mes "Code for more than 1 use?";
			if(select("Yes:No")==2) close;	
			dispbottom "Promotional Code ^FF0000"+.@pcode$+" ^000000is now activated and the reward is ^FF0000"+.@amount+" "+.@iname$+".";
			Query_SQL( "UPDATE `reward_codes` SET `confirmed` = '2' WHERE `code`='"+escape_sql(.@pcode$)+"'");
			close;

 

And thank you @Patskie for your time for trying to help me.

Edited by uDe
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  50
  • Topics Per Day:  0.01
  • Content Count:  1702
  • Reputation:   238
  • Joined:  09/05/12
  • Last Seen:  

Why not create multiple items so that people can claim and claim? If you want it that way then it seems like creating this promo script is useless. You can create an item reward npc wherein you can set your prize and let your players get and get and get.

 

YOzXA8u.jpgkuGr6SL.jpg
 
Try changing all :
if ( select("Yes:No, thanks") - 1 ) end;
to :
if ( select("Yes:No, thanks") - 1 ) close;
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  43
  • Topics Per Day:  0.01
  • Content Count:  400
  • Reputation:   5
  • Joined:  12/05/11
  • Last Seen:  

Why not create multiple items so that people can claim and claim? If you

want it that way then it seems like creating this promo script is

useless. You can create an item reward npc wherein you can set your

prize and let your players get and get and get.

 

 

mes "Code for more than 1 use?";

 

It's mean that only 1 person per item and the code still can be use by other players. Personally for me, this is an another way to distribute rewards for players instead of talking to NPC.

 

For example, I'm going to use this script to promote my server at facebook and I just need to use 1 code only. Instead of giving 100+ codes. And don't worry, I won't give any trade-able items to prevent players to exploit this codes by creating new characters on their ID. It's good to have an option though..

 

Thanks for the opinion by the way. Still, I would really need that function. /kis2

 

Sorry for my cheap English Language.

 

 

EDIT

 

For close; problems, still didn't fix yet..

 

Here's the script :promo_codes.txt

Edited by uDe
Link to comment
Share on other sites

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.

×
×
  • Create New...