• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua How to make a simple quest chest

Sub Zero

New Member
Joined
Jul 17, 2007
Messages
40
Reaction score
1
Location
Ontario, Canada
This script can work on any client...COLOR][/B]

I bet most of you know how to make quest chests work but for the rest of you here it is.

1. Open up actions.xml and scroll down to bottom of the list and add this code:
Code:
<action uniqueid="1000" script="questchest.lua" />

The unique ID number can be any number thats four digits or more (not sure) but also can only be used once, later on you will have to use different ones, so 1000 is used as an example unique ID.


2. Open up map editor with the map you use, and find the ID 1740 which is the normal chest facing down/south "V", or ID 1747 which is chest facing up/north "^", or ID 1748 which is a chest facing right/east ">", or ID 1749 which is a chest facing left/west "<", or this different chest which might be called treasure chest which is ID 1746 which is a chest facing down/south "V". You also use other different IDs such as a tree or a coffin, or even a backpack, but in this tutorial i am using the normal chest ID 1740 as the example. Place the chest with ID 1740 and right click the chest and click properties, there you will see a couple of lines count, action ID, unique ID, if you do not see this you will have to download Simones Map Editor 4.3.7 which is the newest so far. Anyways where you see unique ID line enter the number you used before in the actions.xml the one i used was 1000. Click OK and save the map.

3. Here we get to the chest making ;) , sorry it took so long. You will now have to create a new lua named questchest, if you didnt want to use that one and you used for example myuberquestchest you will have to replace that with the questchest and also rename the lua file. So now you have the lua file named questchest, open it up and add this code:
Code:
function onUse(cid, item, frompos, item2, topos)[/font]
[font=Comic Sans MS]			 if item.uid == 1000 then[/font]
[font=Comic Sans MS]queststatus = getPlayerStorageValue(cid,1000)[/font]
[font=Comic Sans MS]if queststatus == -1 then[/font]
[font=Comic Sans MS]doPlayerSendTextMessage(cid,22,"You have found golden legs.") [/font]
[font=Comic Sans MS]doPlayerAddItem(cid,2470,1)[/font]
[font=Comic Sans MS]setPlayerStorageValue(cid,1000,1)[/font]
[font=Comic Sans MS]else[/font]
[font=Comic Sans MS]doPlayerSendTextMessage(cid,22,"It is empty.")[/font]
[font=Comic Sans MS]end[/font]
[font=Comic Sans MS]end[/font]
[font=Comic Sans MS]return 1[/font]
[font=Comic Sans MS]end


First we added:
Code:
function onUse(cid, item, frompos, item2, topos)

Because each lua should have that at the top since action scripts only redict to the function "Use" or "Use With".



Next added the code:
Code:
if item.uid == 1000 then
The number should be the unique ID you used before on map editor and the ID that you wrote in actions.xml.



After that we added:
Code:
queststatus = getPlayerStorageValue(cid,1000)[/font]
[font=Comic Sans MS]if queststatus == -1 then

That piece of codes makes it so that when the player gets the item as quest loot he cant get it second time. Where it says
Code:
(cid,1000)

Write the unique ID there too.



Then we added the rest of the code:
Code:
 doPlayerSendTextMessage(cid,22,"You have found golden legs.") [/font]
[font=Comic Sans MS]doPlayerAddItem(cid,2470,1)[/font]
[font=Comic Sans MS]setPlayerStorageValue(cid,1000,1)[/font]
[font=Comic Sans MS]else[/font]
[font=Comic Sans MS]doPlayerSendTextMessage(cid,22,"It is empty.")[/font]
[font=Comic Sans MS]end[/font]
[font=Comic Sans MS]end[/font]
[font=Comic Sans MS]return 1[/font]
[font=Comic Sans MS]end


The code:
Code:
doPlayerSendTextMessage(cid,22,"You have found golden legs.")[/font]
[font=Comic Sans MS]
Is the code that gives the player a messege in green when the player click used on the chest.


The code:
Code:
doPlayerAddItem(cid,2470,1)
Is the quest loot that the player should recieve which are golden legs, (cid,2470,1) cid is the player, the number is the ID of the quest loot item, and the number after that is the quantity of the object.


The rest of the code is:
Code:
 setPlayerStorageValue(cid,1000,1)[/font]
[font=Comic Sans MS]else[/font]
[font=Comic Sans MS]doPlayerSendTextMessage(cid,22,"It is empty.")[/font]
[font=Comic Sans MS]end[/font]
[font=Comic Sans MS]end[/font]
[font=Comic Sans MS]return 1


The number on first line should be the unique ID you used before which i used was 1000. Then comes the next that people get when then try to get the loot again. And after that just add the rest of the code.


Adittional Information:
Simone Map Editor 4.3.7 used;
IDs were from tibia 7.4;
Has been tested only on 7.4.

Another Overview:
Code:
function onUse(cid, item, frompos, item2, topos)[/font]
[font=Comic Sans MS]			 if item.uid == 1000 then[/font]
[font=Comic Sans MS]queststatus = getPlayerStorageValue(cid,1000)[/font]
[font=Comic Sans MS]if queststatus == -1 then[/font]
[font=Comic Sans MS]doPlayerSendTextMessage(cid,22,"You have found golden legs.") [/font]
[font=Comic Sans MS]doPlayerAddItem(cid,2470,1)[/font]
[font=Comic Sans MS]setPlayerStorageValue(cid,1000,1)[/font]
[font=Comic Sans MS]else[/font]
[font=Comic Sans MS]doPlayerSendTextMessage(cid,22,"It is empty.")[/font]
[font=Comic Sans MS]end[/font]
[font=Comic Sans MS]end[/font]
[font=Comic Sans MS]return 1[/font]
[font=Comic Sans MS]end

If you find any errors please reply.




Credits goto Roman on otfans
 
If you are just going to copy and paste stuff, maybe you should fix the post first and remove all the " and " in the post.
 
Thank you very much for this friend. I was with some doubts on "PlayerStorageValue", and now I got to understand.
Hugs, Pank!
 
remove all the comic sans ms crap inside the code boxes, nobody else cant see that i bet.
 
you need fix the fonts commands lol but nice work exellent guide
 
Back
Top