• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

NPC not working

Frillinde

Founder: Another Realm
Joined
Jan 16, 2012
Messages
148
Reaction score
3
Location
his computer
I made an npc. It has error "'end' expected (to close 'if' at line 46) near 'else'"....I am not good with lua and realize that,...all I can see is maybe I need 13 ends????lol I have no clue.
:)
Anyhow NPC is
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Wallin" script="tutor1.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="160" head="95" body="94" legs="132" feet="118" addons="0"/> <parameters></parameters>
</npc>

and LUA is
local quest = 2005

if getPlayerStorageValue(cid, quest) == 0 then
doPlayerSendTextMessage(cid, 19, "May I help you with something?")
if msgcontains(msg, 'Tutor Quest')
then
doPlayerSendTextMessage(cid, 19, "Would you like to start the Tutor Quest?")
if msgcontains(msg, 'yes')
then
doPlayerSendTextMessage(cid, 19, "Ok then, You need to speak to Curtis in Ebanor to continue this quest.")
setPlayerStorageValue(cid, quest, 1)
else
if getPlayerStorageValue(cid, quest) == 1 then
doPlayerSendTextMessage(cid, 19, "You should go see Curtis in Ebanor to continue this quest")
else
if getPlayerStorageValue(cid, quest) == 2 then
doPlayerSendTextMessage(cid, 19, "You should go see Brunelle in Duzanne to continue this quest")
else
if getPlayerStorageValue(cid, quest) == 3 then
doPlayerSendTextMessage(cid, 19, "You should go see Gomar at the Southern Post to continue this quest")
else
if getPlayerStorageValue(cid, quest) == 4 then
doPlayerSendTextMessage(cid, 19, "You should go see Braat in Tidus to continue this quest")
else
if getPlayerStorageValue(cid, quest) == 5 then
doPlayerSendTextMessage(cid, 19, "You should go see Freesin in Rundan to continue this quest")
else
if getPlayerStorageValue(cid, quest) == 6 then
doPlayerSendTextMessage(cid, 19, "You should go see Taldorian in Numbring to continue this quest")
else
if getPlayerStorageValue(cid, quest) == 7 then
doPlayerSendTextMessage(cid, 19, "You should go see Fexnir on the Plains of Gormaak to continue this quest")
else
if getPlayerStorageValue(cid, quest) == 8 then
doPlayerSendTextMessage(cid, 19, "You should go see Jolly in Kelbin to continue this quest")
else
if getPlayerStorageValue(cid, quest) == 9 then
doPlayerSendTextMessage(cid, 19, "You should go see Poani at the Northern post to continue this quest")
else
if getPlayerStorageValue(cid, quest) == 10 then
doPlayerSendTextMessage(cid, 19, "You should go see Te'Zethel on the Isle of Timarlane to continue this quest")
else
if getPlayerStorageValue(cid, quest) == 11 then
doPlayerSendTextMessage(cid, 19, "You should go see Delbert in Bendro to continue this quest")
else
if getPlayerStorageValue(cid, quest) == 12 then
doPlayerSendTextMessage(cid, 19, "You should go see Ferdelus in Roshka to continue this quest")
else
if getPlayerStorageValue(cid, quest) == 13 then
doPlayerSendTextMessage(cid, 19, "You should go see Gormel in Caldor to continue this quest")
end
if getPlayerGroupId(cid) > "1" then
doPlayerSendCancel(cid, "The life of a tutor can be hard at times...")
end
else
doPlayerSendTextMessage(cid, 19, "I'm sorry but I can't help you right now.")
end

Again,I know its probably not even close to being right but Im trying to teach myself the lua stuff.
If anyone is bored and wants to help me learn I'd really appreciate it .

:)
 
What kind of NPC is this? It doesnt look like jiddo's system or the old way? First of all you need to tab your script so you can see where your end's are missing and what is going on. Here I have done that for you and you can see almost all of the "if"s are missing an end. Also then should be on the same line as the condition check just so its easier to read and perhaps you ment to use "elseif" as one word as it is different all together then using "else" straight away followed by "if". You can see it in this:
Lua:
local quest = 2005

