Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Create item functions with Lua

Dbo Dev
Joined
Sep 19, 2009
Messages
921
Reaction score
191
Hello,
since I "finished" the lua add-on. Im still writing some functions etc but its time to make a tutorial now.
The compiled server files with lua will be released soon.


What do you need?
You only need Lua experience.
no c++ or anything else is needed!

How do I write new functions for items?
Nothing easier than that.
Example:
Code:
function ItemUse_XXXX ( role )
end

role = unique char id.
XXXX <-- is the function ID from the item.
So you have to search in the item-list which I give you for "Use_Item_Tblidx" and there you'll have unique numbers (maybe some duplicate so they will share the same function)

then you just write

Code:
function ItemUse_8001 ( role )
end

8001 = Use_Item_Tblidx from (id)18001 - (name)Senzu Beans

now we go forward and do this:

Code:
function ItemUse_8001 ( role )
    local hp = [COLOR=#333333]g_test:[/COLOR]GetChaAttr(role, ATTR_HP) 
end

hp is now the current life.

now we add a easy check:
Code:
function ItemUse_8001 ( role )
    local hp = g_test:GetChaAttr(role, ATTR_HP)
    if hp <= 0 then -- Check if char is dead 
    end 
end

time to go further and do more checks
Code:
function ItemUse_8001 ( role )    local hp = g_test:GetChaAttr(role, ATTR_HP)
    if hp <= 0 then -- Check if char is dead 
    end 
    
    hp_resume = 20 -- how many life to heal?
    hp = hp + hp_resume 
    mxhp = g_test:GetChaAttr(role,ATTR_MXHP) -- get max life
    
    if hp > mxhp then --Add check that player wont get more life than he has
        hp = mxhp -- set life = max life
    end
end

now the final:
Code:
function ItemUse_8001 ( role )    local hp = g_test:GetChaAttr(role, ATTR_HP)
    if hp <= 0 then -- Check if char is dead 
    end 
    
    hp_resume = 20 -- how many life to heal?
    hp = hp + hp_resume 
    mxhp = g_test:GetChaAttr(role,ATTR_MXHP) -- get max life
    
    if hp > mxhp then --Add check that player wont get more life than he has
        hp = mxhp
    end
    
    g_test:SetCharaAttr(hp, role, ATTR_HP) 
end

g_test:SetCharaAttr(hp, role, ATTR_HP)
update the life from the player

now you finished writing a function which recovers 20 life points

Itemlist:
 
Last edited:
Newbie Spellweaver
Joined
Dec 28, 2013
Messages
31
Reaction score
1
@Daneos can your spear me the .exe for dbo, i got the server but when i train to use it on the client it keeps crashing, others say thats it might be the server codes but i know your codes don't lie so it the .exe for sure. so can you upload the .exe for dbo and maybe the server files because dont be too sure and i dont wanna be annoying you while your focused :*:
 
Newbie Spellweaver
Joined
Jun 28, 2014
Messages
20
Reaction score
3
Yep trying to work on a server as well need Use_Item_Tblidx so i can start setting that up ..or how to get the info directly.
 
Elite Diviner
Joined
May 26, 2014
Messages
482
Reaction score
32
Use_Item_Tblidx? For what? With TBLIDX u are fine, but I really don't know what are u trying to do, he use the TBLIDX

function ItemUse_XXXX

xxxx = TBLIDX of item
 
Newbie Spellweaver
Joined
Jun 28, 2014
Messages
20
Reaction score
3
The Table id numbers is what i need the identification numbers for the items ..
Was wondering if anyone has the item identification numbers..
 
Elite Diviner
Joined
May 26, 2014
Messages
482
Reaction score
32
._. Really? No one can think? It's easy, THINK, how the code do... is obviusly isn't your code, for search the data of SKILL in the DateBase, how with one TBLIDX u can get all the data of that SKILL, with the TBLIDX 200351 i can know is SSJ, cost 440 ep... etc, etc.

If u want I explain that to you, the server have maps who contains all the data of the tables, if u use one for where i = map.begin() and i != map.end(); i++) and there u can put this, printf("ItemID: %d\n", i->tblidx); then on the screen you are going to see all the IDS of items. If you search in google is one way to create .txt, u can save all data in one .txt and make it like your one DB and see all what have the DB.
 
Newbie Spellweaver
Joined
Jun 28, 2014
Messages
20
Reaction score
3
You see your not listening seems like you getting mad to help. But it is simple "TBLIDX 200351" 200351 Is what i have been asking for but i need all the item id's Dont need the explanation i need the id numbers. unlike you haven't helped with this project at all not sure where to get all the item id numbers and Mission id's the whole reason i am here asking. I see and understand the command you are talking but where do you do it at where is this implemented how do i get id's print to a .txt if you can explain this, maybe i can do it instead of asking the same question over and over again it seems a language barrier is making this.. I just need the ids simple and plain and not as great as the rest of you here still learning thus why i am asking. i Just need the number data for the Korea version of the game so i can experiment get better on my own.
 
Elite Diviner
Joined
May 26, 2014
Messages
482
Reaction score
32
Try to do what I said about for of the maps and put all on the .txt and you can get all the ids

Or

 
Newbie Spellweaver
Joined
Jun 28, 2014
Messages
20
Reaction score
3
Thanks for the Help i have the Translations didn't look in there for a while but all the names ids are there Thanks alot. Now i can do what i wanted i located all Item ids and mob and quest. Now what you were talking about earlier was making the map print out all of it on a .txt where do i initiate the code for instance if i wanted to make a addon that did that at any time then where would initiate the code if that makes sense.
 
Back
Top