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

Help with Guild War System (FRAG LIMIT TFS 1.3)

Grillo1995

New Member
Joined
Feb 8, 2018
Messages
21
Solutions
1
Reaction score
0
Location
Brazil
Hello everyone. :)

I have a problem with my War System, I will try to explain.

See this image:
print1guild.png


After making the declaration of war on the website, everything is fine.

On the website the player types the number of frags that is stored in the 3rd column as you can see in the image.

And after accepting the war invitation on the website, the 'status' is changed to 1 as you can see in the image.

The problem is, the war is endless! Players keep killing themselves and don't count the frags! How can I do to count this frag, and when it reaches the LIMIT that the player put it on the site, the war is over?

Thank you and I'm waiting!

Codes:
creaturescripts/scripts/playerondeath.lua = hastebin (https://hastebin.com/icikivatoy)
pages/guilds.php = hastebin (https://hastebin.com/efirodapuq)
classes/guildwar.php = hastebin (https://hastebin.com/fotakopegi)
 
Last edited:

josejunior23

read&read&read
Joined
Apr 13, 2008
Messages
741
Solutions
1
Reaction score
62
Location
Portugal
made you this 2 functions you can use to getfraglimit and check if guild x has enough kills (not tested)

Lua:
function getFragLimit(warId)
    local fraglimit = 0
    local query = db.storeQuery("SELECT `fraglimit` FROM `guild_wars` WHERE `id` = " .. warId .. " LIMIT 1")
    if(query ~= false) then
        fraglimit = result.getDataInt(query, "fraglimit")
    end
    result.free(query) 
    return fraglimit
end

function getGuildKills(guildId, warId)
    local totalKills = 0
    local query = db.storeQuery("SELECT `killer` FROM `guildwar_kills` WHERE `warid` = " .. guildId .. " AND `killerguild` = " .. warId .. " ORDER BY `time`;")
    if(query ~= false) then
        repeat
            totalKills = totalKills + 1
        until not result.next(query)
    end
    result.free(query) 
    return totalKills
end
Post automatically merged:

i forgot the delete war one... here it is:

Lua:
function deleteGuildWar(warid)
    local query = db.storeQuery("SELECT `warid` FROM `guildwar_kills` WHERE `id` = "..warid..";")
    if(query ~= false) then
        repeat
            db.asyncQuery("DELETE FROM `guildwar_kills` WHERE `warid` = \"" .. warid .. "\";")
        until not result.next(query)
        db.asyncQuery("DELETE FROM `guild_wars` WHERE `id` = \"" .. warid .. "\";")
    end
    result.free(query)   
    return true
end

or if you just want to update the "ended" to 0 or 1:


Lua:
function updateWarEnded(warid, ended) -- ended = 0 or 1?
    local query = db.storeQuery("SELECT `id` FROM `guild_wars` WHERE `id` = "..warid.." LIMIT 1")
    if(query ~= false) then
        db.asyncQuery("UPDATE `guild_wars` SET `ended` = " .. ended .. " WHERE `id` = " .. warid .. ";")   
    end
    result.free(query)   
    return true
end
 
Last edited:
OP
Grillo1995

Grillo1995

New Member
Joined
Feb 8, 2018
Messages
21
Solutions
1
Reaction score
0
Location
Brazil
made you this 2 functions you can use to getfraglimit and check if guild x has enough kills (not tested)

Lua:
function getFragLimit(warId)
    local fraglimit = 0
    local query = db.storeQuery("SELECT `fraglimit` FROM `guild_wars` WHERE `id` = " .. warId .. " LIMIT 1")
    if(query ~= false) then
        fraglimit = result.getDataInt(query, "fraglimit")
    end
    result.free(query)
    return fraglimit
end

function getGuildKills(guildId, warId)
    local totalKills = 0
    local query = db.storeQuery("SELECT `killer` FROM `guildwar_kills` WHERE `warid` = " .. guildId .. " AND `killerguild` = " .. warId .. " ORDER BY `time`;")
    if(query ~= false) then
        repeat
            totalKills = totalKills + 1
        until not result.next(query)
    end
    result.free(query)
    return totalKills
end
Post automatically merged:

i forgot the delete war one... here it is:

Lua:
function deleteGuildWar(warid)
    local query = db.storeQuery("SELECT `warid` FROM `guildwar_kills` WHERE `id` = "..warid..";")
    if(query ~= false) then
        repeat
            db.asyncQuery("DELETE FROM `guildwar_kills` WHERE `warid` = \"" .. warid .. "\";")
        until not result.next(query)
        db.asyncQuery("DELETE FROM `guild_wars` WHERE `id` = \"" .. warid .. "\";")
    end
    result.free(query)  
    return true
end

or if you just want to update the "ended" to 0 or 1:


Lua:
function updateWarEnded(warid, ended) -- ended = 0 or 1?
    local query = db.storeQuery("SELECT `id` FROM `guild_wars` WHERE `id` = "..warid.." LIMIT 1")
    if(query ~= false) then
        db.asyncQuery("UPDATE `guild_wars` SET `ended` = " .. ended .. " WHERE `id` = " .. warid .. ";")  
    end
    result.free(query)  
    return true
end

Good morning josejunior23, thanks for your reply! In case these functions will I add to ondeath? in creatuarescripts?
 
Top