Lua How to make a simple quest chest

Sub Zero

New Member
Joined
Jul 17, 2007
Messages
40
Best answers
0
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
 

Sniperfox

New Member
Joined
Jun 11, 2007
Messages
401
Best answers
0
Reaction score
1
Location
The Netherlands
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.
 

Pank

Member
Joined
Jul 21, 2007
Messages
34
Best answers
0
Reaction score
1
Thank you very much for this friend. I was with some doubts on "PlayerStorageValue", and now I got to understand.
Hugs, Pank!
 

Snel pUppie

Active Member
Joined
Jun 15, 2007
Messages
1,631
Best answers
0
Reaction score
2
I've got a problem with PlayerStorageValue :p
 

Apollo

Herban Legend
Joined
Jul 11, 2007
Messages
519
Best answers
0
Reaction score
1
Location
Canada
remove all the comic sans ms crap inside the code boxes, nobody else cant see that i bet.
 

Xero

~¤+Mapeditor User+¤~ ™
Joined
Jun 11, 2007
Messages
301
Best answers
0
Reaction score
2
Location
Netherlands
I've seen this tutorial on other sites to :S STRANGE!
 

Isen

Member
Joined
Jun 12, 2007
Messages
48
Best answers
0
Reaction score
3
Definitely helped me. Nice pic Agostino.
 

vixcry

New Member
Joined
Aug 2, 2007
Messages
17
Best answers
0
Reaction score
0
oh very good!! Continue working hard!! C'mon!!
 

Fiko

New Member
Joined
Jun 15, 2007
Messages
15
Best answers
0
Reaction score
0
you need fix the fonts commands lol but nice work exellent guide
 

pablol

Member
Joined
Jul 5, 2007
Messages
47
Best answers
0
Reaction score
0
Sure good tutorial it would be better if YOU MADE IT YOURSELF
give Credits to the people you copyed it from like maybe Roman From otfans and maybe heres some proof? http://otfans.net/showthread.php?t=9211
 
Last edited:

Zapatch

Member
Joined
Jun 6, 2007
Messages
166
Best answers
0
Reaction score
1
It helped me abit :p Thank you. But i still think its copied.
 
Top