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

TFS 1.2 Blessed

lazarus321

Member
Joined
May 8, 2017
Messages
209
Reaction score
20
Hello guys,
I implemented the script below, but it doesn't work properly here.
In this part of adding the blessing "player: addBlessing (1)" despite the script does not give errors the player also does not receive the blessing.


I believe it is some function within my source that is not ok

I have this function in the file luascript.cpp. Do I need anything else?

HTML:
int LuaScriptInterface::luaPlayerHasBlessing(lua_State* L)
{
    // player:hasBlessing(blessing)
    uint8_t blessing = getNumber<uint8_t>(L, 2) - 1;
    Player* player = getUserdata<Player>(L, 1);
    if (player) {
        pushBoolean(L, player->hasBlessing(blessing));
    } else {
        lua_pushnil(L);
    }
    return 1;
}

int LuaScriptInterface::luaPlayerAddBlessing(lua_State* L)
{
    // player:addBlessing(blessing)
    Player* player = getUserdata<Player>(L, 1);
    if (player) {
        lua_pushnil(L);
        return 1;
    }

    uint8_t blessing = getNumber<uint8_t>(L, 2) - 1;
    if (player->hasBlessing(blessing)) {
        pushBoolean(L, false);
        return 1;
    }

    player->addBlessing(1 << blessing);
    pushBoolean(L, true);
    return 1;
}

int LuaScriptInterface::luaPlayerRemoveBlessing(lua_State* L)
{
    // player:removeBlessing(blessing)
    Player* player = getUserdata<Player>(L, 1);
    if (player) {
        lua_pushnil(L);
        return 1;
    }

    uint8_t blessing = getNumber<uint8_t>(L, 2) - 1;
    if (!player->hasBlessing(blessing)) {
        pushBoolean(L, false);
        return 1;
    }

    player->removeBlessing(1 << blessing);
    pushBoolean(L, true);
    return 1;
}
 
Last edited:
Solution
Final thing I can check with you is check if you have this in your luascript.cpp
Lua:
    registerMethod("Player", "hasBlessing", LuaScriptInterface::luaPlayerHasBlessing);
    registerMethod("Player", "addBlessing", LuaScriptInterface::luaPlayerAddBlessing);
    registerMethod("Player", "removeBlessing", LuaScriptInterface::luaPlayerRemoveBlessing);

and then a few tiny changes, not sure if it would work within your source

