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

Lua Send message to loot channel OTHire

qben360

Member
Joined
Feb 20, 2015
Messages
170
Solutions
1
Reaction score
12
Hello guys i have creaturescript loot message, but this script sending loot info to Server log channel. I create a new channel name CHANNEL_LOOT, and i want to sending loot info into Loot Channel.

IN othire i didint find function about sends msg to channels, so i inject a luaDoPlayerSendChannelMessage to othire engine.

C++:
int32_t LuaScriptInterface::luaDoPlayerSendChannelMessage(lua_State* L)
{
    //doPlayerSendChannelMessage(cid, author, message, MessageClasses, channel)
    uint16_t channelId = popNumber(L);
    uint32_t cid = popNumber(L);
    std::string text = popString(L), name = popString(L);

    ScriptEnviroment* env = getScriptEnv();
    Player* player = env->getPlayerByUID(popNumber(L));
    if(!player)
    {
        reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
        lua_pushboolean(L, false);
        return 1;
    }

    player->sendChannelMessage(name, text, (MessageClasses)cid, channelId);
    lua_pushboolean(L, true);
    return 1;
}

and its my function from lootmessage.lua

Lua:
if party then
        local leaderid
        for _, pid in ipairs(getPartyMembers(cid)) do
            if isPartyLeader(pid) then
                leaderid = pid
            end
        end
        local hash = ("%d:%d"):format(leaderid, target)
        if not MessageSent[hash] then
            for _, pid in ipairs(getPartyMembers(cid)) do
                if isPremium(pid) then
                    doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, 'Loot of '.. getArticleByWord(name) .. ' ' .. string.lower(name) .. ': ' .. (ret ~= '' and ret or 'nothing'))
                end
            end
            MessageSent[hash] = true
            addEvent(function() MessageSent[hash] = nil end, 1000)
        end
    else
        if isPremium(cid) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Loot of '.. getArticleByWord(name) .. ' ' .. string.lower(name) .. ': ' .. (ret ~= '' and ret or 'nothing'))
        end
    end

I need help to change some strings in function

Lua:
doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, 'Loot of '.. getArticleByWord(name) .. ' ' .. string.lower(name) .. ': ' .. (ret ~= '' and ret or 'nothing'))

to DoPlayerSendChannelMessage
 

hotdog1337

Banned User
Joined
Apr 1, 2021
Messages
294
Solutions
3
Reaction score
123
Lua:
//doPlayerSendChannelMessage(cid, author, message, MessageClasses, channel)


//doPlayerSendChannelMessage(cid, author, 'Loot of '.. getArticleByWord(name) .. ' ' .. string.lower(name) .. ': ' .. (ret ~= '' and ret or 'nothing', MESSAGE_INFO_DESCR, 123456789?channels.xml)
 
OP
OP
qben360

qben360

Member
Joined
Feb 20, 2015
Messages
170
Solutions
1
Reaction score
12
@hotdog1337

Lua:
doPlayerSendChannelMessage(cid, author, 'Loot of '.. getArticleByWord(name) .. ' ' .. string.lower(name) .. ': ' .. (ret ~= '' and ret or 'nothing', MESSAGE_INFO_DESCR, CHANNEL_LOOT)

its will be ok?
 

hotdog1337

Banned User
Joined
Apr 1, 2021
Messages
294
Solutions
3
Reaction score
123
do you have CHANNEL_LOOT? in my distro which is similar to othire i have
/data/xml/ channels.xml

and there you have
e.g

<channel id="1" name="Party"/>
<channel id="2" name="Counselor" access="1"/>
<channel id="3" name="Rule Violations" logged="yes" access="4"/>
<channel id="4" name="Game-Chat" level="2" logged="yes"/>
<channel id="5" name="Trade" level="2" muted="120" conditionId="3" conditionMessage="You may only place one offer in 120 seconds."/>
<channel id="6" name="EN-Chat" level="2" logged="yes"/>
<channel id="7" name="Help" logged="yes"/>

<channel id="65535" name="Private Chat Channel" logged="no"/>

</channels>
 
OP
OP
qben360

qben360

Member
Joined
Feb 20, 2015
Messages
170
Solutions
1
Reaction score
12
in othire dont have channels.xml , channel im adding in chat.cpp

Lua:
local function send(cid, lastHit, pos, name, party, target)
    local corpse = getTileItemByType(pos, ITEM_TYPE_CONTAINER).uid
    local ret = isContainer(corpse) and getContentDescription(corpse)
    local wontcheck = {'Fire Elemental', 'Slime'}
   
    if isInArray(wontcheck, name) then
        ret = ''
    end

    if party then
        local leaderid
        for _, pid in ipairs(getPartyMembers(cid)) do
            if isPartyLeader(pid) then
                leaderid = pid
            end
        end
        local hash = ("%d:%d"):format(leaderid, target)
        if not MessageSent[hash] then
            for _, pid in ipairs(getPartyMembers(cid)) do
                if isPremium(pid) then
                    doPlayerSendChannelMessage(pid, author, 'Loot of '.. getArticleByWord(name) .. ' ' .. string.lower(name) .. ': ' .. (ret ~= '' and ret or 'nothing'), MESSAGE_INFO_DESCR, CHANNEL_LOOT)
                end
            end
            MessageSent[hash] = true
            addEvent(function() MessageSent[hash] = nil end, 1000)
        end
    else
        if isPremium(cid) then
            doPlayerSendChannelMessage(cid, author, 'Loot of '.. getArticleByWord(name) .. ' ' .. string.lower(name) .. ': ' .. (ret ~= '' and ret or 'nothing'), MESSAGE_INFO_DESCR, CHANNEL_LOOT)
        end
    end
   
end

something like this its not working :/
Post automatically merged:

anybody? implemented this function in othire engine? sending loot info to new channel like CHANNEL LOOT?, someone can help me
 
Last edited:
Top