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

Naaano201

Member
Joined
Jun 5, 2011
Messages
241
Reaction score
8
Location
Barcelona
Someone could help me with that errors?
Thanks !



Code:
[10/8/2012 14:29:30] [Error - CreatureScript Interface] 
[10/8/2012 14:29:30] data/creaturescripts/scripts/advancesave.lua:onAdvance
[10/8/2012 14:29:31] Description: 
[10/8/2012 14:29:31] attempt to index a nil value
[10/8/2012 14:29:31] stack traceback:
[10/8/2012 14:29:31] 	[C]: in function 'doSendMagicEffect'
[10/8/2012 14:29:31] 	data/creaturescripts/scripts/advancesave.lua:15: in function <data/creaturescripts/scripts/advancesave.lua:7>

advancedsave.lua
Lua:
local config = {
	savePlayer = true,
	healPlayerOnLevel = true,
	effectType = 30
}

function onAdvance(cid, skill, oldLevel, newLevel)
	if(skill == SKILL__EXPERIENCE) then
		return true
	end

	if(skill == SKILL__LEVEL and config.healPlayerOnLevel) then
		doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
		doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
		doSendMagicEffect(pos, config.effectType)
	end

	if(config.savePlayer) then
		doPlayerSave(cid, true)
	end

	return true
end




Code:
[10/8/2012 14:30:16] [Error - NpcScript Interface] 
[10/8/2012 14:30:16] data/npc/scripts/svargrond_arena.lua:onCreatureSay
[10/8/2012 14:30:16] Description: 
[10/8/2012 14:30:16] data/npc/scripts/svargrond_arena.lua:81: attempt to compare number with boolean
[10/8/2012 14:30:16] stack traceback:
[10/8/2012 14:30:16] 	data/npc/scripts/svargrond_arena.lua:81: in function <data/npc/scripts/svargrond_arena.lua:55>
[10/8/2012 14:30:16] 	[C]: in function 'selfSay'
[10/8/2012 14:30:16] 	data/npc/scripts/svargrond_arena.lua:63: in function <data/npc/scripts/svargrond_arena.lua:55>

svargrond_arena.lua
Lua:
        domodlib('arenaFunctions')
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)             npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)            npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                    npcHandler:onThink()                    end
local focus = 0

local talk_start = 0

local TS = 0



function onCreatureDisappear(cid, pos)

    if focus == cid then

        selfSay('Good bye then.')

        focus = 0

        talk_start = 0

    end

end



local function BYE()

    focus = 0

    talk_start = 0

    TS = 0

end



function msgcontains(txt, str)

      return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))

end



function onCreatureSay(cid, type, msg)



    msg = string.lower(msg)

    if (msgcontains(msg, 'hi') and (focus == 0)) then

        selfSay('Hello ' .. getCreatureName(cid) .. ', Do you want to make arena?.')

          focus = cid

          talk_start = os.clock()

        TS = 1

    elseif msgcontains(msg, 'hi') and (focus ~= cid) then

          selfSay('Im Bussy')

    elseif TS == 1 and msgcontains(msg, 'yes') or msgcontains(msg, 'fight') or msgcontains(msg, 'arena') then

        if getPlayerStorageValue(cid, myArenaLevel) < 3 then

            local enterArena = myArenaLevelIs(cid)

            if getPlayerLevel(cid) >= enterArena.RLV then

                if getPlayerMoney(cid) >= enterArena.RC then

                    setPlayerStorageValue(cid, talkNPC, 1)

                    doPlayerRemoveMoney(cid, enterArena.RC)

                    selfSay("Now you can go to test... ".. enterArena.LN .."")

                    BYE()

                else

                    selfSay("You don\'t have "..enterArena.RC.." gp! Come back when you will be ready!")

                    BYE()

                end

            else

                selfSay("You don\'t have "..enterArena.RLV.." level! Come back when you will be ready!")

                BYE()

            end

        else

            selfSay(Cancel[6])

            BYE()

        end

    elseif TS == 1 and msgcontains(msg, 'no') then

        selfSay("Bye!.")

        BYE()

    elseif msgcontains(msg, 'bye') then

        selfSay("Bye!.")

        BYE()

    end

    return true

