RazorBlade
Retired Snek
Hey guys, I revised my old script for an obsidian knife that would give the player neutral matter without a random factor. Instead of being able to skin multiple corpses, I used storage values. I decided since I'm slowly getting out of newbie town and starting to make working scripts more frequently, I thought I'd share a basic script that I would find useful. I also added notes beside each line to explain what it means and what it does, since I can remember that I never had that and it would have been pretty useful. If you have any questions or if you feel any of the explanations aren't correct, leave a comment.
Here it is...
First of all, in actions.xml put:
Yours may look different depending on what you name your script and if your file path is different.
Now, put in the lua file with the name you've chosen:
Here it is...
First of all, in actions.xml put:
Code:
<action itemid="5908" script="tools/neutral matter with storage.lua"/>
Now, put in the lua file with the name you've chosen:
Code:
--This is a script for the obsidian knife that allows the skinning of the Lord of the Elements' corpse in order to get neutral matter. I will add notes beside things to clarify their uses for those who are new to scripting.--
--Script by RazorBlade--
local corpse = {9009} --This is a local storage that identifies the id of the corpse.
function onUse(cid, item, fromPosition, itemEx, toPosition) --Obviously the function that tells the system that we're using an item on another item.
if isInArray(corpse, itemEx.itemid) == TRUE then --This means if the item we're using the obsidian knife on has the same id as the local storage "corpse", then it moves onto the next line...
if getPlayerStorageValue(cid, 20005) <= 0 then --This function checks if the player has the storage value 20005 with a value of 0 or less. This is to check if the person has already used their knife on this item. If everything checks out, it moves on.
doPlayerAddItem(cid, 8310, 1) --Adds 1 item with the id 8310 to the player's hand, arrow slot or backpack, depending on where there's room.
doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN) --Sends the magic effect that you get from skinning in real Tibia. Green sparkles on the corpse.
setPlayerStorageValue(cid, 20005, 1) --Sets the player's storage value 20005 at 1 so they can't skin the corpse ever again.
else --If the system checks for something, in this case the item id or storage value, and doesn't get the correct answer, it moves to the line following the word "else".
doCreatureSay(cid, "You cannot skin the corpse more than once.", TALKTYPE_ORANGE_2) --Sends the message seen here.
end --Ends the last "if" function
return TRUE --Ensures the system doesn't return "You can not use this object." when skinning unsuccessfully.
end --Ends the second-last "if" function
return FALSE --Ensures that the system doesn't return the message "You can not use this object." when skinning successfully.
end --Ends the third-last function
Last edited: