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

Solved Simple script error

bybbzan

mapper
Joined
Aug 4, 2012
Messages
809
Solutions
2
Reaction score
136
Location
Sweden
Hello.

Im trying to edit @Cykotitan 's script so it fits my quest.
But i do get this error:
Code:
[Error - Action Interface]
data/actions/scripts/quests/ultimate challenge/statues.lua:onUse
Description:
...ctions/scripts/quests/ultimate challenge/statues.lua:17: attempt to index glo
bal 'pos' (a nil value)
stack traceback:
        ...ctions/scripts/quests/ultimate challenge/statues.lua:17: in function
<...ctions/scripts/quests/ultimate challenge/statues.lua:8>

script
LUA:
local t = {
	[30018] = {'Balrog of fire', CONST_ME_MAGIC, 15},
	[30019] = {'Balrog of earth', CONST_ME_MAGIC, 45},
	[30020] = {'Balrog of ice', CONST_ME_MAGIC, 42},
	[30021] = {'Balrog of energy', CONST_ME_MAGIC, 47}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isPlayer(cid) == TRUE then
		local f = t[item.uid]
		if getPlayerStorageValue(cid, item.uid) == -1 then
			setPlayerStorageValue(cid, item.uid, 1)
			doSendMagicEffect(pos, f[2])
			doCreatureSay(cid, 'You have touched '..f[1]..'\'s holy statue and absorbed some spirit.', TALKTYPE_ORANGE_1)
		else
			if item.itemid == 1451 then
				pos.y = pos.y + f[3]
			elseif item.itemid == 1451 then
				pos.x = pos.x + f[3]
			end
			doCreatureSay(cid, 'Already done!', TALKTYPE_ORANGE_1)	
		end
	end
end

actions.xml
LUA:
	<action uniqueid="30018" event="script" value="quests/ultimate challenge/statues.lua"/>	
	<action uniqueid="30019" event="script" value="quests/ultimate challenge/statues.lua"/>
	<action uniqueid="30020" event="script" value="quests/ultimate challenge/statues.lua"/>
	<action uniqueid="30021" event="script" value="quests/ultimate challenge/statues.lua"/>

Please help.
rep+
 
Try this:
PHP:
local t = {
	[30018] = {'Balrog of fire', CONST_ME_MAGIC, 15},
	[30019] = {'Balrog of earth', CONST_ME_MAGIC, 45},
	[30020] = {'Balrog of ice', CONST_ME_MAGIC, 42},
	[30021] = {'Balrog of energy', CONST_ME_MAGIC, 47}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isPlayer(cid) == TRUE then
		local f = t[item.uid]
		if getPlayerStorageValue(cid, item.uid) == -1 then
			setPlayerStorageValue(cid, item.uid, 1)
			doSendMagicEffect(fromPosition, f[2])
			doCreatureSay(cid, 'You have touched '..f[1]..'\'s holy statue and absorbed some spirit.', TALKTYPE_ORANGE_1)
		else
			if item.itemid == 1451 then
				toPosition.y = toPosition.y + f[3]
			elseif item.itemid == 1451 then
				toPosition.x = toPosition.x + f[3]
			end
			doCreatureSay(cid, 'Already done!', TALKTYPE_ORANGE_1)	
		end
	end
end
 
Back
Top