end



function onThink()

    doNpcSetCreatureFocus(focus)

    if (os.clock() - talk_start) > 60 then

          if focus > 0 then

              selfSay('Good bye then.')

          end

          focus = 0

      end

end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
advancedsave.lua
Lua:
local config = {
	savePlayer = true,
	healPlayerOnLevel = true,
}
 
function onAdvance(cid, skill, oldLevel, newLevel)
	if(skill == SKILL__EXPERIENCE) then
		return true
	end
 
	if(skill == SKILL__LEVEL and config.healPlayerOnLevel) then
		doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
		doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
		doSendMagicEffect(getPlayerPosition(cid), 30)
	end
 
	if(config.savePlayer) then
		doPlayerSave(cid, true)
	end
 
	return true
end

2.. svargrond_arena.lua
Lua:
dofile("./arena.lua")

local focus = 0
local talk_start = 0
local TS = 0

function onCreatureDisappear(cid, pos)
	if focus == cid then
		selfSay('Good bye then.')
		focus = 0
		talk_start = 0
	end
end

local function BYE()
	focus = 0
	talk_start = 0
	TS = 0
end

function msgcontains(txt, str)
  	return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end

function onCreatureSay(cid, type, msg)

	msg = string.lower(msg)
	if (msgcontains(msg, 'hi') and (focus == 0)) then
		selfSay('Hello ' .. getCreatureName(cid) .. ', Do you want to make arena?.')
  		focus = cid
  		talk_start = os.clock()
		TS = 1
	elseif msgcontains(msg, 'hi') and (focus ~= cid) then
  		selfSay('Im Bussy')
	elseif TS == 1 and msgcontains(msg, 'yes') or msgcontains(msg, 'fight') or msgcontains(msg, 'arena') then
		if getPlayerStorageValue(cid, myArenaLevel) < 3 then
			local enterArena = myArenaLevelIs(cid)
			if getPlayerLevel(cid) >= enterArena.RLV then
				if getPlayerMoney(cid) >= enterArena.RC then
					setPlayerStorageValue(cid, talkNPC, 1)
					doPlayerRemoveMoney(cid, enterArena.RC)
					selfSay("Now you can go to test... ".. enterArena.LN .."")
					BYE()
				else
					selfSay("You don\'t have "..enterArena.RC.." gp! Come back when you will be ready!")
					BYE()
				end
			else
				selfSay("You don\'t have "..enterArena.RLV.." level! Come back when you will be ready!")
				BYE()
			end
		else
			selfSay(Cancel[6])
			BYE()
		end
	elseif TS == 1 and msgcontains(msg, 'no') then
		selfSay("Bye!.")
		BYE()
	elseif msgcontains(msg, 'bye') then
		selfSay("Bye!.")
		BYE()
	end
	return true
end

function onThink()
	doNpcSetCreatureFocus(focus)
	if (os.clock() - talk_start) > 60 then
  		if focus > 0 then
  			selfSay('Good bye then.')
  		end
  		focus = 0
  	end
end
 
Advancedsave.lua worked perfect but the svargrond_arena.lua doesn't work, spam an error all the time.

svargrond_arena.lua
Lua:
[10/8/2012 18:49:45] [Error - NpcScript Interface] 
[10/8/2012 18:49:45] (Unknown script file)
[10/8/2012 18:49:45] Description: 
[10/8/2012 18:49:45] attempt to call a nil value
[10/8/2012 18:49:45] stack traceback:
 
hmm ok use this are you edited
Lua:
function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)             npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)            npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                    npcHandler:onThink()                    end
local focus = 0

local talk_start = 0

local TS = 0



function onCreatureDisappear(cid, pos)

    if focus == cid then

        selfSay('Good bye then.')

        focus = 0

        talk_start = 0

    end

