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

How to make a NPC respond to lowercase messages aswell?

Kungenn

Veteran OT User
Joined
Jun 10, 2007
Messages
1,625
Reaction score
283
Location
USA California
How can I make my NPC respond to lowercase messages aswell.

Code:
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
function creatureSayCallback(cid, type, msg)
        if(not npcHandler:isFocused(cid)) then
                return false
        end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid        
local spells = {
                [1] = {spell_name = "Antidote" ,price = 150, words = 'EXANA POX', number = 1},
                [2] = {spell_name = "Berserk" ,price = 2500, words = 'EXORI', number = 2},
                [3] = {spell_name = "Blood Rage" ,price = 8000, words = 'UTITO TEMPO', number = 3},
                [4] = {spell_name = "Challenge" ,price = 2000, words = 'EXETA RES', number = 4},
                [5] = {spell_name = "Charge" ,price = 1300, words = 'UTANI TEMPO HUR', number = 5},
                [6] = {spell_name = "Fierce Berserk" ,price = 5000, words = 'EXORI GRAN', number = 6},
                [7] = {spell_name = "Find Person" ,price = 80, words = 'EXIVA', number = 7},
                [8] = {spell_name = "Great Light" ,price = 500, words = 'UTEVO GRAN LUX', number = 8},
                [9] = {spell_name = "Groundshaker" ,price = 1500, words = 'EXORI MAS', number = 9},
                [10] = {spell_name = "Haste" ,price = 600, words = 'UTANI HUR', number = 10},
                [11] = {spell_name = "Levitate" ,price = 500, words = 'EXANI HUR', number = 11},
                [12] = {spell_name = "Light" ,price = 100, words = 'UTEVO LUX', number = 12},
                [13] = {spell_name = "Light Healing" ,price = 170, words = 'EXURA', number = 13},
                [14] = {spell_name = "Magic Rope" ,price = 200, words = 'EXANI TERA', number = 14},
                [15] = {spell_name = "Protector" ,price = 6000, words = 'UTAMO TEMPO', number = 15},
                [16] = {spell_name = "Train Party" ,price = 4000, words = 'UTITO MAS SIO', number = 16},
                [17] = {spell_name = "Whirlwind Throw" ,price = 800, words = 'EXORI HUR', number = 17},
                [18] = {spell_name = "Wound Cleansing" ,price = 300, words = 'EXANA MORT', number = 18},
                }    
for i = 1, #spells do
    if msgcontains(msg, spells[i].spell_name) then
        if getPlayerLearnedInstantSpell(cid, spells[i].spell_name) == false then
            npcHandler:say("Would you like to buy "..spells[i].spell_name.." for "..spells[i].price.." gold?", cid)
            talkState[talkUser] = spells[i].number
        else
            npcHandler:say("You already know how to cast this spell.", cid)
        end
    elseif msgcontains(msg, 'yes') then
        if talkState[talkUser] == spells[i].number then
            if getPlayerMoney(cid) >= spells[i].price then
                doPlayerRemoveMoney(cid, spells[i].price)
                npcHandler:say("To cast this spell say {"..spells[i].words.."}.", cid)
                doPlayerLearnInstantSpell(cid, spells[i].spell_name)
                doSendMagicEffect(getCreaturePosition(cid), 12)
            else
                npcHandler:say("You don\'t have enough money.", cid)
            end
        end
    end
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Right now it only answers to the exact way you write for example it says "Antidote". If I write Antidote the NPC works perfectly but should I write antidote or aNtidote it won't respond at all.

Jiddo helped me fix this with one of my scripts a while ago but I have no clue how to do it again.

Using 0.3.6 tfs :)

Thanks in advance!
 
Back
Top