Adding custom item effect and scripts

07/25/2011 17:36 Ranma014#1
I found out about another script, that isnt present in the current 6.1 server files, that were released a while ago. It is convenient, as you can add new function to items, like opening dialogues (shops, auction, storage) or administer buffs.


1.) Download the 'on_use_item.lua' I wrote. Look at the bottom of his post. Copy it into your Resource/Script folder.
2.) Open it in your favorite text editor. Inside you will find:
3.) To add new functions, there are two things you gotta do. First, you'll have to know the ID of the item you are trying to modify. Then find that item inside this table: [Arcadia].[dbo].[ItemResource]
The last column is named 'script_text'. There you have to insert 'on_use_item' (without the quotes).
Second, you need to let the server know what to do. Inside the above posted lua-file look for
The X represent the item functions. To add a new one insert
just before the last 'end' in the lua-file. The Ys represent the ID of the item you want to add a new function. The Zs are the new function. I may make a list of what you can do later, but for now look inside other threads, they are the same as for login buffs or item insertions.
4.) Save the file and restart your server. Whenever you use the item the function you entered will be called.

Example:
I adjusted the Red Potion Lv1 inside the database to call the script with


The ID is 602001. Then I added a function. Whenever a Red Potion Lv1 is used it will insert another Red Potion Lv1. This is the complete on_use_item.lua for that, with out any other modifications:



WARNING
I wrote that lua-script myself based on my findings in the database.
I am not sure if the original script (that is stored away inside the server files) does anything else. I just added the items that already had that fuction build in, namely "Scroll of Storing", "Scroll of Bidding" and "Scroll of Boosting", which can be bought in the hidden village. If you use this there might be complications with unknown functions, but I am pretty sure, that those three are the only items/object calling that script.

WARNING 2
You cannot add such a function to an equippable item. I tested the three scrolls and the Red Potion. It seems it works just fine with any consumable item.

Have fun.

Edit: Creating the basic lua-file:

I cannot add lua-files, so make a new text-file and enter
Save it as on_use_item.lua

Alternately download
Mirror 1: [Only registered and activated users can see links. Click Here To Register...]
Mirror 2: [Only registered and activated users can see links. Click Here To Register...]
07/25/2011 17:48 lilnani#2
i didnt understand
07/25/2011 18:26 Ranma014#3
Try reading it now, I changed my original post.
Of yourse you would need to know how to edit your database, use basix sql queries and how to code in lua (any basic programming language is sufficiant, just enter new items according to the 3 scrolls)
07/25/2011 20:05 wisp66#4
nifty concept ^^ not sure how useful it is at first glance but it does open the doors to a few other options
07/25/2011 20:39 Ranma014#5
Quote:
Originally Posted by wisp66 View Post
nifty concept ^^ not sure how useful it is at first glance but it does open the doors to a few other options
Well there was a problem with creature buffs on login, cause when you dual summoned your 2nd pet wont have those unless you relogged, which wasnt pratical. thats why i raised the dual summon time to almost unlimited. Now with this concept I addes those add_cstate commands to the use of a red potion lv1, so whenever i use one, my latest summoned pet will be fully buffed.

edit: btw wisp, could you pls add this thread and this one: [Only registered and activated users can see links. Click Here To Register...] as links to your sticky? cause the second one is already on the back pages. this section is getting spoammed alot by trolls and idiots who think they can setup a server with one click.
07/25/2011 21:54 ismokedrow#6
That is some true ingenuity you got there sir. +1
07/25/2011 22:55 wisp66#7
Quote:
Originally Posted by Ranma014 View Post
Well there was a problem with creature buffs on login, cause when you dual summoned your 2nd pet wont have those unless you relogged, which wasnt pratical. thats why i raised the dual summon time to almost unlimited. Now with this concept I addes those add_cstate commands to the use of a red potion lv1, so whenever i use one, my latest summoned pet will be fully buffed.

edit: btw wisp, could you pls add this thread and this one: [Only registered and activated users can see links. Click Here To Register...] as links to your sticky? cause the second one is already on the back pages. this section is getting spoammed alot by trolls and idiots who think they can setup a server with one click.
yep ill move it there when i get home later to night ^^
11/12/2013 21:50 banditas231#8
re-upload the files please
11/15/2013 21:39 ThunderNikk#9
They are right up there in the OP that your necroposting.

They are only .txt files converted to .lua by changing the file extension and they are all written here in the spoilers.

No need to download them.
01/15/2015 19:46 hassuny#10
up up