end



local function BYE()

    focus = 0

    talk_start = 0

    TS = 0

end



function msgcontains(txt, str)

      return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))

end



function onCreatureSay(cid, type, msg)



    msg = string.lower(msg)

    if (msgcontains(msg, 'hi') and (focus == 0)) then

        selfSay('Hello ' .. getCreatureName(cid) .. ', Do you want to make arena?.')

          focus = cid

          talk_start = os.clock()

        TS = 1

    elseif msgcontains(msg, 'hi') and (focus ~= cid) then

          selfSay('Im Bussy')

    elseif TS == 1 and msgcontains(msg, 'yes') or msgcontains(msg, 'fight') or msgcontains(msg, 'arena') then

        if getPlayerStorageValue(cid, myArenaLevel) < 3 then

            local enterArena = myArenaLevelIs(cid)

            if getPlayerLevel(cid) >= enterArena.RLV then

                if getPlayerMoney(cid) >= enterArena.RC then

                    setPlayerStorageValue(cid, talkNPC, 1)

                    doPlayerRemoveMoney(cid, enterArena.RC)

                    selfSay("Now you can go to test... ".. enterArena.LN .."")

                    BYE()

                else

                    selfSay("You don\'t have "..enterArena.RC.." gp! Come back when you will be ready!")

                    BYE()

                end

            else

                selfSay("You don\'t have "..enterArena.RLV.." level! Come back when you will be ready!")

                BYE()

            end

        else

            selfSay(Cancel[6])

            BYE()

        end

    elseif TS == 1 and msgcontains(msg, 'no') then

        selfSay("Bye!.")

        BYE()

    elseif msgcontains(msg, 'bye') then

        selfSay("Bye!.")

        BYE()

    end

    return true

end



function onThink()

    doNpcSetCreatureFocus(focus)

    if (os.clock() - talk_start) > 60 then

          if focus > 0 then

              selfSay('Good bye then.')

          end

          focus = 0

      end

end
 
hmm ok use this are you edited
Lua:
function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)             npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)            npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                    npcHandler:onThink()                    end
local focus = 0

local talk_start = 0

local TS = 0



function onCreatureDisappear(cid, pos)

    if focus == cid then

        selfSay('Good bye then.')

        focus = 0

        talk_start = 0

    end

end



local function BYE()

    focus = 0

    talk_start = 0

    TS = 0

end



function msgcontains(txt, str)

      return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))

end



function onCreatureSay(cid, type, msg)



    msg = string.lower(msg)

    if (msgcontains(msg, 'hi') and (focus == 0)) then

        selfSay('Hello ' .. getCreatureName(cid) .. ', Do you want to make arena?.')

          focus = cid

          talk_start = os.clock()

        TS = 1

    elseif msgcontains(msg, 'hi') and (focus ~= cid) then

          selfSay('Im Bussy')

    elseif TS == 1 and msgcontains(msg, 'yes') or msgcontains(msg, 'fight') or msgcontains(msg, 'arena') then

        if getPlayerStorageValue(cid, myArenaLevel) < 3 then

            local enterArena = myArenaLevelIs(cid)

            if getPlayerLevel(cid) >= enterArena.RLV then

                if getPlayerMoney(cid) >= enterArena.RC then

                    setPlayerStorageValue(cid, talkNPC, 1)

                    doPlayerRemoveMoney(cid, enterArena.RC)

                    selfSay("Now you can go to test... ".. enterArena.LN .."")

                    BYE()

                else

                    selfSay("You don\'t have "..enterArena.RC.." gp! Come back when you will be ready!")

                    BYE()

                end

            else

                selfSay("You don\'t have "..enterArena.RLV.." level! Come back when you will be ready!")

                BYE()

            end

        else

            selfSay(Cancel[6])

            BYE()

        end

    elseif TS == 1 and msgcontains(msg, 'no') then

        selfSay("Bye!.")

        BYE()

    elseif msgcontains(msg, 'bye') then

        selfSay("Bye!.")

        BYE()

    end

    return true

