• 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!

Script error

tiddpd

PHP Scripter
Joined
Apr 16, 2008
Messages
331
Reaction score
0
I have this script to remove a statue when the lever is pulled, then to appear again when its pulled again, put I can only pull the lever once, and it wont go back to make the statue reapear, whats wrong with this script?

function onUse(cid, item, frompos, item2, topos)
statuepos1 = {x=286, y=95, z=10, stackpos=1}
statue1 = getThingfromPos(statuepos1)
if item.itemid == 1945 and item.uid == 6541 then
doRemoveItem(statue1.uid,4444)
doTransformItem(item.uid,1946)
doPlayerSendTextMessage(cid,22,"Something has just magically disapeared.")
elseif(item.itemid == 1946 and item.uid == 6541) then
doCreateItem(statue1.uid,4444)
doTransformItem(item.uid,1945)
doPlayerSendTextMessage(cid,22,"Something just magically appeared.")
else
doPlayerSendTextMessage(cid,22,"Sorry, not possible.")
end
end
 
Try this:
function onUse(cid, item, frompos, item2, topos)
statuepos1 = {x=286, y=95, z=10, stackpos=1}
statue1 = getThingfromPos(statuepos1)
if item.itemid == 1945 and item.uid == 6541 then
doRemoveItem(statue1.uid,4444)
doTransformItem(item.uid,1946)
doPlayerSendTextMessage(cid,22,"Something has just magically disapeared.")
elseif item.itemid == 1946 and item.uid == 6541 then
doCreateItem(4444, 1, statuepos1)
doTransformItem(item.uid,1945)
doPlayerSendTextMessage(cid,22,"Something just magically appeared.")
else
doPlayerSendTextMessage(cid,22,"Sorry, not possible.")
end
end
 
um it still gives me an error saying "attempt to index a number value traceback" on the function doCreateItem
 
Code:
function onUse(cid, item, frompos, item2, topos)

	local statuePos = {x = 286, y = 95, z = 10, stackpos=1}
	local statue = getThingfromPos(statuePos)
	
	if item.itemid == 1945 and item.uniqueid == 6541 then
		doRemoveItem(statue.uid,4444)
		doTransformItem(item.uid,1946)
		doPlayerSendTextMessage(cid,22,"Something has just magically disapeared.")
	elseif(item.itemid == 1946 and item.uniqueid == 6541) then
		doCreateItem(4444,1,statuePos)
		doTransformItem(item.uid,1945) 
		doPlayerSendTextMessage(cid,22,"Something just magically appeared.")
	else
		doPlayerSendTextMessage(cid,22,"Sorry, not possible.")
	end
end
 
Last edited:
it still gives me the error "attempt to index number value" after the lever is pulled once, as in the object disapears, but script doesnt work for making it reapear
 
nevermind, i thought i reloaded actions but i guess i didnt, i don't get an error message anymore, but it still doesnt make the object reapear when the lever is pulled, just the "sorry, not possible" comes up
 
Try this one instead. Sorry for all the mess... :p

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

	local statuePos = {x = 286, y = 95, z = 10, stackpos=1}
	local statuePos2 = {x = 286, y = 95, z = 10}
	local statue = getThingfromPos(statuePos)
	
	if item.itemid == 1945 then
		doRemoveItem(statue.uid,4444)
		doTransformItem(item.uid,1946)
		doPlayerSendTextMessage(cid,22,"Something has just magically disapeared.")
	elseif item.itemid == 1946 then
		doCreateItem(4444,1,statuePos2)
		doTransformItem(item.uid,1945) 
		doPlayerSendTextMessage(cid,22,"Something just magically appeared.")
	end
end
 
Back
Top