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

war system tfs 1.3

vexler222

Active Member
Joined
Apr 22, 2012
Messages
714
Solutions
15
Reaction score
46
Hi, i found war system for tfs 1.3 (100% tfs 1.3) by commands, not on website, but i have problem, i can send war invite, i can accept, and i got war shield icons, i can kill enemy player with icon, without skull only pz, but war is infinity, i kill enemy player 10 times (war invite for 10 frags), but war status still be "1", problme is in war.lua from talkactions or i skiped something, when i serching war in datapack?


Code:
function onSay(player, words, param)

    local player = Player(player)
    local guild = player:getGuild()
    if(guild == nil) then
            player:sendCancelMessage("You need to be in a guild in order to execute this talkaction.")
            return false
    end

    local guild = getPlayerGuildId(player)
    if not guild or (player:getGuildLevel() < 3) then
            player:sendCancelMessage("You cannot execute this talkaction.")
            return false
    end

    local t = string.split(param, ",")
    if(not t[2]) then
            player:sendChannelMessage("", "Not enough param(s).", TALKTYPE_CHANNEL_R1, CHANNEL_GUILD)
            return false
    end

    local enemy = getGuildId(t[2])
    if(not enemy) then
            player:sendChannelMessage("", "Guild \"" .. t[2] .. "\" does not exists.", TALKTYPE_CHANNEL_R1, CHANNEL_GUILD)
            return false
    end


    if(enemy == guild) then
            player:sendChannelMessage("", "You cannot perform war action on your own guild.", TALKTYPE_CHANNEL_R1, CHANNEL_GUILD)
            return false
    end

    local enemyName, tmp = "", db.storeQuery("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
    if tmp ~= false then
            enemyName = result.getDataString(tmp, "name")
            result.free(tmp)
    end

    if(isInArray({"accept", "reject", "cancel"}, t[1])) then
            local query = "`guild1` = " .. enemy .. " AND `guild2` = " .. guild
            if(t[1] == "cancel") then
                    query = "`guild1` = " .. guild .. " AND `guild2` = " .. enemy
            end

            tmp = db.storeQuery("SELECT `id`, `started`, `ended`, `payment` FROM `guild_wars` WHERE " .. query .. " AND `status` = 0")
            if(tmp == false) then
                    player:sendChannelMessage("", "Currently there's no pending invitation for a war with " .. enemyName .. ".", TALKTYPE_CHANNEL_R1, CHANNEL_GUILD)
                    return false
            end

            query = "UPDATE `guild_wars` SET "
            local msg = "accepted " .. enemyName .. " invitation to war."
            if(t[1] == "reject") then
                    query = query .. "`ended` = " .. os.time() .. ", `status` = 2"
                    msg = "rejected " .. enemyName .. " invitation to war."
            elseif(t[1] == "cancel") then
                    query = query .. "`ended` = " .. os.time() .. ", `status` = 3"
                    msg = "canceled invitation to a war with " .. enemyName .. "."
            else
                    query = query .. "`started` = " .. os.time() .. ", `ended` = " .. (result.getDataInt(tmp, "ended") > 0 and (os.time() + ((result.getDataInt(tmp, "started") - result.getDataInt(tmp, "ended")) / 86400)) or 0) .. ", `status` = 1"
            end


            query = query .. " WHERE `id` = " .. result.getDataInt(tmp, "id")
            result.free(tmp)
            db.query(query)
            broadcastMessage(getPlayerGuildName(player) .. " has " .. msg, MESSAGE_EVENT_ADVANCE)
            return false
    end

    if(t[1] == "invite") then
            local str = ""
            tmp = db.storeQuery("SELECT `guild1`, `status` FROM `guild_wars` WHERE `guild1` IN (" .. guild .. "," .. enemy .. ") AND `guild2` IN (" .. enemy .. "," .. guild .. ") AND `status` IN (0, 1)")
    if(tmp ~= false) then

                    if(result.getDataInt(tmp, "status") == 0) then
                            if(result.getDataInt(tmp, "guild1") == guild) then
                                    str = "You have already invited " .. enemyName .. " to war."
                            else
                                    str = enemyName .. " have already invited you to war."
                            end
                    else
                            str = "You are already on a war with " .. enemyName .. "."
                    end

                    result.free(tmp)
            end

            if(str ~= "") then
                    player:sendChannelMessage("", str, TALKTYPE_CHANNEL_R1, CHANNEL_GUILD)
                    return false
            end

            local frags = tonumber(t[3])
            if(frags ~= nil) then
                    frags = math.max(10, math.min(1000, frags))
            else
                    frags = 100
            end

            local payment = tonumber(t[4])
            if(payment ~= nil) then
                    payment = math.floor(payment)+1000
                    tmp = db.storeQuery("SELECT `balance` FROM `guilds` WHERE `id` = " .. guild)

                    local state = result.getDataInt(tmp, "balance") < payment
                    result.free(tmp)
                    if(state) then
                            player:sendChannelMessage("", "Your guild balance is too low for such payment.", TALKTYPE_CHANNEL_R1, CHANNEL_GUILD)
                            return false
                    end

                    db.query("UPDATE `guilds` SET `balance` = `balance` - " .. payment .. " WHERE `id` = " .. guild)
            else
                    payment = 0
            end

            local begining, ending = os.time(), tonumber(t[5])
            if(ending ~= nil and ending ~= 0) then
                    ending = begining + (ending * 86400)
            else
                    ending = 0
            end

            db.query("INSERT INTO `guild_wars` (`guild1`, `guild2`, `started`, `ended`, `frags`, `payment`,`name1`,`name2`) VALUES (" .. guild .. ", " .. enemy .. ", " .. begining .. ", " .. ending .. ", " .. frags .. ", " .. payment .. ", '" .. getPlayerGuildName(player) .."', '"..enemyName.."');")
            db.query("INSERT INTO `znote_guild_wars` (`limit`) VALUES ('"..frags.."');")
            broadcastMessage(getPlayerGuildName(player) .. " has invited " .. enemyName .. " to war till " .. frags .. " frags.", MESSAGE_EVENT_ADVANCE)
            return false
    end

    if(not isInArray({"end", "finish"}, t[1])) then
            return false
    end

    local status = (t[1] == "end" and 1 or 4)
    tmp = db.storeQuery("SELECT `id` FROM `guild_wars` WHERE `guild1` = " .. guild .. " AND `guild2` = " .. enemy .. " AND `status` = " .. status)
    if(tmp ~= false) then
            local query = "UPDATE `guild_wars` SET `ended` = " .. os.time() .. ", `status` = 5 WHERE `id` = " .. result.getDataInt(tmp, "id")
            result.free(tmp)

            db.query(query)
            broadcastMessage(getPlayerGuildName(player) .. " has " .. (status == 4 and "mend fences" or "ended up a war") .. " with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
            return false
    end

    if(status == 4) then
            player:sendChannelMessage("", "Currently there's no pending war truce from " .. enemyName .. ".", TALKTYPE_CHANNEL_R1, CHANNEL_GUILD)
            return false
    end

    tmp = db.storeQuery("SELECT `id`, `ended` FROM `guild_wars` WHERE `guild1` = " .. enemy .. " AND `guild2` = " .. guild .. " AND `status` = 1")
    if(tmp ~= false) then
            if(result.getDataInt(tmp, "ended") > 0) then
                    result.free(tmp)
                    player:sendChannelMessage("", "You cannot request ending for war with " .. enemyName .. ".", TALKTYPE_CHANNEL_R1, CHANNEL_GUILD)
                    return false
            end

            local query = "UPDATE `guild_wars` SET `status` = 4, `ended` = " .. os.time() .. " WHERE `id` = " .. result.getDataInt(tmp, "id")
            result.free(tmp)

            db.query(query)
            broadcastMessage(getPlayerGuildName(player) .. " has signed an armstice declaration on a war with " .. enemyName .. ".", MESSAGE_EVENT_ADVANCE)
            return false
    end

    player:sendChannelMessage("", "Currently there's no active war with " .. enemyName .. ".", TALKTYPE_CHANNEL_R1, CHANNEL_GUILD)
    return false
end
 
Try this:

Lua:
local minPlayersOnline = 1
local minLevel = 100

local function hasMinimumMembersInGuild(guild)
    local membersOnline = guild:getMembersOnline()
    local total = 0
    for _, member in ipairs(membersOnline) do
        if member:getLevel() >= minLevel then
            total = total + 1
        end
    end

    if total >= minPlayersOnline then
        return true
    end

    return false
end

function onSay(player, words, param)
    local guild = player:getGuild()
    if not guild then
        player:sendCancelMessage("You need to be on a guild in order to execute this command.")
        return false
    end

    if player:getGuildLevel() ~= 3 then
        player:sendCancelMessage("You are not the guild leader.")
        return false
    end

    local p = param:split(', ')
    local action, targetGuildName = p[1], p[2]
    if not action or not targetGuildName then
        player:popupFYI('Use the command correctly:' .. '\n\n' .. '\n\n Keep in mind\n\n Guild name should be the same shown on website. \n\nExample:\n' .. '--> !war invite, Guildname, 30' .. '\n\n' .. 'To accept a war:\n' .. '--> !war accept, Guildname' .. '\n\n' .. 'Reject war:\n' .. '--> !war reject, Guildname' .. '\n\n' .. 'Cancel war invite:\n' .. '--> !war cancel, Guildname' .. '\n\n' .. 'End war system:\n' .. '--> !war end, Guildname')
        return true
    end

    local resultName = db.storeQuery(string.format('SELECT `id` FROM `guilds` WHERE `name` = %s', db.escapeString(targetGuildName)))
    if not resultName then
        player:sendCancelMessage(string.format("Guild does not exists.", targetGuildName))
        return false
    end

    local targetGuildId = result.getNumber(resultName, "id")
    result.free(resultName)

    local guildId, guildName = guild:getId(), guild:getName()
    if action:lower() == "invite" then
        if not hasMinimumMembersInGuild(guild) then
            player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('You need to have at least %d player%s online in your guild higher than level %d in order to execute this command.', minPlayersOnline, minPlayersOnline ~= 1 and 's', minLevel))
            return false
        end

        if #p ~= 3 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'Please use the command correctly:\n!war invite, Guild name, frags\n\nExample:\n!war invite, Guild Name, 100')
            return false
        end

        local frags = p[3]
        if targetGuildName:lower() == guildName:lower() or guildId == targetGuildId then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You can not invite your own guild to a war.")
            return false
        end

        local resultInvite = db.storeQuery(string.format("SELECT `id` FROM `guild_wars` WHERE (((guild1 = %d AND guild2 = %d) OR (guild1 = %d AND guild2 = %d)) AND (status = 0 OR status = 1))", guildId, targetGuildId, targetGuildId, guildId))
        if resultInvite then
            player:sendCancelMessage("You already sent a war invitation to that guild.")
            result.free(resultInvite)
            return false
        end
      
        local fragsLimit = tonumber(frags)
        if not fragsLimit then
            player:sendCancelMessage("Please use only numbers in frags limit.")
            return false
        end

        if fragsLimit < 20 or fragsLimit > 999 then
            player:sendCancelMessage("The minimum frag limit is 20 and maximum 999.")
            return false
        end
      
        db.query(string.format('INSERT INTO `guild_wars`(`guild1`, `guild2`, `name1`, `name2`, `status`, `started`, `ended`, `fraglimit`) VALUES (%d, %d, %s, %s, %d, %d, %d, %d)', guildId, targetGuildId, db.escapeString(guildName), db.escapeString(targetGuildName), 0, 0, 0, fragsLimit))
        Game.broadcastMessage(string.format('%s sent %s a war invitation for %d frags.', guild:getName(), targetGuildName, fragsLimit), MESSAGE_EVENT_ADVANCE)
    elseif action:lower() == "accept" then
        if not hasMinimumMembersInGuild(guild) then
            player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('You need to have at least %d player%s online in your guild higher than level %d in order to execute this command.', minPlayersOnline, minPlayersOnline ~= 1 and 's', minLevel))
            return false
        end

        local acceptResult = db.storeQuery(string.format("SELECT `id`, `guild1`, `guild2` FROM `guild_wars` WHERE (`status` = 0 AND (name1 = %s AND name2 = %s) OR (name2 = %s AND name1 = %s))", db.escapeString(targetGuildName), db.escapeString(guildName), db.escapeString(guildName), db.escapeString(targetGuildName)))
        if not acceptResult then
            player:sendCancelMessage('There is no pending invitations with that guild.')
            return false
        end
      
        local invitationId = result.getNumber(acceptResult, "id")
        local guildInvited = result.getNumber(acceptResult, "guild1")
        local guildReceived = result.getNumber(acceptResult, "guild2")
        result.free(acceptResult)
        if guildInvited == guildId then
            player:sendCancelMessage('You can not accept your own war.')
            return false
        end

        db.query(string.format('UPDATE `guild_wars` SET `status` = 1, `started` = %d WHERE `id` = %d', os.time(), invitationId))
        Game.broadcastMessage(string.format('Guild %s accepted the war invitation made by guild %s.', guildName, targetGuildName), MESSAGE_EVENT_ADVANCE)
    elseif action:lower() == "reject" then   
        if not hasMinimumMembersInGuild(guild) then
            player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('You need to have at least %d player%s online in your guild higher than level %d in order to execute this command.', minPlayersOnline, minPlayersOnline ~= 1 and 's', minLevel))
            return false
        end

        local rejectId = db.storeQuery(string.format("SELECT `id`, `guild1`, `guild2` FROM `guild_wars` WHERE (`status` = 0 AND (name1 = %s AND name2 = %s) OR (name2 = %s AND name1 = %s))", db.escapeString(targetGuildName), db.escapeString(guildName), db.escapeString(guildName), db.escapeString(targetGuildName)))
        if not rejectId then
            player:sendCancelMessage('There is no pending invitations with that guild.')
            return false
        end

        local invitationId = result.getNumber(rejectId, "id")
        local guildInvited = result.getNumber(rejectId, "guild2")
        result.free(rejectId)
        if guildInvited == guildId then
            player:sendCancelMessage('You can not accept your own war.')
            return false
        end
      
        db.query(string.format('UPDATE `guild_wars` SET `status` = 2 WHERE `id` = %d', invitationId))
        Game.broadcastMessage(string.format('Guild %s rejected the war invitation made by guild %s.', guildName, targetGuildName), MESSAGE_EVENT_ADVANCE)
    elseif action:lower() == "end" then       
        local endResult = db.storeQuery(string.format("SELECT `id`, `guild1`, `guild2` FROM `guild_wars` WHERE (`status` = 1 AND (name1 = %s AND name2 = %s) OR (name2 = %s AND name1 = %s))", db.escapeString(targetGuildName), db.escapeString(guildName), db.escapeString(guildName), db.escapeString(targetGuildName)))
        if not endResult then
            player:sendCancelMessage('Your guild is not in war against them.')
            return false
        end

        local warId = result.getNumber(endResult, "id")   
        local guildInvited = result.getNumber(endResult, "guild1")
        local guildReceived = result.getNumber(endResult, "guild2")
        result.free(endResult)

        db.query(string.format('UPDATE `guild_wars` SET `status` = 4, `ended` = %d WHERE `id` = %d', os.time(), warId))
        Game.broadcastMessage(string.format('Guild %s just closed a war against guild %s.', guildName, targetGuildName), MESSAGE_EVENT_ADVANCE)
    elseif action:lower() == "cancel" then   
        if not hasMinimumMembersInGuild(guild) then
            player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('You need to have at least %d player%s online in your guild higher than level %d in order to execute this command.', minPlayersOnline, minPlayersOnline ~= 1 and 's', minLevel))
            return false
        end

        local resultCancel = db.storeQuery(string.format("SELECT `id`, `guild1` FROM `guild_wars` WHERE (`status` = 0 AND (name1 = %s AND name2 = %s) OR (name2 = %s AND name1 = %s))", db.escapeString(targetGuildName), db.escapeString(guildName), db.escapeString(guildName), db.escapeString(targetGuildName)))
        if not resultCancel then
            player:sendCancelMessage('There is no pending invitations with that guild.')
            return false
        end

        local invitationId = result.getNumber(resultCancel, "id")
        local guildInvited = result.getNumber(resultCancel, "guild1")
        result.free(resultCancel)
        if guildInvited ~= guildId then
            player:sendCancelMessage('You can not accept your own war.')
            return false
        end
      
        db.query(string.format('UPDATE `guild_wars` SET `status` = 3 WHERE `id` = %d', invitationId))
        Game.broadcastMessage(string.format('Guild %s canceled the war invitation to %s.', guildName, targetGuildName), MESSAGE_EVENT_ADVANCE)
    end
  
    return false