C++:
int LuaScriptInterface::luaPlayerHasBlessing(lua_State* L)
{
    // player:hasBlessing(blessing)
    uint8_t blessing = getNumber<uint8_t>(L, 2) - 1;
    Player* player = getUserdata<Player>(L, 1);
    if (player) {
        pushBoolean(L, player->hasBlessing(blessing));
    } else {
        lua_pushnil(L);
    }...
Dear lazarus321,

It has most likely something to do with your blessing script which you can locate in your npc/scripts folder. And most of the times its being called bless.lua. Make sure the NPC you want to talk to so Quentin.xml for example has access to the bless.lua script.

If there are any issues or need guidance in obtaining your goal feel free to post the your_npc.xml and your_script_used_by_npc.lua here and I will have a look at it.

Sincerely,
Ralumbi(Caleb)
 
Ok, Thanks @Ralumbi.

well,

the name of npc is Oyama with this file.

HTML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Oyama" script="Oyama.lua" walkinterval="2000" floorchange="0">
      <health now="150" max="150" />
    <look type="57" head="115" body="113" legs="31" feet="38" addons="3" />
    <parameters>
        <parameter key="message_greet" value="Bem vindo |PLAYERNAME|! Raramente eu recebo visitantes nestes dias de reforma da {Ordem}. Eu posso lhe conceder algumas {protecoes} ou {todas} se desejar." />
        <parameter key="message_walkaway" value="Tome cuidado, ha muitos perigos la fora." />
        <parameter key="message_farewell" value="Ide em paz, |PLAYERNAME|!" />
    </parameters>
</npc>


The script Oyama.lua is this.

HTML:
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 player = Player(cid)
    local blessings = 0
    for i = 1, 5 do
        if(player:hasBlessing(i)) then
            blessings = blessings + 1
        end
    end
  
    if(msgcontains(msg, 'protecoes')) then
        npcHandler:say("Existem cinco tipos diferentes de bencaos disponiveis nos {lugares sagrados}. Essas bencaos sao: a {sabedoria de Mithrandir}, a {centelha de Gruumsh}, o {abraco de Melora}, o {fortaleza de Kurul} e o {destino de Bran}. Voce tem " .. blessings .. " de 5 bencaos. Tambem posso lhe fornecer {todas} as bencaos de uma so vez. Alem disso, voce pode receber a {reviravolta do destino} aqui.", cid)
        talkState[talkUser] = 0
    elseif(msgcontains(msg, 'lugares sagrados')) then
        npcHandler:say("Sao locais para se conectar com o divino. Basta perguntar em qual das cinco bencaos voce esta interessado.", cid)
        talkState[talkUser] = 0
    elseif(msgcontains(msg, 'todas')) then
        if(player:hasBlessing(5)) then
            npcHandler:say("Voce ja possui todas as bencaos.", cid)
            talkState[talkUser] = 0
        else
            npcHandler:say("Gostaria de receber todas as bencaos?", cid)
            talkState[talkUser] = 1
        end
    elseif(msgcontains(msg, 'fortaleza de Kurul')) then
        if(player:hasBlessing(4)) then
            npcHandler:say("Vejo que voce ja recebeu a bencao da fortaleza de Kurul.", cid)
            talkState[talkUser] = 0
        else
            npcHandler:say("Gostaria de receber a bencao da fortaleza de Kurul?", cid)
            talkState[talkUser] = 2
        end
    elseif(msgcontains(msg, 'centelha de Gruumsh')) then
        if(player:hasBlessing(2)) then
            npcHandler:say("Vejo que voce ja recebeu a bencao da centelha de Gruumsh.", cid)
            talkState[talkUser] = 0
        else
            npcHandler:say("Gostaria de receber a bencao da centelha de Gruumsh?", cid)
            talkState[talkUser] = 3
        end
    elseif(msgcontains(msg, 'destino de Bran')) then
        if(player:hasBlessing(5)) then
            npcHandler:say("Vejo que voce ja recebeu a bencao do destino de Bran.", cid)
            talkState[talkUser] = 0
        else
            npcHandler:say("Gostaria de receber a bencao do destino de Bran?", cid)
            talkState[talkUser] = 4
        end
    elseif(msgcontains(msg, 'abraco de Melora')) then
        if(player:hasBlessing(3)) then
            npcHandler:say("Vejo que voce ja recebeu a bencao do abraco de Melora.", cid)
            talkState[talkUser] = 0
        else
            npcHandler:say("Gostaria de receber a bencao do abraco de Melora?", cid)
            talkState[talkUser] = 5
        end
    elseif(msgcontains(msg, 'sabedoria de Mithrandir')) then
        if(player:hasBlessing(1)) then
            npcHandler:say("Vejo que voce ja recebeu a bencao da sabedoria de Mithrandir.", cid)
            talkState[talkUser] = 0
        else
            npcHandler:say("Gostaria de receber a bencao da sabedoria de Mithrandir?", cid)
            talkState[talkUser] = 6
        end
    elseif(msgcontains(msg, 'reviravolta do destino')) then
        if(player:hasBlessing(6)) then
            npcHandler:say("Voce ja possui a bencao da reviravolta do destino.", cid)
            talkState[talkUser] = 0
        else
            npcHandler:say(
                {"This is a special blessing I can bestow upon you once you have obtained at least one of the other blessings and which functions a bit differently. ...",
                "It only works when you're killed by other adventurers, which means that the last damage that is the cause of your death was caused by others, not by monsters or the environment. ...",
                "The twist of fate will not reduce the death penalty like the other blessings, but instead prevent you from losing your other blessings as well as the amulet of loss, should you wear one. It costs the same as the other blessings. ...",
                "Would you like to receive that protection for a sacrifice of 28000 gold, child?"}, cid)
            talkState[talkUser] = 7
        end

    elseif(msgcontains(msg, 'sim')) then
        if(talkState[talkUser] == 1) then
            if(player:getMoney() >= ((player:getLevel()) * 5)) then
                for i = 1, 5 do
                    player:addBlessing(i)
                end
                npcHandler:say("Voce recebeu todas as bencaos!", cid)
            else
                npcHandler:say("Voce nao pode pagar essa bencao!", cid)
            end
            talkState[talkUser] = 0
        elseif(talkState[talkUser] == 2) then
            if(player:getMoney() >= (player:getLevel())) then
                npcHandler:say("Voce recebeu a bencao da fortaleza de Kurul!", cid)
                player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
                player:addBlessing(4)
            else
                npcHandler:say("Voce nao pode pagar essa bencao!", cid)
            end
            talkState[talkUser] = 0
        elseif(talkState[talkUser] == 3) then
            if(player:getMoney() >= (player:getLevel())) then
                npcHandler:say("Voce recebeu a bencao da centelha de Gruumsh!", cid)
                player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
                player:addBlessing(2)
            else
                npcHandler:say("Voce nao pode pagar essa bencao!", cid)
            end
            talkState[talkUser] = 0
        elseif(talkState[talkUser] == 4) then
            if(player:getMoney() >= (player:getLevel())) then
                npcHandler:say("Voce recebeu a bencao do destino de Bran!", cid)
                player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
                player:addBlessing(5)
            else
                npcHandler:say("Voce nao pode pagar essa bencao!", cid)
            end
            talkState[talkUser] = 0
        elseif(talkState[talkUser] == 5) then
            if(player:getMoney() >= (player:getLevel())) then
                npcHandler:say("Voce recebeu a bencao do abraco de Melora!", cid)
                player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
                player:addBlessing(3)
            else
                npcHandler:say("Voce nao pode pagar essa bencao!", cid)
            end
            talkState[talkUser] = 0
        elseif(talkState[talkUser] == 6) then
            if(player:getMoney() >= (player:getLevel())) then
                npcHandler:say("Voce recebeu a bencao da sabedoria de Mithrandir!", cid)
                player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
                player:addBlessing(1)
            else
                npcHandler:say("Voce nao pode pagar essa bencao!", cid)
            end
            talkState[talkUser] = 0
        elseif(talkState[talkUser] == 7) then
            if(player:getMoney() >= getPvpBlessingCost(player:getLevel())) then
                npcHandler:say("Voce recebeu a bencao da reviravolta do destino!", cid)
                player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
                player:addBlessing(6)
            else
                npcHandler:say("Voce nao pode pagar essa bencao!", cid)
            end
            talkState[talkUser] = 0

        end
    elseif(msgcontains(msg, 'nao')) then
        npcHandler:say("Tudo bem.", cid)
        talkState[talkUser] = 0
    end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Lua:
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 node1 = keywordHandler:addKeyword({'first bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first blessing for 10000 gold?'})
    node1:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 1, premium = true, cost = 10000})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node2 = keywordHandler:addKeyword({'second bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the second blessing for 10000 gold?'})
    node2:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 2, premium = true, cost = 10000})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node3 = keywordHandler:addKeyword({'third bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the third blessing for 10000 gold?'})
    node3:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 3, premium = true, cost = 10000})
    node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node4 = keywordHandler:addKeyword({'fourth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fourth blessing for 10000 gold?'})
    node4:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 4, premium = true, cost = 10000})
    node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node5 = keywordHandler:addKeyword({'fifth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fifth blessing for 10000 gold?'})
    node5:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 5, premium = true, cost = 10000})
    node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

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 player = Player(cid)
    local blessings = 0
    for i = 1, 5 do
        if(player:hasBlessing(i)) then
            blessings = blessings + 1
        end
    end

    if(msgcontains(msg, 'protecoes')) then
        npcHandler:say("Existem cinco tipos diferentes de bencaos disponiveis nos {lugares sagrados}. Essas bencaos sao: a {sabedoria de Mithrandir}, a {centelha de Gruumsh}, o {abraco de Melora}, o {fortaleza de Kurul} e o {destino de Bran}. Voce tem " .. blessings .. " de 5 bencaos. Tambem posso lhe fornecer {todas} as bencaos de uma so vez. Alem disso, voce pode receber a {reviravolta do destino} aqui.", cid)
        talkState[talkUser] = 0
    elseif(msgcontains(msg, 'lugares sagrados')) then
        npcHandler:say("Sao locais para se conectar com o divino. Basta perguntar em qual das cinco bencaos voce esta interessado.", cid)
        talkState[talkUser] = 0
    elseif(msgcontains(msg, 'todas')) then
        if(player:hasBlessing(5)) then
            npcHandler:say("Voce ja possui todas as bencaos.", cid)
            talkState[talkUser] = 0
        else
            npcHandler:say("Gostaria de receber todas as bencaos?", cid)
            talkState[talkUser] = 1
        end
    elseif(msgcontains(msg, 'fortaleza de Kurul')) then
        if(player:hasBlessing(4)) then
            npcHandler:say("Vejo que voce ja recebeu a bencao da fortaleza de Kurul.", cid)
            talkState[talkUser] = 0
        else
            npcHandler:say("Gostaria de receber a bencao da fortaleza de Kurul?", cid)
            talkState[talkUser] = 2
        end
    elseif(msgcontains(msg, 'centelha de Gruumsh')) then
        if(player:hasBlessing(2)) then
            npcHandler:say("Vejo que voce ja recebeu a bencao da centelha de Gruumsh.", cid)
            talkState[talkUser] = 0
        else
            npcHandler:say("Gostaria de receber a bencao da centelha de Gruumsh?", cid)
            talkState[talkUser] = 3
        end
    elseif(msgcontains(msg, 'destino de Bran')) then
        if(player:hasBlessing(5)) then
            npcHandler:say("Vejo que voce ja recebeu a bencao do destino de Bran.", cid)
            talkState[talkUser] = 0
        else
            npcHandler:say("Gostaria de receber a bencao do destino de Bran?", cid)
            talkState[talkUser] = 4
        end
    elseif(msgcontains(msg, 'abraco de Melora')) then
        if(player:hasBlessing(3)) then
            npcHandler:say("Vejo que voce ja recebeu a bencao do abraco de Melora.", cid)
            talkState[talkUser] = 0
        else
            npcHandler:say("Gostaria de receber a bencao do abraco de Melora?", cid)
            talkState[talkUser] = 5
        end
    elseif(msgcontains(msg, 'sabedoria de Mithrandir')) then
        if(player:hasBlessing(1)) then
            npcHandler:say("Vejo que voce ja recebeu a bencao da sabedoria de Mithrandir.", cid)
            talkState[talkUser] = 0
        else
            npcHandler:say("Gostaria de receber a bencao da sabedoria de Mithrandir?", cid)
            talkState[talkUser] = 6
        end
    elseif(msgcontains(msg, 'reviravolta do destino')) then
        if(player:hasBlessing(6)) then
            npcHandler:say("Voce ja possui a bencao da reviravolta do destino.", cid)
            talkState[talkUser] = 0
        else
            npcHandler:say(
                {"This is a special blessing I can bestow upon you once you have obtained at least one of the other blessings and which functions a bit differently. ...",
                "It only works when you're killed by other adventurers, which means that the last damage that is the cause of your death was caused by others, not by monsters or the environment. ...",
                "The twist of fate will not reduce the death penalty like the other blessings, but instead prevent you from losing your other blessings as well as the amulet of loss, should you wear one. It costs the same as the other blessings. ...",
                "Would you like to receive that protection for a sacrifice of 28000 gold, child?"}, cid)
            talkState[talkUser] = 7
        end

    elseif(msgcontains(msg, 'sim')) then
        if(talkState[talkUser] == 1) then
            if(player:getMoney() >= ((player:getLevel()) * 5)) then
                for i = 1, 5 do
                    player:addBlessing(i)
                end
                npcHandler:say("Voce recebeu todas as bencaos!", cid)
            else
                npcHandler:say("Voce nao pode pagar essa bencao!", cid)
            end
            talkState[talkUser] = 0
        elseif(talkState[talkUser] == 2) then
            if(player:getMoney() >= (player:getLevel())) then
                npcHandler:say("Voce recebeu a bencao da fortaleza de Kurul!", cid)
                player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
                player:addBlessing(4)
            else
                npcHandler:say("Voce nao pode pagar essa bencao!", cid)
            end
            talkState[talkUser] = 0
        elseif(talkState[talkUser] == 3) then
            if(player:getMoney() >= (player:getLevel())) then
                npcHandler:say("Voce recebeu a bencao da centelha de Gruumsh!", cid)
                player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
                player:addBlessing(2)
            else
                npcHandler:say("Voce nao pode pagar essa bencao!", cid)
            end
            talkState[talkUser] = 0
        elseif(talkState[talkUser] == 4) then
            if(player:getMoney() >= (player:getLevel())) then
                npcHandler:say("Voce recebeu a bencao do destino de Bran!", cid)
                player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
                player:addBlessing(5)
            else
                npcHandler:say("Voce nao pode pagar essa bencao!", cid)
            end
            talkState[talkUser] = 0
        elseif(talkState[talkUser] == 5) then
            if(player:getMoney() >= (player:getLevel())) then
                npcHandler:say("Voce recebeu a bencao do abraco de Melora!", cid)
                player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
                player:addBlessing(3)
            else
                npcHandler:say("Voce nao pode pagar essa bencao!", cid)
            end
            talkState[talkUser] = 0
        elseif(talkState[talkUser] == 6) then
            if(player:getMoney() >= (player:getLevel())) then
                npcHandler:say("Voce recebeu a bencao da sabedoria de Mithrandir!", cid)
                player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
                player:addBlessing(1)
            else
                npcHandler:say("Voce nao pode pagar essa bencao!", cid)
            end
            talkState[talkUser] = 0
        elseif(talkState[talkUser] == 7) then
            if(player:getMoney() >= getPvpBlessingCost(player:getLevel())) then
                npcHandler:say("Voce recebeu a bencao da reviravolta do destino!", cid)
                player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
                player:addBlessing(6)
            else
                npcHandler:say("Voce nao pode pagar essa bencao!", cid)
            end
            talkState[talkUser] = 0

        end
    elseif(msgcontains(msg, 'nao')) then
        npcHandler:say("Tudo bem.", cid)
        talkState[talkUser] = 0
    end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

