Jump to content

Recommended Posts

Posted

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
Posted (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 by Meroy
Posted

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.

Posted

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
Posted

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.

Posted

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.

Posted

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)

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

}

Posted

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.

Posted

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

Posted

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

Posted

@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

Posted

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.

Posted

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

Posted

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

Posted

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 ?

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.

  • Recently Browsing   0 members

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