• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved Top Guild Effect

kafo

Well-known Member
Joined
Oct 14, 2011
Messages
209
Reaction score
17
Location
Egypt
Hello OTlanders,,,

i need help plz guys i searched for a script that make an effect to top guild players i found this

Code:
[code=lua]
local highscorefrags = getHighscoreString(Frags)
function onThink(interval, lastExecution)
    if getPlayerGuildFrags(cid) == highscorefrags then
              doSendMagicEffect(getPlayerPosition(cid), 27)
                  doSendAnimatedText(getPlayerPosition(cid), "TOP FRAGS", TEXTCOLOR_RED)
              end
       
        return true
end
[/CODE]

but i cant make the method getPlayerGuildFrags(cid) could any1 help me plz :D
 
I made this script, works properly but make freez.
Code:
function onThink(interval, lastExecution)
                    local text = {"1ST GUILD", "2ND GUILD", "3RD GUILD", "4TH GUILD"}
                    local info = db.getResult('SELECT `g`.`name` AS `name`, COUNT(`g`.`name`) as `frags` FROM `killers` k LEFT JOIN `player_killers` pk ON `k`.`id` = `pk`.`kill_id` LEFT JOIN `players` p ON `pk`.`player_id` = `p`.`id` LEFT JOIN `guild_ranks` gr ON `p`.`rank_id` = `gr`.`id` LEFT JOIN `guilds` g ON `gr`.`guild_id` = `g`.`id` WHERE `k`.`unjustified` = 1 AND `k`.`final_hit` = 1 GROUP BY `name` ORDER BY `frags` DESC, `name` ASC LIMIT 0, 4;')
                    if(info:getID() == -1) then
                        return true
                    end
                    local guilds, frags = {}, {}
                    while(info:next()) do
                        table.insert(guilds, info:getDataString("name"))
                        table.insert(frags, info:getDataString("frags"))
                    end
                    info:free()
                    if(#guilds < 1 and #frags < 1) then
                        return true
                    end
                    for _, pid in ipairs(getPlayersOnline()) do
                        for i = 1, 4 do
                            if(#guilds >= i) then
                                if(getPlayerGuildName(pid) == guilds[i]) then
                                    doSendAnimatedText(getCreaturePosition(pid), text[i], TEXTCOLOR_RED)
                                end
                            end
                        end
                    end
                    doBroadcastMessage("Best guild on server is ".. guilds[1] .." with ".. frags[1] .." kills!")
                    return true
                end

How often is it executed?
If it's executed quite often then I would store the query in another function and then check how long ago we checked the query, then update it maybe each 5 min.
Aka cache it.
 
WibbenZ.. An example of how to copy another function?
Long time want to know how to store something in a function.
=d
 
WibbenZ.. An example of how to copy another function?
Long time want to know how to store something in a function.
=d

You don't store them in the function, since the function they are renewed each time you call it.
You store them in global variables so they don't get renewd unless you overwrite the variable.
The function is used to check if the time variable has passed the time + ex 5 min and if that is the case overwrite the query variable with the new query output.
 
I made this script, works properly but make freez.
Code:
function onThink(interval, lastExecution)
                    local text = {"1ST GUILD", "2ND GUILD", "3RD GUILD", "4TH GUILD"}
                    local info = db.getResult('SELECT `g`.`name` AS `name`, COUNT(`g`.`name`) as `frags` FROM `killers` k LEFT JOIN `player_killers` pk ON `k`.`id` = `pk`.`kill_id` LEFT JOIN `players` p ON `pk`.`player_id` = `p`.`id` LEFT JOIN `guild_ranks` gr ON `p`.`rank_id` = `gr`.`id` LEFT JOIN `guilds` g ON `gr`.`guild_id` = `g`.`id` WHERE `k`.`unjustified` = 1 AND `k`.`final_hit` = 1 GROUP BY `name` ORDER BY `frags` DESC, `name` ASC LIMIT 0, 4;')
                    if(info:getID() == -1) then
                        return true
                    end
                    local guilds, frags = {}, {}
                    while(info:next()) do
                        table.insert(guilds, info:getDataString("name"))
                        table.insert(frags, info:getDataString("frags"))
                    end
                    info:free()
                    if(#guilds < 1 and #frags < 1) then
                        return true
                    end
                    for _, pid in ipairs(getPlayersOnline()) do
                        for i = 1, 4 do
                            if(#guilds >= i) then
                                if(getPlayerGuildName(pid) == guilds[i]) then
                                    doSendAnimatedText(getCreaturePosition(pid), text[i], TEXTCOLOR_RED)
                                end
                            end
                        end
                    end
                    doBroadcastMessage("Best guild on server is ".. guilds[1] .." with ".. frags[1] .." kills!")
                    return true
                end
thx bro i will test it as soon as possible
 
How often is it executed?
If it's executed quite often then I would store the query in another function and then check how long ago we checked the query, then update it maybe each 5 min.
Aka cache it.
It depends from user. Ofc, we can save the result in globalstorage but while taking the result it makes freez. The main problem is that: the query taking result from the longest database - "killers".
In my opinion best option to solve it is making new one database "guilds_kills" and saving each kill in this database. If we will make script by this way, query will be much shorter and safer.
 
It depends from user. Ofc, we can save the result in globalstorage but while taking the result it makes freez. The main problem is that: the query taking result from the longest database - "killers".
In my opinion best option to solve it is making new one database "guilds_kills" and saving each kill in this database. If we will make script by this way, query will be much shorter and safer.

Yeah there are a couple of diffrent ways of doing it, you could also just execute it at startup and then have a daily server save.
 
I made this script, works properly but make freez.
Code:
function onThink(interval, lastExecution)
                    local text = {"1ST GUILD", "2ND GUILD", "3RD GUILD", "4TH GUILD"}
                    local info = db.getResult('SELECT `g`.`name` AS `name`, COUNT(`g`.`name`) as `frags` FROM `killers` k LEFT JOIN `player_killers` pk ON `k`.`id` = `pk`.`kill_id` LEFT JOIN `players` p ON `pk`.`player_id` = `p`.`id` LEFT JOIN `guild_ranks` gr ON `p`.`rank_id` = `gr`.`id` LEFT JOIN `guilds` g ON `gr`.`guild_id` = `g`.`id` WHERE `k`.`unjustified` = 1 AND `k`.`final_hit` = 1 GROUP BY `name` ORDER BY `frags` DESC, `name` ASC LIMIT 0, 4;')
                    if(info:getID() == -1) then
                        return true
                    end
                    local guilds, frags = {}, {}
                    while(info:next()) do
                        table.insert(guilds, info:getDataString("name"))
                        table.insert(frags, info:getDataString("frags"))
                    end
                    info:free()
                    if(#guilds < 1 and #frags < 1) then
                        return true
                    end
                    for _, pid in ipairs(getPlayersOnline()) do
                        for i = 1, 4 do
                            if(#guilds >= i) then
                                if(getPlayerGuildName(pid) == guilds[i]) then
                                    doSendAnimatedText(getCreaturePosition(pid), text[i], TEXTCOLOR_RED)
                                end
                            end
                        end
                    end
                    doBroadcastMessage("Best guild on server is ".. guilds[1] .." with ".. frags[1] .." kills!")
                    return true
                end
it works but it make every1 on the ot 1st guild and broadcast this
02:01 Best guild on server is with 0 kills!
 
fixed

and i just remove somethings


Code:
function onThink(interval, lastExecution)
                    local info = db.getResult('SELECT `g`.`name` AS `name`, COUNT(`g`.`name`) as `frags` FROM `killers` k LEFT JOIN `player_killers` pk ON `k`.`id` = `pk`.`kill_id` LEFT JOIN `players` p ON `pk`.`player_id` = `p`.`id` LEFT JOIN `guild_ranks` gr ON `p`.`rank_id` = `gr`.`id` LEFT JOIN `guilds` g ON `gr`.`guild_id` = `g`.`id` WHERE `k`.`unjustified` = 1 AND `k`.`final_hit` = 1 GROUP BY `name` ORDER BY `frags` DESC, `name` ASC LIMIT 0, 4;')
                    if(info:getID() == -1) then
                        return true
                    end
                    local guilds = info:getDataString("name")

                    for _, cid in ipairs(getPlayersOnline()) do
                                if(getPlayerGuildName(cid) == guilds) then
                                    doSendAnimatedText(getCreaturePosition(cid),"Top Guild", TEXTCOLOR_WHITE) 
                        end
                    end
                    return true
                end

thx GarQet
 
set this:
Code:
if(#guilds < 1 and #frags < 1) then
return true
end
to this:
Code:
if(#guilds < 1 or #frags < 1) then
return true
end
and will work for 4 guilds
 
Back
Top