• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved "Use hammer" on object to "set storage"

ziggy46802

Active Member
Joined
Aug 19, 2012
Messages
418
Reaction score
27
How do I make a script whereas when I use item id "carpenter hammer" on item id "sign", it sets a players storage value.
 
Last edited:
LUA:
local key = 123

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if itemEx.itemid == 1429 then
		if getCreatureStorage(cid, key) == -1 then
			doCreatureSetStorage(cid, key, 1)
			doCreatureSay(cid, 'Success', TALKTYPE_ORANGE_1)
		else
			doCreatureSay(cid, 'Failure', TALKTYPE_ORANGE_1)
		end
	end

	return true
end
 
With this in actions.xml

Code:
	<action itemid="2557" event="script" value="quests/brokensign.lua"/>

and this script

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if itemEx.itemid == 5361 then
		if getCreatureStorageValue(cid, 1005) < 2 then
			doCreatureSetStorage(cid, 1005, 2)
			doCreatureSay(cid, 'You fixed the sign!', TALKTYPE_ORANGE_1)
		else
			doCreatureSay(cid, 'You did not do something right, the sign is still broken.', TALKTYPE_ORANGE_1)
		end
	end
 
	return true
end

I'm getting this error:

Code:
[25/09/2012 23:54:48] data/actions/scripts/quests/brokensign.lua:5: attempt to call global 'getCreatureStorageValue' (a nil value)
[25/09/2012 23:54:48] stack traceback:
[25/09/2012 23:54:48] 	data/actions/scripts/quests/brokensign.lua:5: in function <data/actions/scripts/quests/brokensign.lua:3>

- - - Updated - - -

I tried this in actions.xml

Code:
	<action actionid="1005" event="script" value="quests/brokensign.lua"/>

with this script

Code:
local key = 1005
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 2557 and itemEx.itemid == 5361 then
		if getPlayerStorageValue(cid, key) == 1 then
			setPlayerStorageValue(cid, key, 2)
			doCreatureSay(cid, 'Success', TALKTYPE_ORANGE_1)
		elseif getPlayerStorageValue(cid, key) == 2 then
			doCreatureSay(cid, 'You already fixed the sign', TALKTYPE_ORANGE_1)
			else
			doCreatureSay(cid, 'You need a hammer', TALKTYPE_ORANGE_1)
		end
	end
 
	return true
end

and nothing happens when I use the sign or when I use the hammer on the sign...


this code worked
Code:
local key = 123
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if itemEx.itemid == 1429 then
		if getCreatureStorage(cid, key) == -1 then
			doCreatureSetStorage(cid, key, 1)
			doCreatureSay(cid, 'Success', TALKTYPE_ORANGE_1)
		else
			doCreatureSay(cid, 'Failure', TALKTYPE_ORANGE_1)
		end
	end
 
	return true
end
but it worked when I just "used" the sign, I want it so that you have to use a carpenter hammer (2557) on the sign to set the storage value, how do I do that?
 
Last edited:
You gave the actionid to the sign...

You need to use this line:

Code:
<action itemid="1005" event="script" value="quests/brokensign.lua"/>
In itemid put the id of the hammer...

Code:
local key = 123
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if itemEx.itemid == 1429 and itemEx.actionid == 1005 then
		if getCreatureStorage(cid, key) == -1 then
			doCreatureSetStorage(cid, key, 1)
			doCreatureSay(cid, 'Success', TALKTYPE_ORANGE_1)
		else
			doCreatureSay(cid, 'Failure', TALKTYPE_ORANGE_1)
		end
	end
 
	return true
end

Actionid 1005 to the sign...

And it will work only in that sign and only when it's used the hammer on it...
 
Back
Top