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

Lua Default Idle Error?

Exedion

Active Member
Joined
Jun 11, 2007
Messages
628
Reaction score
30
i have this error with the idle creature event:

Code:
[16:52:02.635] [Error - CreatureScript Interface]
[16:52:02.636] data/creaturescripts/scripts/idle.lua:onThink
[16:52:02.639] Description:
[16:52:02.640] data/creaturescripts/scripts/idle.lua:12: attempt to perform arit
hmetic on local 'interval' (a table value)
[16:52:02.642] stack traceback:
[16:52:02.643]  data/creaturescripts/scripts/idle.lua:12: in function <data/crea
turescripts/scripts/idle.lua:6>

and this is my script:

Lua:
local config = {
	idleWarning = getConfigValue('idleWarningTime'),
	idleKick = getConfigValue('idleKickTime')
}

function onThink(cid, interval)
	if(getTileInfo(getCreaturePosition(cid)).nologout or getCreatureNoMove(cid) or
		getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_ALLOWIDLE)) then
		return true
	end

	local idleTime = getPlayerIdleTime(cid) + interval
	doPlayerSetIdleTime(cid, idleTime)
	if(config.idleKick > 0 and idleTime > config.idleKick) then
		doRemoveCreature(cid)
	elseif(config.idleWarning > 0 and idleTime == config.idleWarning) then
		local message = "You have been idle for " .. math.ceil(config.idleWarning / 60000) .. " minutes"
		if(config.idleKick > 0) then
			message = message .. ", you will be disconnected in "
			local diff = math.ceil((config.idleWarning - config.idleKick) / 60000)
			if(diff > 1) then
				message = message .. diff .. " minutes"
			else
				message = message .. "one minute"
			end

			message = message .. " if you are still idle"
		end

		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, message .. ".")
	end

	return true
end

and this the line of the error:
Lua:
	local idleTime = getPlayerIdleTime(cid) + interval

with this, i can't cast spells!! o_O i don't understend... please help!
 
change 7th and 8th lines to:
Lua:
    if(getTileInfo(getCreaturePosition(cid)).nologout or getCreatureNoMove(cid) or
        getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_ALLOWIDLE)) or not isPlayer(cid) then
 
Back
Top