I have added a few lines to your script, this should work when speaking to Oyama and ask for:
  • first bless
  • second bless
  • third bless
  • fourth bless
  • fifth bless
If its not working I must know which version of TFS you're using.

Sincerely,
Ralumbi(Caleb)
 
I don't know if it worked, see the red arrows. How do we check to see if the player already has the blessing?

1587927437679.png
My TFS is 1.3 - version 10.98
1587927757022.png
 
Right click on an "ankh" item to check the blessings.
Not sure how far you changed the names to Portuguese, but this always worked for me.
Post automatically merged:

Excuse me, use an Ceremonial Ankh to check your blessings.
 
Last edited:
1587928254177.png
We can speak in English no problem.
Well, it looks like you're not recognizing the command to bless. so I believe it is some edition in the source
 
Could you try this script inside the Oyamo.xml instead of the current one and try the "first bless" and try the ankh.

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

local node1 = keywordHandler:addKeyword({'first bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first blessing for 10000 gold?'})
    node1:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 1, premium = true, cost = 10000})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node2 = keywordHandler:addKeyword({'second bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the second blessing for 10000 gold?'})
    node2:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 2, premium = true, cost = 10000})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node3 = keywordHandler:addKeyword({'third bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the third blessing for 10000 gold?'})
    node3:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 3, premium = true, cost = 10000})
    node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node4 = keywordHandler:addKeyword({'fourth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fourth blessing for 10000 gold?'})
    node4:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 4, premium = true, cost = 10000})
    node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

