tr0n Posted May 13, 2012 Group: Members Topic Count: 28 Topics Per Day: 0.01 Content Count: 562 Reputation: 153 Joined: 02/21/12 Last Seen: February 27, 2024 Share Posted May 13, 2012 Coupon NPC I had the idea from here: http://rathena.org/b...ional-code-npc/ I decided to make my own script. How does this works ? The admin speaks to the npc and he/she can add a new coupon. The code will be generated randomly and automatic and everything will be saved in database. You can set the code length in script. You only need to enter the item id and the amount. If a player speaks to the npc he/she can submit a coupon and get the stuff. The code will be deleted from database after it was used. Notice: Coupon Codes are limited to 128 (array limit) Files coupon_system.txt coupon_npc_1.1.0.txt coupon_npc_1.1.1.txt coupon_npc_1.1.2.txt Changelogs 1.0.0 Release 1.1.0 Added code type feature (normal|md5-hash) 1.1.0 Added prevention for typing 0 into Item ID or Amount 1.1.0 Added a feature for gms to see available coupons 1.1.0 Minor bug fixes 1.1.1 Fixed a bug that caused duplicating items 1.1.2 Added announce if player got a item Features Saves coupons in database randomly generated codes very easy to use How can you help me ? Give me feedback Report bugs Tell me if you like it tr0n 8 Quote Link to comment Share on other sites More sharing options...
Littlefoot Posted May 13, 2012 Group: Members Topic Count: 70 Topics Per Day: 0.01 Content Count: 203 Reputation: 1 Joined: 05/11/12 Last Seen: July 30, 2016 Share Posted May 13, 2012 Looks Nice, I will be using this! Thanks Quote Link to comment Share on other sites More sharing options...
Jhosef Posted May 13, 2012 Group: Members Topic Count: 98 Topics Per Day: 0.02 Content Count: 299 Reputation: 5 Joined: 04/05/12 Last Seen: September 9, 2012 Share Posted May 13, 2012 i try this but when i enter the code it i cannot get anything Quote Link to comment Share on other sites More sharing options...
v00m3r Posted May 13, 2012 Group: Members Topic Count: 53 Topics Per Day: 0.01 Content Count: 291 Reputation: 4 Joined: 04/24/12 Last Seen: January 30, 2014 Share Posted May 13, 2012 i tried it also.. when i click add coupon -> item ID -> item amount where to put the coupon code? Quote Link to comment Share on other sites More sharing options...
Meroy Posted May 13, 2012 Group: Members Topic Count: 0 Topics Per Day: 0 Content Count: 9 Reputation: 0 Joined: 05/04/12 Last Seen: May 23, 2012 Share Posted May 13, 2012 (edited) +1 for this, further question for this, i'll post later. Possible, it would be 'ERROR' if you will input 'NULL' numbers or any item that's not inserted in DATABASE. Preview: http://i45.tinypic.com/icv31c.png e.g i'll put 21313asdqw3 , when i input that it still continue the processing, possible it will say 'ERROR: Please Input Correctly, or check databse for items and etc. To PREVENT spamm in 'database' Possible to choose generate key "STANDARD" or MD5M" just like IP.Board And also, it could be nice if you could add feature that admin can check if the COUPON is available or not. and time when he/she claim the coupon and check I.P's for more secure method. Thank you! Edited May 13, 2012 by Meroy Quote Link to comment Share on other sites More sharing options...
tr0n Posted May 13, 2012 Group: Members Topic Count: 28 Topics Per Day: 0.01 Content Count: 562 Reputation: 153 Joined: 02/21/12 Last Seen: February 27, 2024 Author Share Posted May 13, 2012 i try this but when i enter the code it i cannot get anything i tried it also.. when i click add coupon -> item ID -> item amount where to put the coupon code? The coupon is generated randomly(automatic) in your database. you can find it there. +1 for this, further question for this, i'll post later. Possible, it would be 'ERROR' if you will input 'NULL' numbers or any item that's not inserted in DATABASE. Preview: http://i45.tinypic.com/icv31c.png e.g i'll put 21313asdqw3 , when i input that it still continue the processing, possible it will say 'ERROR: Please Input Correctly, or check databse for items and etc. To PREVENT spamm in 'database' Possible to choose generate key "STANDARD" or MD5M" just like IP.Board And also, it could be nice if you could add feature that admin can check if the COUPON is available or not. and time when he/she claim the coupon and check I.P's for more secure method. Thank you! I will work on preventing input 0 or " ". Preventing spam ? why should the admin spam his own server ? the generated key is made by the scriptcommand rand() I think about adding a md5() function in it. the coupon will be deleted after submit. so you can't use it again. Quote Link to comment Share on other sites More sharing options...
Littlefoot Posted May 13, 2012 Group: Members Topic Count: 70 Topics Per Day: 0.01 Content Count: 203 Reputation: 1 Joined: 05/11/12 Last Seen: July 30, 2016 Share Posted May 13, 2012 Can i generate a code by my self? Quote Link to comment Share on other sites More sharing options...
tr0n Posted May 13, 2012 Group: Members Topic Count: 28 Topics Per Day: 0.01 Content Count: 562 Reputation: 153 Joined: 02/21/12 Last Seen: February 27, 2024 Author Share Posted May 13, 2012 Can i generate a code by my self? The code will be generated randomly and automatic and everything will be saved in database. You can set the code length in script. You only need to enter the item id and the amount. 1 Quote Link to comment Share on other sites More sharing options...
Syouji Posted May 13, 2012 Group: Members Topic Count: 70 Topics Per Day: 0.01 Content Count: 1245 Reputation: 395 Joined: 11/19/11 Last Seen: January 15, 2020 Share Posted May 13, 2012 Nice script Tr0n! Is it possible for the NPC to display the code to the GM as well if they wish to view it instead of looking in the SQL db. Mainly for those who dont have access to the SQL such as a higher level GM. Quote Link to comment Share on other sites More sharing options...
tr0n Posted May 13, 2012 Group: Members Topic Count: 28 Topics Per Day: 0.01 Content Count: 562 Reputation: 153 Joined: 02/21/12 Last Seen: February 27, 2024 Author Share Posted May 13, 2012 you want to give gm's access to the coupon npc ? well okay, I actualy could add it. I will do it for the next update. Quote Link to comment Share on other sites More sharing options...
Jhosef Posted May 13, 2012 Group: Members Topic Count: 98 Topics Per Day: 0.02 Content Count: 299 Reputation: 5 Joined: 04/05/12 Last Seen: September 9, 2012 Share Posted May 13, 2012 when i input the code i dont get anything Quote Link to comment Share on other sites More sharing options...
quesoph Posted May 13, 2012 Group: Members Topic Count: 16 Topics Per Day: 0.00 Content Count: 210 Reputation: 10 Joined: 11/20/11 Last Seen: August 23, 2015 Share Posted May 13, 2012 Suggestion: GM can set 2 or more items ( with individual quantity ) in 1 coupon. example: coupon number is: 123465 when the code is entered to the npc you can claim 2pcs yggdrasillberry , and 3 yggdrasillseed. Quote Link to comment Share on other sites More sharing options...
WhatFT Posted May 13, 2012 Group: Members Topic Count: 142 Topics Per Day: 0.03 Content Count: 511 Reputation: 7 Joined: 02/15/12 Last Seen: April 11, 2014 Share Posted May 13, 2012 Can just put the CODE in the NPC itself? It's kinda hard for newbies to insert it the SQL. I'm a newbie on it lol. Suggestion : 1. Can just only insert the Code anything what the admin wants. (ex: ASD123) 2. Admin(99) can write/remove/view the existing codes 3. Admin can the logs (if ever) Quote Link to comment Share on other sites More sharing options...
GM Takumirai Posted May 13, 2012 Group: Members Topic Count: 69 Topics Per Day: 0.01 Content Count: 592 Reputation: 31 Joined: 11/14/11 Last Seen: July 29, 2015 Share Posted May 13, 2012 if(getgmlevel() == 99) you can change it to your GM level if(getgmlevel() => 50) - correct me if im wrong - i think the code of tr0n is no need to create a table manually in script OnInit: query_sql "CREATE TABLE IF NOT EXISTS `coupons` (`code` TINYTEXT NOT NULL, `item_id` INT NOT NULL, `item_amount` INT NOT NULL, INDEX `code` (`code`(32)) ) ENGINE=MyISAM"; } Quote Link to comment Share on other sites More sharing options...
WhatFT Posted May 13, 2012 Group: Members Topic Count: 142 Topics Per Day: 0.03 Content Count: 511 Reputation: 7 Joined: 02/15/12 Last Seen: April 11, 2014 Share Posted May 13, 2012 Do i just need to restart the server? Quote Link to comment Share on other sites More sharing options...
tr0n Posted May 13, 2012 Group: Members Topic Count: 28 Topics Per Day: 0.01 Content Count: 562 Reputation: 153 Joined: 02/21/12 Last Seen: February 27, 2024 Author Share Posted May 13, 2012 just restart the server. _____________________________________________________________ For everyone: PLEASE READ THE DESCRIPTION AND THE SCRIPT. It can't be that I make a friggin easy script and get 100posts about "how to use it correct" or "please make it different with this and that". If you can't understand basic logic mechanics then please learn the basics, if you open a server, learn basic scripting! Actually i really like suggestions and here are some good suggestions. But it's kinda rude to tell the author to make a whole different version of the script just because 1 person likes to. I don't even hear a "thank you" or a suggestion to improve my script. Some people say it and thank you for that, you are the reason why I do this! Please people, it's not like I don't like to make public scripts for the community. Sry but I had to say that. Quote Link to comment Share on other sites More sharing options...
Jhosef Posted May 13, 2012 Group: Members Topic Count: 98 Topics Per Day: 0.02 Content Count: 299 Reputation: 5 Joined: 04/05/12 Last Seen: September 9, 2012 Share Posted May 13, 2012 @tron thanks to your script i already making my SPECIAL SCRIPT thanks to you i have a REFERENCE to my SPECIAL SCRIPT and THANKS to thishttp://rathena.org/board/topic/63282-promotional-code-npc/ for my another Reference Quote Link to comment Share on other sites More sharing options...
WhatFT Posted May 13, 2012 Group: Members Topic Count: 142 Topics Per Day: 0.03 Content Count: 511 Reputation: 7 Joined: 02/15/12 Last Seen: April 11, 2014 Share Posted May 13, 2012 @tr0n Sorry for not saying Thanks in the first place, Well.. The script works now ! THANKS XD Quote Link to comment Share on other sites More sharing options...
tr0n Posted May 13, 2012 Group: Members Topic Count: 28 Topics Per Day: 0.01 Content Count: 562 Reputation: 153 Joined: 02/21/12 Last Seen: February 27, 2024 Author Share Posted May 13, 2012 UPDATE Changelogs 1.1.0: 1.1.0 Added code type feature (normal|md5-hash) 1.1.0 Added prevention for typing 0 into Item ID or Amount 1.1.0 Added a feature for gms to see available coupons 1.1.0 Minor bug fixes Quote Link to comment Share on other sites More sharing options...
WhatFT Posted May 14, 2012 Group: Members Topic Count: 142 Topics Per Day: 0.03 Content Count: 511 Reputation: 7 Joined: 02/15/12 Last Seen: April 11, 2014 Share Posted May 14, 2012 @tr0n I got a problem while giving out the codes to the players as an event for a test. I just input the "amount" from 10 and I made lots of Coupon Codes. Then suddenly some of my players got atleast 400~500 amount of the item I input. Quote Link to comment Share on other sites More sharing options...
tr0n Posted May 14, 2012 Group: Members Topic Count: 28 Topics Per Day: 0.01 Content Count: 562 Reputation: 153 Joined: 02/21/12 Last Seen: February 27, 2024 Author Share Posted May 14, 2012 @tr0n I got a problem while giving out the codes to the players as an event for a test. I just input the "amount" from 10 and I made lots of Coupon Codes. Then suddenly some of my players got atleast 400~500 amount of the item I input. I don't know how this could happen. I checked the script and found nothing. If you didn't entered 400-500 item amount in your database this shouldn't happen Quote Link to comment Share on other sites More sharing options...
WhatFT Posted May 14, 2012 Group: Members Topic Count: 142 Topics Per Day: 0.03 Content Count: 511 Reputation: 7 Joined: 02/15/12 Last Seen: April 11, 2014 Share Posted May 14, 2012 I just typed the amount "10" only. Then suddenly some of the players received 400~500. I even see it in my database when I'm giving them the Codes. It's 10 but some received many and It's really many because I checked their accounts & logs. Quote Link to comment Share on other sites More sharing options...
Emistry Posted May 14, 2012 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: Sunday at 05:32 PM Share Posted May 14, 2012 @tr0n I got a problem while giving out the codes to the players as an event for a test. I just input the "amount" from 10 and I made lots of Coupon Codes. Then suddenly some of my players got atleast 400~500 amount of the item I input. if i was right.....then i think those player are using this method to achieve above situation... GM Generate Coupon for Items and give the Code to Players. Players gain items from the NPC by giving the right Code. but then...unfortunately.....they found a way to Duplicate your Items / Coupons... this is the way how they do it.... Give the Correct Code , then get items. before they Close the Message Window .... they ...Relog / ALT + F4 so....after they relog / Alt +F4 ......the Coupon actually is not deleted from the SQL. ....because...the command line that delete the SQL only executed right after they closed the message window of NPC. mes "[^FF7700Coupon Jack^000000]"; mes "You get ^0000FF" + getitemname(@available_item[@i]) + " - " + @available_item[@i] + " ea.^000000"; close2; query_sql "DELETE FROM `coupons` WHERE `code`='"+@my_code$+"'"; getitem @available_item[@i],@available_amount[@i]; end; if you want...you can try it like this...i think it should be able to solve above problems. mes "[^FF7700Coupon Jack^000000]"; mes "You get ^0000FF" + getitemname(@available_item[@i]) + " - " + @available_item[@i] + " ea.^000000"; query_sql "DELETE FROM `coupons` WHERE `code`='"+@my_code$+"'"; getitem @available_item[@i],@available_amount[@i]; close; and....make sure you dont generate alot Coupon with SAME Code. Quote Link to comment Share on other sites More sharing options...
WhatFT Posted May 14, 2012 Group: Members Topic Count: 142 Topics Per Day: 0.03 Content Count: 511 Reputation: 7 Joined: 02/15/12 Last Seen: April 11, 2014 Share Posted May 14, 2012 @tr0n I got a problem while giving out the codes to the players as an event for a test. I just input the "amount" from 10 and I made lots of Coupon Codes. Then suddenly some of my players got atleast 400~500 amount of the item I input. if i was right.....then i think those player are using this method to achieve above situation... GM Generate Coupon for Items and give the Code to Players. Players gain items from the NPC by giving the right Code. but then...unfortunately.....they found a way to Duplicate your Items / Coupons... this is the way how they do it.... Give the Correct Code , then get items. before they Close the Message Window .... they ...Relog / ALT + F4 so....after they relog / Alt +F4 ......the Coupon actually is not deleted from the SQL. ....because...the command line that delete the SQL only executed right after they closed the message window of NPC. mes "[^FF7700Coupon Jack^000000]"; mes "You get ^0000FF" + getitemname(@available_item[@i]) + " - " + @available_item[@i] + " ea.^000000"; close2; query_sql "DELETE FROM `coupons` WHERE `code`='"+@my_code$+"'"; getitem @available_item[@i],@available_amount[@i]; end; if you want...you can try it like this...i think it should be able to solve above problems. mes "[^FF7700Coupon Jack^000000]"; mes "You get ^0000FF" + getitemname(@available_item[@i]) + " - " + @available_item[@i] + " ea.^000000"; query_sql "DELETE FROM `coupons` WHERE `code`='"+@my_code$+"'"; getitem @available_item[@i],@available_amount[@i]; close; and....make sure you dont generate alot Coupon with SAME Code. I also monitored my SQL, and it has been deleted right away. In just a few minutes, after that I got reports that players got 400~500 amount. Quote Link to comment Share on other sites More sharing options...
tr0n Posted May 14, 2012 Group: Members Topic Count: 28 Topics Per Day: 0.01 Content Count: 562 Reputation: 153 Joined: 02/21/12 Last Seen: February 27, 2024 Author Share Posted May 14, 2012 Emistry, how it can be that you get the item before it gets deleted in sql ? the query is before getitem. Does the query need a bit of time ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.