end
 
Try this:

Lua:
local minPlayersOnline = 1
local minLevel = 100

local function hasMinimumMembersInGuild(guild)
    local membersOnline = guild:getMembersOnline()
    local total = 0
    for _, member in ipairs(membersOnline) do
        if member:getLevel() >= minLevel then
            total = total + 1
        end
    end

    if total >= minPlayersOnline then
        return true
    end

    return false
end

function onSay(player, words, param)
    local guild = player:getGuild()
    if not guild then
        player:sendCancelMessage("You need to be on a guild in order to execute this command.")
        return false
    end

    if player:getGuildLevel() ~= 3 then
        player:sendCancelMessage("You are not the guild leader.")
        return false
    end

    local p = param:split(', ')
    local action, targetGuildName = p[1], p[2]
    if not action or not targetGuildName then
        player:popupFYI('Use the command correctly:' .. '\n\n' .. '\n\n Keep in mind\n\n Guild name should be the same shown on website. \n\nExample:\n' .. '--> !war invite, Guildname, 30' .. '\n\n' .. 'To accept a war:\n' .. '--> !war accept, Guildname' .. '\n\n' .. 'Reject war:\n' .. '--> !war reject, Guildname' .. '\n\n' .. 'Cancel war invite:\n' .. '--> !war cancel, Guildname' .. '\n\n' .. 'End war system:\n' .. '--> !war end, Guildname')
        return true
    end

    local resultName = db.storeQuery(string.format('SELECT `id` FROM `guilds` WHERE `name` = %s', db.escapeString(targetGuildName)))
    if not resultName then
        player:sendCancelMessage(string.format("Guild does not exists.", targetGuildName))
        return false
    end

    local targetGuildId = result.getNumber(resultName, "id")
    result.free(resultName)

    local guildId, guildName = guild:getId(), guild:getName()
    if action:lower() == "invite" then
        if not hasMinimumMembersInGuild(guild) then
            player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('You need to have at least %d player%s online in your guild higher than level %d in order to execute this command.', minPlayersOnline, minPlayersOnline ~= 1 and 's', minLevel))
            return false
        end

        if #p ~= 3 then
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'Please use the command correctly:\n!war invite, Guild name, frags\n\nExample:\n!war invite, Guild Name, 100')
            return false
        end

        local frags = p[3]
        if targetGuildName:lower() == guildName:lower() or guildId == targetGuildId then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You can not invite your own guild to a war.")
            return false
        end

        local resultInvite = db.storeQuery(string.format("SELECT `id` FROM `guild_wars` WHERE (((guild1 = %d AND guild2 = %d) OR (guild1 = %d AND guild2 = %d)) AND (status = 0 OR status = 1))", guildId, targetGuildId, targetGuildId, guildId))
        if resultInvite then
            player:sendCancelMessage("You already sent a war invitation to that guild.")
            result.free(resultInvite)
            return false
        end
     
        local fragsLimit = tonumber(frags)
        if not fragsLimit then
            player:sendCancelMessage("Please use only numbers in frags limit.")
            return false
        end

        if fragsLimit < 20 or fragsLimit > 999 then
            player:sendCancelMessage("The minimum frag limit is 20 and maximum 999.")
            return false
        end
     
        db.query(string.format('INSERT INTO `guild_wars`(`guild1`, `guild2`, `name1`, `name2`, `status`, `started`, `ended`, `fraglimit`) VALUES (%d, %d, %s, %s, %d, %d, %d, %d)', guildId, targetGuildId, db.escapeString(guildName), db.escapeString(targetGuildName), 0, 0, 0, fragsLimit))
        Game.broadcastMessage(string.format('%s sent %s a war invitation for %d frags.', guild:getName(), targetGuildName, fragsLimit), MESSAGE_EVENT_ADVANCE)
    elseif action:lower() == "accept" then
        if not hasMinimumMembersInGuild(guild) then
            player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('You need to have at least %d player%s online in your guild higher than level %d in order to execute this command.', minPlayersOnline, minPlayersOnline ~= 1 and 's', minLevel))
            return false
        end

        local acceptResult = db.storeQuery(string.format("SELECT `id`, `guild1`, `guild2` FROM `guild_wars` WHERE (`status` = 0 AND (name1 = %s AND name2 = %s) OR (name2 = %s AND name1 = %s))", db.escapeString(targetGuildName), db.escapeString(guildName), db.escapeString(guildName), db.escapeString(targetGuildName)))
        if not acceptResult then
            player:sendCancelMessage('There is no pending invitations with that guild.')
            return false
        end
     
        local invitationId = result.getNumber(acceptResult, "id")
        local guildInvited = result.getNumber(acceptResult, "guild1")
        local guildReceived = result.getNumber(acceptResult, "guild2")
        result.free(acceptResult)
        if guildInvited == guildId then
            player:sendCancelMessage('You can not accept your own war.')
            return false
        end

        db.query(string.format('UPDATE `guild_wars` SET `status` = 1, `started` = %d WHERE `id` = %d', os.time(), invitationId))
        Game.broadcastMessage(string.format('Guild %s accepted the war invitation made by guild %s.', guildName, targetGuildName), MESSAGE_EVENT_ADVANCE)
    elseif action:lower() == "reject" then  
        if not hasMinimumMembersInGuild(guild) then
            player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('You need to have at least %d player%s online in your guild higher than level %d in order to execute this command.', minPlayersOnline, minPlayersOnline ~= 1 and 's', minLevel))
            return false
        end

        local rejectId = db.storeQuery(string.format("SELECT `id`, `guild1`, `guild2` FROM `guild_wars` WHERE (`status` = 0 AND (name1 = %s AND name2 = %s) OR (name2 = %s AND name1 = %s))", db.escapeString(targetGuildName), db.escapeString(guildName), db.escapeString(guildName), db.escapeString(targetGuildName)))
        if not rejectId then
            player:sendCancelMessage('There is no pending invitations with that guild.')
            return false
        end

        local invitationId = result.getNumber(rejectId, "id")
        local guildInvited = result.getNumber(rejectId, "guild2")
        result.free(rejectId)
        if guildInvited == guildId then
            player:sendCancelMessage('You can not accept your own war.')
            return false
        end
     
        db.query(string.format('UPDATE `guild_wars` SET `status` = 2 WHERE `id` = %d', invitationId))
        Game.broadcastMessage(string.format('Guild %s rejected the war invitation made by guild %s.', guildName, targetGuildName), MESSAGE_EVENT_ADVANCE)
    elseif action:lower() == "end" then      
        local endResult = db.storeQuery(string.format("SELECT `id`, `guild1`, `guild2` FROM `guild_wars` WHERE (`status` = 1 AND (name1 = %s AND name2 = %s) OR (name2 = %s AND name1 = %s))", db.escapeString(targetGuildName), db.escapeString(guildName), db.escapeString(guildName), db.escapeString(targetGuildName)))
        if not endResult then
            player:sendCancelMessage('Your guild is not in war against them.')
            return false
        end

        local warId = result.getNumber(endResult, "id")  
        local guildInvited = result.getNumber(endResult, "guild1")
        local guildReceived = result.getNumber(endResult, "guild2")
        result.free(endResult)

        db.query(string.format('UPDATE `guild_wars` SET `status` = 4, `ended` = %d WHERE `id` = %d', os.time(), warId))
        Game.broadcastMessage(string.format('Guild %s just closed a war against guild %s.', guildName, targetGuildName), MESSAGE_EVENT_ADVANCE)
    elseif action:lower() == "cancel" then  
        if not hasMinimumMembersInGuild(guild) then
            player:sendTextMessage(MESSAGE_INFO_DESCR, string.format('You need to have at least %d player%s online in your guild higher than level %d in order to execute this command.', minPlayersOnline, minPlayersOnline ~= 1 and 's', minLevel))
            return false
        end

        local resultCancel = db.storeQuery(string.format("SELECT `id`, `guild1` FROM `guild_wars` WHERE (`status` = 0 AND (name1 = %s AND name2 = %s) OR (name2 = %s AND name1 = %s))", db.escapeString(targetGuildName), db.escapeString(guildName), db.escapeString(guildName), db.escapeString(targetGuildName)))
        if not resultCancel then
            player:sendCancelMessage('There is no pending invitations with that guild.')
            return false
        end

        local invitationId = result.getNumber(resultCancel, "id")
        local guildInvited = result.getNumber(resultCancel, "guild1")
        result.free(resultCancel)
        if guildInvited ~= guildId then
            player:sendCancelMessage('You can not accept your own war.')
            return false
        end
     
        db.query(string.format('UPDATE `guild_wars` SET `status` = 3 WHERE `id` = %d', invitationId))
        Game.broadcastMessage(string.format('Guild %s canceled the war invitation to %s.', guildName, targetGuildName), MESSAGE_EVENT_ADVANCE)
    end
 
    return false
end

Same like my script, but in your script, guild name can't have space in name (when i have guild with name "test two", i must change it to "testtwo")
i send test war for 20 frags, and i killed my test character 70 times and nothing happend
 
Working fine for me, something must be wrong with your sql schema

I don't have any errors about sql, so i think all is fine (now is status 4 cuz, end war by command !war end)

JBHSo2d.png
 
Back
Top