• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Obsidian Knife for Neutral Matter with Storages [for Newbies]

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,015
Solutions
3
Reaction score
629
Location
Canada
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:
Code:
	<action itemid="5908" script="tools/neutral matter with storage.lua"/>
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:
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:
Hm?
return TRUE --Ensures the system doesn't return "You can not use this object." when skinning unsuccessfully.
return FALSE --Ensures that the system doesn't return the message "You can not use this object." when skinning successfully.
Also, you would achieve the same result if you return FALSE(0)/false or nothing
 
@Cyko: Yes, thanks for mentioning that.
@Beon: Could you rephrase that? Didn't quite catch that. If you're asking what the script does, it simply enables you to use an obsidian knife on the corpse of the lord of the elements in order to get neutral matter.
 
Well in regards to the script, that's what they do... If they aren't there, then it sends that message...
 
I'll explain what I mean... If it's return TRUE like it says in the script, it doesn't send the message. If it's not there or if I change it to return FALSE, it sends the message still. If the other one is changed from return FALSE, it sends the message. But the return TRUE only changes it if it's already been skinned, and the return FALSE only changes it if it hasn't been skinned. I tested it several times in several different ways and the way I have it now is the only way it works properly as far as I can tell. Obviously it's not required to have them there at all but if they aren't it returns the message "You can not use this object." every time you try to skin the corpse, whether successful or not...
 
Back
Top