Jump to content

Coupon NPC [1.1.2]


tr0n

Recommended Posts


  • Group:  Members
  • Topic Count:  28
  • Topics Per Day:  0.01
  • Content Count:  562
  • Reputation:   152
  • Joined:  02/21/12
  • Last Seen:  

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

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

  • Upvote 8
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  70
  • Topics Per Day:  0.02
  • Content Count:  203
  • Reputation:   1
  • Joined:  05/11/12
  • Last Seen:  

Looks Nice, I will be using this! Thanks :D

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  98
  • Topics Per Day:  0.02
  • Content Count:  299
  • Reputation:   5
  • Joined:  04/05/12
  • Last Seen:  

i try this but when i enter the code it i cannot get anything

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  53
  • Topics Per Day:  0.01
  • Content Count:  291
  • Reputation:   4
  • Joined:  04/24/12
  • Last Seen:  

i tried it also.. when i click add coupon -> item ID -> item amount where to put the coupon code?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  9
  • Reputation:   0
  • Joined:  05/04/12
  • Last Seen:  

+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 by Meroy
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  28
  • Topics Per Day:  0.01
  • Content Count:  562
  • Reputation:   152
  • Joined:  02/21/12
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  70
  • Topics Per Day:  0.02
  • Content Count:  203
  • Reputation:   1
  • Joined:  05/11/12
  • Last Seen:  

Can i generate a code by my self?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  28
  • Topics Per Day:  0.01
  • Content Count:  562
  • Reputation:   152
  • Joined:  02/21/12
  • Last Seen:  

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.

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  70
  • Topics Per Day:  0.02
  • Content Count:  1245
  • Reputation:   392
  • Joined:  11/19/11
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  28
  • Topics Per Day:  0.01
  • Content Count:  562
  • Reputation:   152
  • Joined:  02/21/12
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  98
  • Topics Per Day:  0.02
  • Content Count:  299
  • Reputation:   5
  • Joined:  04/05/12
  • Last Seen:  

when i input the code

i dont get anything

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  210
  • Reputation:   10
  • Joined:  11/20/11
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  142
  • Topics Per Day:  0.03
  • Content Count:  511
  • Reputation:   7
  • Joined:  02/15/12
  • Last Seen:  

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)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  69
  • Topics Per Day:  0.02
  • Content Count:  592
  • Reputation:   31
  • Joined:  11/14/11
  • Last Seen:  

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";

}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  142
  • Topics Per Day:  0.03
  • Content Count:  511
  • Reputation:   7
  • Joined:  02/15/12
  • Last Seen:  

Do i just need to restart the server?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  28
  • Topics Per Day:  0.01
  • Content Count:  562
  • Reputation:   152
  • Joined:  02/21/12
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  98
  • Topics Per Day:  0.02
  • Content Count:  299
  • Reputation:   5
  • Joined:  04/05/12
  • Last Seen:  

@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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  142
  • Topics Per Day:  0.03
  • Content Count:  511
  • Reputation:   7
  • Joined:  02/15/12
  • Last Seen:  

@tr0n

Sorry for not saying Thanks in the first place, Well.. The script works now ! THANKS XD

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  28
  • Topics Per Day:  0.01
  • Content Count:  562
  • Reputation:   152
  • Joined:  02/21/12
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  142
  • Topics Per Day:  0.03
  • Content Count:  511
  • Reputation:   7
  • Joined:  02/15/12
  • Last Seen:  

@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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  28
  • Topics Per Day:  0.01
  • Content Count:  562
  • Reputation:   152
  • Joined:  02/21/12
  • Last Seen:  

@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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  142
  • Topics Per Day:  0.03
  • Content Count:  511
  • Reputation:   7
  • Joined:  02/15/12
  • Last Seen:  

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.

Link to comment
Share on other sites


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

@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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  142
  • Topics Per Day:  0.03
  • Content Count:  511
  • Reputation:   7
  • Joined:  02/15/12
  • Last Seen:  

@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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  28
  • Topics Per Day:  0.01
  • Content Count:  562
  • Reputation:   152
  • Joined:  02/21/12
  • Last Seen:  

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 ?

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
Reply to this topic...

×   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...