if getPlayerStorageValue(cid, quest) == 0 then
    doPlayerSendTextMessage(cid, 19, "May I help you with something?")
    
    if msgcontains(msg, 'Tutor Quest') then
        doPlayerSendTextMessage(cid, 19, "Would you like to start the Tutor Quest?")
        
        if msgcontains(msg, 'yes') then
            doPlayerSendTextMessage(cid, 19, "Ok then, You need to speak to Curtis in Ebanor to continue this quest.")
            setPlayerStorageValue(cid, quest, 1)
        else
            if getPlayerStorageValue(cid, quest) == 1 then
                doPlayerSendTextMessage(cid, 19, "You should go see Curtis in Ebanor to continue this quest")
            else
                if getPlayerStorageValue(cid, quest) == 2 then
                    doPlayerSendTextMessage(cid, 19, "You should go see Brunelle in Duzanne to continue this quest")
                else
                    if getPlayerStorageValue(cid, quest) == 3 then
                        doPlayerSendTextMessage(cid, 19, "You should go see Gomar at the Southern Post to continue this quest")
                    else
                        if getPlayerStorageValue(cid, quest) == 4 then
                            doPlayerSendTextMessage(cid, 19, "You should go see Braat in Tidus to continue this quest")
                        else
                            if getPlayerStorageValue(cid, quest) == 5 then
                                doPlayerSendTextMessage(cid, 19, "You should go see Freesin in Rundan to continue this quest")
                            else
                                if getPlayerStorageValue(cid, quest) == 6 then
                                    doPlayerSendTextMessage(cid, 19, "You should go see Taldorian in Numbring to continue this quest")
                                else
                                    if getPlayerStorageValue(cid, quest) == 7 then
                                        doPlayerSendTextMessage(cid, 19, "You should go see Fexnir on the Plains of Gormaak to continue this quest")
                                    else
                                        if getPlayerStorageValue(cid, quest) == 8 then
                                            doPlayerSendTextMessage(cid, 19, "You should go see Jolly in Kelbin to continue this quest")
                                        else
                                            if getPlayerStorageValue(cid, quest) == 9 then
                                                doPlayerSendTextMessage(cid, 19, "You should go see Poani at the Northern post to continue this quest")
                                            else
                                                if getPlayerStorageValue(cid, quest) == 10 then
                                                    doPlayerSendTextMessage(cid, 19, "You should go see Te'Zethel on the Isle of Timarlane to continue this quest")
                                                else
                                                    if getPlayerStorageValue(cid, quest) == 11 then
                                                        doPlayerSendTextMessage(cid, 19, "You should go see Delbert in Bendro to continue this quest")
                                                    else
                                                        if getPlayerStorageValue(cid, quest) == 12 then
                                                            doPlayerSendTextMessage(cid, 19, "You should go see Ferdelus in Roshka to continue this quest")
                                                        else
                                                            if getPlayerStorageValue(cid, quest) == 13 then
                                                                doPlayerSendTextMessage(cid, 19, "You should go see Gormel in Caldor to continue this quest")
                                                            end ---you put this end here it is needed
                                                            
                                                            if getPlayerGroupId(cid) > "1" then
                                                                doPlayerSendCancel(cid, "The life of a tutor can be hard at times...")
                                                            --end --- you had an "end" here and it would make the following "else" useless and give you errors
                                                            else
                                                                doPlayerSendTextMessage(cid, 19, "I'm sorry but I can't help you right now.")
                                                            end
                                                        end ---you need an "end" here to to finish the "if" on the same tab row
                                                    end ---you need an "end" here to to finish the "if" on the same tab row
                                                end ---you need an "end" here to to finish the "if" on the same tab row
                                            end ---you need an "end" here to to finish the "if" on the same tab row
                                        end ---you need an "end" here to to finish the "if" on the same tab row
                                    end ---you need an "end" here to to finish the "if" on the same tab row
                                end ---you need an "end" here to to finish the "if" on the same tab row
                            end ---you need an "end" here to to finish the "if" on the same tab row
                        end ---you need an "end" here to to finish the "if" on the same tab row
                    end ---you need an "end" here to to finish the "if" on the same tab row
                end ---you need an "end" here to to finish the "if" on the same tab row
            end ---you need an "end" here to to finish the "if" on the same tab row
        end ---you need an "end" here to to finish the "if" on the same tab row
    end ---you need an "end" here to to finish the "if" on the same tab row
end ---you need an "end" here to to finish the "if" on the same tab row

This script wont give you any errors when you load it but hopefully you can see that it wont do what you want it to do.
 
lol I told ya I wasn't good at LUA.
;p
I tried to make it using different npc's I had on file, tryin to use their commands as some sort of reference.I havent found any tutorial thats helped me....either too basic or way over my head.

The NPC is for a quest on my server,there is 15 of them in a series to goto to complete it.

Which parts of this (other than the whole thing lol) do I need to add to to get to work or should I try something totally different?

Thanks for doing the above, at least I can use it to help me figure out where the ends and such should go.
 
Ok now i think I got all bugs out but now Im trying to figure out how to add to actions xml and sytem lua.


here is newest npc version(lol)

[QUOTElocal config = {
quest_one = 34450,
quest_two = 34451,
quest_three = 34452,
quest_four = 34453,
quest_five = 34454,
quest_six = 34455,
quest_seven = 34456,
quest_eight = 34457,
quest_nine = 34458,
quest_ten = 34459,
quest_eleven = 34460,
quest_twelve = 34461,
quest_thirteen = 34462
}
if getPlayerStorageValue(cid, quest_one) == 0 then
doPlayerSendTextMessage(cid, 19, "May I help you with something?")
if msgcontains(msg, 'Tutor Quest')
then
doPlayerSendTextMessage(cid, 19, "Would you like to start the Tutor Quest?")
if msgcontains(msg, 'yes')
then
doPlayerSendTextMessage(cid, 19, "Ok then, You need to speak to Curtis in Ebanor to continue this quest.")
setPlayerStorageValue(cid, quest_one, 1)
else
doPlayerSendTextMessage(cid, 19, "I'm sorry but I can't help you right now.")
end end end][/QUOTE]

So if someone can explain the quest adding part Id really appreciate it.The annihilator part in systems lua has me messed up.
:)
 
Back
Top