end



function onThink()

    doNpcSetCreatureFocus(focus)

    if (os.clock() - talk_start) > 60 then

          if focus > 0 then

              selfSay('Good bye then.')

          end

          focus = 0

      end

end


Error:
Lua:
[10/8/2012 19:5:40] [Error - NpcScript Interface] 
[10/8/2012 19:5:40] data/npc/scripts/svargrond_arena.lua:onCreatureSay
[10/8/2012 19:5:40] Description: 
[10/8/2012 19:5:40] data/npc/scripts/svargrond_arena.lua:73: attempt to call global 'myArenaLevelIs' (a nil value)
[10/8/2012 19:5:40] stack traceback:
[10/8/2012 19:5:40] 	data/npc/scripts/svargrond_arena.lua:73: in function <data/npc/scripts/svargrond_arena.lua:49>
[10/8/2012 19:5:40] 	[C]: in function 'selfSay'
[10/8/2012 19:5:40] 	data/npc/scripts/svargrond_arena.lua:57: in function <data/npc/scripts/svargrond_arena.lua:49>
 
hmm ok see try this
Its works for me
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid)			end
function onCreatureDisappear(cid) 			npcHandler:onCreatureDisappear(cid)			end
function onCreatureSay(cid, type, msg) 		npcHandler:onCreatureSay(cid, type, msg)	end
function onThink() 							npcHandler:onThink()						end

function enterArena(cid, message, keywords, parameters, node)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	local cost = 0
	local levelname = ''
	if getPlayerStorageValue(cid, 42355) < 1 then
		cost = 1000
		levelname = 'greenshore'
		levelneeded = 30
	elseif getPlayerStorageValue(cid, 42355) == 1 then
		cost = 5000
		levelname = 'scrapper'
		levelneeded = 50
	elseif getPlayerStorageValue(cid, 42355) == 2 then
		cost = 10000
		levelname = 'warlord'
		levelneeded = 80
	end
	if string.lower(keywords[1]) == 'yes' and parameters.prepare ~= 1 then
		if(getPlayerLevel(cid) >= levelneeded) then
			if(getPlayerMoney(cid) >= cost) then
				doPlayerRemoveMoney(cid, cost)
				npcHandler:say('Now you can go to test.', cid)
				setPlayerStorageValue(cid, 42351, 1)
			else
				npcHandler:say('You don\'t have ' .. cost .. ' gp! Come back when you will be ready!', cid)
		    end
		else
			npcHandler:say('You don\'t have ' .. levelneeded .. ' level! Come back when you will be ready!', cid)
		end
		npcHandler:resetNpc()
	elseif string.lower(keywords[1]) == 'no' then
		npcHandler:say('Come back later then!', cid)
		npcHandler:resetNpc()
	else
		if getPlayerStorageValue(cid, 42355) < 3 then
			npcHandler:say('You test will be ' .. levelname .. ' level. If you want enter you must pay ' .. cost .. ' gp and have ' .. levelneeded .. ' level. Wanna try?', cid)
		else
			npcHandler:say('You did all arena levels.',cid)
		end
	end
	return true
end

npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|! Do you want to make arena?')

local yesNode = KeywordNode:new({'yes'}, enterArena, {})
local noNode = KeywordNode:new({'no'}, enterArena, {})

local node1 = keywordHandler:addKeyword({'arena'}, enterArena, {prepare=1})
	node1:addChildKeywordNode(yesNode)
	node1:addChildKeywordNode(noNode)
	
local node1 = keywordHandler:addKeyword({'fight'}, enterArena, {prepare=1})
	node1:addChildKeywordNode(yesNode)
	node1:addChildKeywordNode(noNode)
local node1 = keywordHandler:addKeyword({'yes'}, enterArena, {prepare=1})
	node1:addChildKeywordNode(yesNode)
	node1:addChildKeywordNode(noNode)
npcHandler:addModule(FocusModule:new())
 
Back
Top