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

summon monster lever with timer

kipler

New Member
Joined
Sep 19, 2009
Messages
11
Reaction score
0
posting on here to for help

ok.. i have a script that summons a demon when you pull the lever, only issue is i want to add a timer to it so people cant abuse it.
heres the working script


Code:
local pos = {x=608, y=602, z=10}
function onUse(cid, item, frompos, item2, topos)
    if item.itemid == 1945 and item.uid == 2002 then
        doSummonCreature("demon", pos)
        return TRUE
    end
end
now heres the edit i tried to do to add a timer:



Code:
local pos = {x=608, y=602, z=10}
function onUse(cid, item, frompos, item2, topos)
    timetoreset = 20000 -- enter another time, 20 secs now
    if item.itemid == 1945 and item.uid == 2002 then
        doSummonCreature("demon", pos)
		addEvent(callback, timetoreset)
        return TRUE
    end
end
function callback(timetoreset)
    if item.itemid ~= 0 then
        doTransformItem(item.uid, 1945)
return 1
end
end
thats how far it got to at least make the script working to summon. the error that i get with this is the item comes up as a nil value

i'm pretty sure i'm missing something and i most likely did a backwards screwy way to get what i did. pretty new to scripting these things still.

any help is appreciated and of course rep+ to those that help out
thanks in advanced
 
Code:
local config = {
	pos = {x=608, y=602, z=10},
	reset = 20 -- Seconds
}

local function reset(pos)
	local thing = getTileItemById(pos, 1946).uid
	return thing > 0 and doTransformItem(thing, 1945)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(item.itemid == 1945) then
		doSummonCreature("Demon", config.pos)
		addEvent(reset, config.reset * 1000, fromPosition)
		return TRUE
	end
	return FALSE
end

I think I have the "addEvent" correct. :p
Nope, o_O
 
Last edited:
hrm.. ok, trying your script cykotitan.
i get an error with the timer event:

[19/11/2009 14:37:42] ...ata/actions/scripts/quests/femurbrassummonswitch.lua:13: attempt to perform arithmetic on field 'reset' (a nil value)
[19/11/2009 14:37:42] stack traceback:
[19/11/2009 14:37:42] ...ata/actions/scripts/quests/femurbrassummonswitch.lua:13: in function <...ata/actions/scripts/quests/femurbrassummonswitch.lua:10>

playing around with it still to see if i can get it, but so far no luck
 
Last edited:
whoops sorry
first error was unexpected symbol near local on line 4, so i moved it to line 2 and that part worked

Code:
local config = {
	pos = {x=608, y=602, z=10}}
	reset = 20 -- seconds

local function reset(pos)
	local thing = getTileItemById(pos, 1946).uid
	return thing > 0 and doTransformItem(thing, 1945)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(item.itemid == 1945) then
		doSummonCreature("Demon", config.pos)
		addEvent(reset, config.reset * 1000, fromPosition)
		return TRUE
	end
	return FALSE
end
 
Teste it XD

local config = {
pos = {x=608, y=602, z=10},
reset = 20 -- seconds}

local function reset(pos)
local thing = getTileItemById(pos, 1946).uid
doSummonCreature("Demon", config.pos)
return thing > 0 and doTransformItem(thing, 1945)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
if(item.itemid == 1945) then
addEvent(reset, config.reset * 1000, fromPosition)
return TRUE
end
return FALSE
end
 
Back
Top