• 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 0.X Automatic war system guild x guilds, no frags.

esdrtu

New Member
Joined
Mar 8, 2022
Messages
15
Reaction score
4
How to adjust for when the player joins the guild, it is automatically at war with all other guilds? There are no frags between them.
Can you help me?

Frags.lua
Lua:
local config = {
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler')),
    advancedFragList = getBooleanFromString(getConfigValue('advancedFragList'))
}

function onSay(cid, words, param, channel)
    if(not config.useFragHandler) then
        return false
    end

    local time = os.time()
    local times = {today = (time - 86400), week = (time - (7 * 86400))}

    local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
    if(result:getID() ~= -1) then
        repeat
            local content = {
                name = result:getDataString("name"),
                level = result:getDataInt("level"),
                date = result:getDataInt("date")
            }
            if(content.date > times.today) then
                table.insert(contents.day, content)
            elseif(content.date > times.week) then
                table.insert(contents.week, content)
            else
                table.insert(contents.month, content)
            end
        until not result:next()
        result:free()
    end

    local size = {
        day = table.maxn(contents.day),
        week = table.maxn(contents.week),
        month = table.maxn(contents.month)
    }
    if(config.advancedFragList) then
        local result = "Frags gained today: " .. size.day .. "."
        if(size.day > 0) then
            for _, content in ipairs(contents.day) do
                result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
            end

            result = result .. "\n"
        end

        result = result .. "\nFrags gained this week: " .. (size.day + size.week) .. "."
        if(size.week > 0) then
            for _, content in ipairs(contents.week) do
                result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
            end

            result = result .. "\n"
        end

        result = result .. "\nFrags gained this month: " .. (size.day + size.week + size.month) .. "."
        if(size.month > 0) then
            for _, content in ipairs(contents.month) do
                result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level
            end

            result = result .. "\n"
        end

        local skullEnd = getPlayerSkullEnd(cid)
        if(skullEnd > 0) then
            result = result .. "\nYour " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull will expire at " .. os.date("%d %B %Y %X", skullEnd)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, ""..result.."")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You currently have " .. size.day .. " frags today, " .. (size.day + size.week) .. " this week and " .. (size.day + size.week + size.month) .. " this month.")
        if(size.day > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Last frag at " .. os.date("%d %B %Y %X", contents.day[1].date) .. " on level " .. contents.day[1].level .. " (" .. contents.day[1].name .. ").")
        end

        local skullEnd = getPlayerSkullEnd(cid)
        if(skullEnd > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull will expire at " .. os.date("%d %B %Y %X", skullEnd))
        end
    end

    return true
end



Guild.lua
Code:
function onChannelJoin(cid, channelId, users)
    if(channelId ~= CHANNEL_GUILD) then
        return true
    end

    for _, pid in pairs(users) do
        doPlayerSendChannelMessage(pid, "", "Player " .. getCreatureName(cid) .. " has entered the channel.", TALKTYPE_CHANNEL_HIGHLIGHT, CHANNEL_GUILD)
    end

    local guildId = getPlayerGuildId(cid)
    if(guildId and guildId ~= 0) then
        local guildMotd = getGuildMotd(guildId)
        if(guildMotd and guildMotd ~= "") then
            addEvent(valid(doPlayerSendChannelMessage), 150, cid, "", "Message of the Day: " .. guildMotd, TALKTYPE_GAMEMASTER_CHANNEL, CHANNEL_GUILD)
        end
    end

    return true
end

function onChannelLeave(cid, channelId, users)
    if(channelId ~= CHANNEL_GUILD) then
        return true
    end

    for _, pid in users do
        doPlayerSendChannelMessage(pid, "", "Player " .. getCreatureName(cid) .. " has left the channel.", TALKTYPE_CHANNEL_HIGHLIGHT, CHANNEL_GUILD)
    end

    return true
end
 
Whats the reason behind it? Just to display emblems automatically? Because in that case would be better to just edit Player::getGuildEmblem on sources instead
Hello, thanks for posting.
this is not the reason, I would like everyone who enters a guild to automatically go to war with all other guilds, so as not to count frags and they kill each other peacefully. But who is without a guild continues the limited frags normally. its old version system war
 
Ah okey, still best solution is by editing sources instead you can make a check on Player:onKilledCreature to not set injustified kills in case cid/target has guild, plus a check on Player::getGuildEmblem for emblems if you want to (player.cpp)
 
Back
Top