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

OnUse error

Arkangel Nyx

Member
Joined
Feb 23, 2012
Messages
176
Reaction score
6
Location
U.S.A.
Lua:
 local t, doEet = {
	{x=1761, y=1883, z=10},
	{x=1762, y=1883, z=10},
	{x=1763, y=1883, z=10}
},
function onUse(cid, item)
	for _, v in ipairs(t) do
		doSummonCreature("dragon lord", v)
	end
	addEvent(doEet, 30 * 60000)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have spawned Dragon Lords, take cover!")
end

What the script is meant to do: When you use the item set for this script, it should spawn Three Dragon Lords in the spots mentioned above.

Error: [04/09/2012 12:12:25] [Error - LuaScriptInterface::loadFile] data/actions/scripts/quests/dlquest.lua:6: '(' expected near 'onUse'
[04/09/2012 12:12:25] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/quests/dlquest.lua)
[04/09/2012 12:12:25] data/actions/scripts/quests/dlquest.lua:6: '(' expected near 'onUse'

Rep++
 
You've used the addEvent wrong. You have linked it to a "local variable". But It should look like this, and I hope this works:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local function f(monster)
		local monsterPos = {
			{x=1761, y=1883, z=10},
			{x=1762, y=1883, z=10},
			{x=1763, y=1883, z=10}
		}
		for _, v in ipairs(monsterPos) do
			doSummonCreature(monster, v)
		end
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have spawned ".. monster ..", take cover!")
	end
	
	addEvent(f, 30 * 60000, "dragon lord")
	return true
end
 
Lua:
 function onUse(cid, item, fromPosition, itemEx, toPosition)
	local function f(monster)
		local monsterPos = {
			{x=1761, y=1883, z=10},
			{x=1762, y=1883, z=10},
			{x=1763, y=1883, z=10}
		}
		for _, v in ipairs(monsterPos) do
			doSummonCreature(monster, v)
		end
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have spawned ".. monster ..", take cover!")
	end
 
	addEvent(f, 1000, "dragon lord")
	return true
end

No error. I should mention this...i have this scripting running off a unique id. Im sure that is the problem. What do i need to change in the script?
 
Does it say "Sorry, not possible." or does it say nothing?

Else use this:
XML:
	<action actionid="8450" event="script" value="dls.lua"/>
(without uniqueid)

Edit:

It worked for me with this script:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local function f(monster)
		local monsterPos = {
			{x=1002, y=1006, z=7},
			{x=1002, y=1007, z=7},
			{x=1002, y=1005, z=7}
		}
		for i = 1, #monsterPos do
			doSummonCreature(monster, monsterPos[i])
		end
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have spawned ".. monster ..", take cover!")
	end
 
	addEvent(f, 1000, "dragon lord")
	return true
end
And actionid.
 
Last edited:
It says nothing. problem is the object im using it on is a quest chest. So it already has an actionid of 2000. Is it possible to have it run off two different ones at the same time?
 
Nope, you can't. Else you can just script a chest that is giving the player the choosen items and then activating the dragon-lords spawns
Tell me witch items it gives you in the chest, I'll parse it in into a script so you can just use on the chest and the both activates.
 
I haven't decided on the items yet :O. But i can surely add them in when i do. So i couldnt say...make the chest actionid 2000, then a unique id for the dragon lord script? Btw thanks dude. I got you on rep
 
Else, here you are :)
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local storage = 1000 -- empty storage
	local monsterPos = {
		{x=1002, y=1006, z=7},
		{x=1002, y=1007, z=7},
		{x=1002, y=1005, z=7}
	}
	local itemsInChest = { -- [#] = {itemid, count},
		[1] = {2160, 1},
		[2] = {2153, 1}
	}
	if(getPlayerStorageValue(cid, storage) < 0) then
		setPlayerStorageValue(cid, storage, 1)
		for i = 1, #itemsInChest do
			doPlayerAddItem(cid, itemsInChest[i][1], itemsInChest[i][2])
		end
		
		for i = 1, #monsterPos do
			doSummonCreature("dragon lord", monsterPos[i])
		end
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have spawned dragon lords, take cover!")
	else
		doPlayerSendTextMessage(cid, 25, "It's empty.")
		return false
	end
	return true
end

Edited
 
Last edited:
Error - Action Interface]
[04/09/2012 15:10:58] data/actions/scripts/quests/dlquest.lua:eek:nUse
[04/09/2012 15:10:58] Description:
[04/09/2012 15:10:58] (luaDoCreateNpc) Npc with name '' not found

[04/09/2012 15:10:58] [Error - Action Interface]
[04/09/2012 15:10:58] data/actions/scripts/quests/dlquest.lua:eek:nUse
[04/09/2012 15:10:58] Description:
[04/09/2012 15:10:58] data/actions/scripts/quests/dlquest.lua:18: attempt to concatenate global 'monster' (a nil value)
[04/09/2012 15:10:58] stack traceback:
[04/09/2012 15:10:58] data/actions/scripts/quests/dlquest.lua:18: in function <data/actions/scripts/quests/dlquest.lua:1>
 
Ok i got it working. Thank you, i rep'd ya. If you have anymore time on your hands please shoot me a private message. Got a challenge for ya :p
 
Last edited:
Back
Top