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

Solved TFS 1.X attempt to concatenate a boolean value

johnsamir

Advanced OT User
Joined
Oct 13, 2009
Messages
965
Solutions
6
Reaction score
164
Location
Nowhere
When i greet this npc the server is displaying this error in console:
Code:
Lua Script Error: [Npc interface]
data/npc/scripts/test.lua:onCreatureSay
data/npc/scripts/test.lua:15: attempt to concatenate a boolean value
stack traceback:
        [C]: in function '__concat'
        data/npc/scripts/Nielson.lua:15: in function 'callback'
        data/npc/scripts/lib/npcsystem/npchandler.lua:344: in function 'greet'
        data/npc/scripts/lib/npcsystem/npchandler.lua:523: in function 'onGreet'
        data/npc/scripts/lib/npcsystem/modules.lua:250: in function 'callback'
        data/npc/scripts/lib/npcsystem/keywordhandler.lua:26: in function 'processMessage'
        data/npc/scripts/lib/npcsystem/keywordhandler.lua:151: in function 'processNodeMessage'
        data/npc/scripts/lib/npcsystem/keywordhandler.lua:119: in function 'processMessage'
        data/npc/scripts/lib/npcsystem/npchandler.lua:412: in function 'onCreatureSay'
        data/npc/scripts/Nielson.lua:10: in function <data/npc/scripts/test.lua:10>
have tried this
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions
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 greetCallback(cid)
    if getPlayerSex(cid) == PLAYERSEX_MALE then
        npcHandler:setMessage(MESSAGE_GREET, "man ".. getPlayerName(cid) .." welcome.")
        return true
    elseif getPlayerSex(cid) == PLAYERSEX_FEMALE then
        npcHandler:setMessage(MESSAGE_GREET, " lady ".. getPlayerName(cid) .." welcomes.")
        return true
    end  
end  

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
this
Code:
function greetCallback(cid)
    if getPlayerSex(cid) == 1 then
        npcHandler:setMessage(MESSAGE_GREET, "man ".. getPlayerName(cid) .." welcome.")
        return true
    elseif getPlayerSex(cid) == 0 then
        npcHandler:setMessage(MESSAGE_GREET, "lady ".. getPlayerName(cid) .." welcome.")
        return true
    end  
end  

npcHandler:setCallback(CALLBACK_GREET, greetCallback)

this
Code:
function greetCallback(cid)
    if getPlayerSex(cid) == 1 then
        npcHandler:setMessage(MESSAGE_GREET, "man ".. getPlayerName(cid) .." welcome.")
        return true
    else
        npcHandler:setMessage(MESSAGE_GREET, "lady ".. getPlayerName(cid) .."welcome.")
        return true
    end  
end


and always the same error is displayed. By some reason if i remove this code
Code:
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
it works, but it doesn't check players sex
Post automatically merged:

fixed
changed
Lua:
 if getPlayerSex(cid) == 1 then
to
Code:
if Player(cid):getSex() == PLAYERSEX_MALE then
and
Code:
npcHandler:setMessage(MESSAGE_GREET, "lady ".. getPlayerName(cid) .."welcome.")
for this
Code:
npcHandler:setMessage(MESSAGE_GREET, "lady".." |PLAYERNAME| ".."welcome.")
this fixed the error
 
Last edited:
Back
Top