local node5 = keywordHandler:addKeyword({'fifth bless'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the fifth blessing for 10000 gold?'})
    node5:addChildKeyword({'yes'}, StdModule.bless, {npcHandler = npcHandler, bless = 5, premium = true, cost = 10000})
    node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

npcHandler:addModule(FocusModule:new())

If this doesn't work there is another issue going.
 
Final thing I can check with you is check if you have this in your luascript.cpp
Lua:
    registerMethod("Player", "hasBlessing", LuaScriptInterface::luaPlayerHasBlessing);
    registerMethod("Player", "addBlessing", LuaScriptInterface::luaPlayerAddBlessing);
    registerMethod("Player", "removeBlessing", LuaScriptInterface::luaPlayerRemoveBlessing);

and then a few tiny changes, not sure if it would work within your source

C++:
int LuaScriptInterface::luaPlayerHasBlessing(lua_State* L)
{
    // player:hasBlessing(blessing)
    uint8_t blessing = getNumber<uint8_t>(L, 2) - 1;
    Player* player = getUserdata<Player>(L, 1);
    if (player) {
        pushBoolean(L, player->hasBlessing(blessing));
    } else {
        lua_pushnil(L);
    }
    return 1;
}

int LuaScriptInterface::luaPlayerAddBlessing(lua_State* L)
{
    // player:addBlessing(blessing)
    Player* player = getUserdata<Player>(L, 1);
    if (!player) {
        lua_pushnil(L);
        return 1;
    }

    uint8_t blessing = getNumber<uint8_t>(L, 2) - 1;
    if (player->hasBlessing(blessing)) {
        pushBoolean(L, false);
        return 1;
    }

    player->addBlessing(1 << blessing);
    pushBoolean(L, true);
    return 1;
}

int LuaScriptInterface::luaPlayerRemoveBlessing(lua_State* L)
{
    // player:removeBlessing(blessing)
    Player* player = getUserdata<Player>(L, 1);
    if (!player) {
        lua_pushnil(L);
        return 1;
    }

    uint8_t blessing = getNumber<uint8_t>(L, 2) - 1;
    if (!player->hasBlessing(blessing)) {
        pushBoolean(L, false);
        return 1;
    }

    player->removeBlessing(1 << blessing);
    pushBoolean(L, true);
    return 1;
}

Make sure to recompile your server!!
 
Solution
Back
Top