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

Own NPC Arena!

jpkulik

New Member
Joined
Mar 15, 2008
Messages
208
Reaction score
2
Hello Guys!
Im doing an Own NPC Arena.. And while im doing the first arena script i got an erro. Can some one help?
Script:
PHP:
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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
------------Arena 1--------------
	local arena1cost = 0
	local arena1name = 'greenhorn'
	local arena1level = 30 
	local arena1cost = 1000
	local arena1storage = 5555
-----------Arena 1 End-----------
	
	
	if msgcontains(msg, 'greenhorn') and getPlayerStorageValue(cid, 5555) < 1 then
	npcHandler:say('Do you really want to do the '..arena1name..' arena for players of level '..arena1level..' or more, paying the price of '..arena1cost..' Gold Coins?', cid)
	talk_state = 1
	
	elseif msgcontains(msg, 'yes') and talk_state == 1 then
	if(getPlayerLevel(cid) >= arena1level) then
	if(getPlayerMoney(cid) >= arena1cost) then
	npcHandler:say('Ok! Good look in the '..arena1name..' arena.', cid)
	setPlayerStorageValue(cid, 5555, 1)
	else
	npcHandler:say('You do not have '..arena1cost..' Gold Coins! Come back when you have it!', cid)
	end
	else
	npcHandler:say('You are not level '..arena1level..'! Come back when you have it!', cid)
	end

Error:
Code:
[23/01/2009 18:06:07] [Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/arena.lua
[23/01/2009 18:06:07] data/npc/scripts/arena.lua:18: 'end' expected (to close 'if' at line 15) near 'local'

Cya!
 
Fixed:

PHP:
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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
		end
------------Arena 1--------------
    local arena1cost = 0
    local arena1name = 'greenhorn'
    local arena1level = 30 
    local arena1cost = 1000
    local arena1storage = 5555
-----------Arena 1 End-----------
    
    
    if msgcontains(msg, 'greenhorn') and getPlayerStorageValue(cid, 5555) < 1 then
    npcHandler:say('Do you really want to do the '..arena1name..' arena for players of level '..arena1level..' or more, paying the price of '..arena1cost..' Gold Coins?', cid)
    talk_state = 1
    
    elseif msgcontains(msg, 'yes') and talk_state == 1 then
    if(getPlayerLevel(cid) >= arena1level) then
    if(getPlayerMoney(cid) >= arena1cost) then
    npcHandler:say('Ok! Good look in the '..arena1name..' arena.', cid)
    setPlayerStorageValue(cid, 5555, 1)
    else
    npcHandler:say('You do not have '..arena1cost..' Gold Coins! Come back when you have it!', cid)
    end
    else
    npcHandler:say('You are not level '..arena1level..'! Come back when you have it!', cid)
    end

Your error:

function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false

You missed 1 end in there above return false!
 
Now i got this script:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end
-- OTServ event handling functions end

npcHandler:addModule(FocusModule:new())


------------Arena 1--------------
local arena1cost = 0
local arena1name = 'greenhorn'
local arena1level = 30
local arena1cost = 1000
local arena1storage = 5555
-----------Arena 1---------------


if msgcontains(msg, 'greenhorn') and getPlayerStorageValue(cid, 5555) < 1 then
npcHandler:say('Do you really want to do the '..arena1name..' arena for players of level '..arena1level..' or more, paying the price of '..arena1cost..' Gold Coins?', cid)
talk_state = 1

elseif msgcontains(msg, 'yes') and talk_state == 1 then
if(getPlayerLevel(cid) >= arena1level) then
if(getPlayerMoney(cid) >= arena1cost) then
npcHandler:say('Ok! Good look in the '..arena1name..' arena.', cid)
setPlayerStorageValue(cid, 5555, 1)
else
npcHandler:say('You do not have '..arena1cost..' Gold Coins! Come back when you have it!', cid)
end
else
npcHandler:say('You are not level '..arena1level..'! Come back when you have it!', cid)
end
And this error:
[24/01/2009 08:30:46] [Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/arena.lua
[24/01/2009 08:30:46] data/npc/scripts/arena.lua:40: '<eof>' expected near 'end'
Can someone help me quick?
Ty!
 
Here you go:

PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandlernCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandlernCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandlernCreatureSay(cid, type, msg) end
function onThink() npcHandlernThink() end
-- OTServ event handling functions end

npcHandler:addModule(FocusModule:new())


------------Arena 1--------------
local arena1cost = 0
local arena1name = 'greenhorn'
local arena1level = 30
local arena1cost = 1000
local arena1storage = 5555
-----------Arena 1---------------


if msgcontains(msg, 'greenhorn') and getPlayerStorageValue(cid, 5555) < 1 then
npcHandler:say('Do you really want to do the '..arena1name..' arena for players of level '..arena1level..' or more, paying the price of '..arena1cost..' Gold Coins?', cid)
talk_state = 1

elseif msgcontains(msg, 'yes') and talk_state == 1 then
if(getPlayerLevel(cid) >= arena1level) then
if(getPlayerMoney(cid) >= arena1cost) then
npcHandler:say('Ok! Good look in the '..arena1name..' arena.', cid)
setPlayerStorageValue(cid, 5555, 1)
else
npcHandler:say('You do not have '..arena1cost..' Gold Coins! Come back when you have it!', cid)
end
else
npcHandler:say('You are not level '..arena1level..'! Come back when you have it!', cid)
end 
end
 
Back
Top