• 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.X+ Talkaction Revscript Problem

Itutorial

Excellent OT User
Joined
Dec 23, 2014
Messages
2,325
Solutions
68
Reaction score
999
Talkactions with params do not execute.

Lua:
local vipTalk = TalkAction("/addvip","/vip","!vip")

function vipTalk.onSay(player, words, param, type)
if (words == "/addvip") then
    local t = param.split(",")
    local name = t[1]
    local amount = t[2]

    if not name or amount then
         player:sendCancelMessage("Usage: /addvip name, amount")
    return false
    end

    local target = Player(name)

    addVipDays(target)
end
return false
end

vipTalk:separator(" ")
vipTalk:register()

This isn't the actual code but just an example. If I type
Code:
/addvip

It will say "Usage: /addvip name, amount" but if I type

/addvip name

or anything else other than /addvip it wont even start the code. Using prints there is nothing at all.
 
are you sure it's not erroring from this line?
Lua:
local t = param.split(",")
It should be
Lua:
local t = string.split(param, ",")

---
Everything appears to work correctly with the following code
Lua:
local vipTalk = TalkAction("/addvip","/vip","!vip")

function vipTalk.onSay(player, words, param, type)
    print("------")
    print(1)
    print(words)
    if (words == "/addvip") then
        local t = string.split(param, ",")
        local name = t[1]
        local amount = t[2]
   
        if name == nil or amount == nil then
            player:sendCancelMessage("Usage: /addvip name, amount")
            return false
        end
   
        print(name)
        print(amount)
    end
    return false
end

vipTalk:separator(" ")
vipTalk:register()
 
Last edited:
My bad I just typed it wrong it is param:split(",")

I remember running into this issue before and someone had posted a modification in cpp because it wasn't creating the words and params correctly. I can't find that again though.
Post automatically merged:

Something in this
C++:
TalkActionResult_t TalkActions::playerSaySpell(Player* player, SpeakClasses type, const std::string& words) const
{
    size_t wordsLength = words.length();
    for (auto it = talkActions.begin(); it != talkActions.end(); ) {
        const std::string& talkactionWords = it->first;
        size_t talkactionLength = talkactionWords.length();
        if (wordsLength < talkactionLength || strncasecmp(words.c_str(), talkactionWords.c_str(), talkactionLength) != 0) {
            ++it;
            continue;
        }

        std::string param;
        if (wordsLength != talkactionLength) {
            param = words.substr(talkactionLength);
            if (param.front() != ' ') {
                ++it;
                continue;
            }
            trim_left(param, ' ');

            std::string separator = it->second.getSeparator();
            if (separator != " ") {
                if (!param.empty()) {
                    if (param != separator) {
                        ++it;
                        continue;
                    } else {
                        param.erase(param.begin());
                    }
                }
            }
        }

        if (it->second.fromLua) {
            if (it->second.getNeedAccess() && !player->getGroup()->access) {
                return TALKACTION_CONTINUE;
            }

            if (player->getAccountType() < it->second.getRequiredAccountType()) {
                return TALKACTION_CONTINUE;
            }
        }

        if (it->second.executeSay(player, words, param, type)) {
            return TALKACTION_CONTINUE;
        } else {
            return TALKACTION_BREAK;
        }
    }
    return TALKACTION_CONTINUE;
}

I think it was fixed in the newest TFS files but there was also a bunch of other stuff added aswell so I can't just use it.
 
Last edited:
maybe you should merge this change
No luck

Alright, I just updated the files to work the same as it is in the current version of TFS. It was easier than I thought. Just need to:
#include <boost/algorithm/string.hpp>

and add the other methods that are red (or don't exist yet) in tools.h and tools.cpp. They can be copied from the newest files. Nice and easy.
 
Last edited:
Back
Top