Ir para conteúdo
  • Cadastre-se

(Resolvido)top fragger effect on player


Ir para solução Resolvido por Dwarfer,

Posts Recomendados

When player with top frags login the game, the effect will be shown.

 

Create a file in creaturescripts/scripts:

 

frageffect.lua

 

Spoiler

local t = {
text = "KILLER", 
effect = 28, 
time = 5 -- interval in second between effects
}

function onLogin(cid)
query = db.getResult("SELECT `player_id`, COUNT(`player_id`) as count FROM `player_killers` GROUP BY `player_id` ORDER BY count DESC LIMIT 1")
    if query:getID() ~= -1 then
        name = getPlayerNameByGUID(query:getDataString("player_id"))
        if getPlayerName(cid) == name then
            SendEffect(cid)
        end
    end
return true
end

function SendEffect(cid)
if isPlayer(cid) then
    doSendMagicEffect(getPlayerPosition(cid), t.effect)
    doSendAnimatedText(getPlayerPosition(cid), t.text, COLOR_LIGHTGREEN)
    addEvent(SendEffect, t.time*1000, cid) 
end
return true
end

 

 

In creaturescripts.xml, add the tag:  <event type="login" name="TopFrags" event="script" value="frageffect.lua"/>

Editado por Dwarfer (veja o histórico de edições)

Contato:

 

Link para o post
Compartilhar em outros sites

thanks @Dwarfer working fine 

can you make another script for top magic level and top guild please i think its all about data base Query 

if its ok 

thanks in advance :)

Link para o post
Compartilhar em outros sites

What did you mean with topguild? Guild with more frags, right? If yes, you can try:

 

Spoiler

local t = {
[1] = {effect = 28, text = "KILLER", time = 10, color = COLOR_LIGHTGREEN}, --topfrags
[2] = {effect = 29, text = "HOT MAGE", time = 10, color = COLOR_DARKRED}, -- topML
[3] = {effect = 30, text = "HOT GUILD", time = 10, color = COLOR_LIGHTBLUE} --topGuildFrags
}

function onLogin(cid)
qrys = {
[1] = db.getResult("SELECT `name` FROM `players` WHERE id = (SELECT `player_id` FROM `player_killers` GROUP BY `player_id` ORDER BY COUNT(`player_id`) DESC LIMIT 1)"),
[2] = db.getResult("SELECT `name` FROM `players` WHERE `group_id` < 2 ORDER BY `maglevel` DESC LIMIT 1"),
[3] = db.getResult("SELECT `g`.`id` AS `id`, `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 1")
}

list = {}
for _, v in pairs(qrys) do
    if v:getID() == -1 then
        return true
    end
    table.insert(list, v:getDataString("name"))
end

local index = getTopWhat(cid, list, getPlayerName(cid))

if index ~= nil then
    SendEffect(cid, t[index].effect, t[index].text, t[index].time, t[index].color)
end

return true
end

function SendEffect(cid, effect, text, time, color)
if isPlayer(cid) then
    doSendMagicEffect(getPlayerPosition(cid), effect)
    doSendAnimatedText(getPlayerPosition(cid), text, color)
    addEvent(SendEffect, time*1000, cid, effect, text, time, color) 
end
return true
end

function getTopWhat(cid, list, name)
for i, k in pairs(list) do
    if k == name or k == getPlayerGuildName(cid) then
        return i 
    end
end
return nil
end

 

 

 

Editado por Dwarfer (veja o histórico de edições)

Contato:

 

Link para o post
Compartilhar em outros sites
21 hours ago, Dwarfer said:

What did you mean with topguild? Guild with more frags, right? If yes, you can try:

 

  Hide contents


local t = {
[1] = {effect = 28, text = "KILLER", time = 10, color = COLOR_LIGHTGREEN}, --topfrags
[2] = {effect = 29, text = "HOT MAGE", time = 10, color = COLOR_DARKRED}, -- topML
[3] = {effect = 30, text = "HOT GUILD", time = 10, color = COLOR_LIGHTBLUE} --topGuildFrags
}

function onLogin(cid)
qrys = {
[1] = db.getResult("SELECT `name` FROM `players` WHERE id = (SELECT `player_id` FROM `player_killers` GROUP BY `player_id` ORDER BY COUNT(`player_id`) DESC LIMIT 1)"),
[2] = db.getResult("SELECT `name` FROM `players` WHERE `group_id` < 2 ORDER BY `maglevel` DESC LIMIT 1"),
[3] = db.getResult("SELECT `name` FROM `guilds` WHERE id = (SELECT `guild_id` FROM `guild_kills` GROUP BY `guild_id` ORDER BY COUNT(`guild_id`) DESC LIMIT 1)")
}

list = {}
for _, v in pairs(qrys) do
    if v:getID() == -1 then
        return true
    end
    table.insert(list, v:getDataString("name"))
end

local index = getTopWhat(cid, list, getPlayerName(cid))

if index ~= nil then
    SendEffect(cid, t[index].effect, t[index].text, t[index].time, t[index].color)
end

return true
end

function SendEffect(cid, effect, text, time, color)
if isPlayer(cid) then
    doSendMagicEffect(getPlayerPosition(cid), effect)
    doSendAnimatedText(getPlayerPosition(cid), text, color)
    addEvent(SendEffect, time*1000, cid, effect, text, time, color) 
end
return true
end

function getTopWhat(cid, list, name)
for i, k in pairs(list) do
    if k == name or k == getPlayerGuildName(cid) then
        return i 
    end
end
return nil
end

 

 

 

not working and i registered it and every thing no err in console 

if you just make every script alone not all in 1 script maybe it work 

thank you @Dwarfer

Link para o post
Compartilhar em outros sites
  • Solução

Hi. I had made a point of testing this code before sending it to you and worked correctly. It's not because they are "together" in only one script. Are you sure does your server have a guild with kills, right? Anyway, as you said, you can try them separated. 

 

Spoiler

local t = {effect = 29, text = "HOT MAGE", time = 10, color = COLOR_DARKRED}

function onLogin(cid)
query =  db.getResult("SELECT `name` FROM `players` WHERE `group_id` < 2 ORDER BY `maglevel` DESC LIMIT 1")
    if query:getID() ~= -1 then
        name = query:getDataString("name")
        if getPlayerName(cid) == name then
            SendEffect(cid, t.effect, t.text, t.time, t.color)
        end
    end
return true
end

function SendEffect(cid, effect, text, time, color)
if isPlayer(cid) then
    doSendMagicEffect(getPlayerPosition(cid), effect)
    doSendAnimatedText(getPlayerPosition(cid), text, color)
    addEvent(SendEffect, time*1000, cid, effect, text, time, color) 
end
return true
end

 

 

 

Spoiler

local t = {effect = 30, text = "HOT GUILD", time = 10, color = COLOR_LIGHTBLUE}

function onLogin(cid)
query = db.getResult("SELECT `g`.`id` AS `id`, `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 1")
    if query:getID() ~= -1 then
        name = query:getDataString("name")
        if getPlayerGuildName(cid) == name then
            SendEffect(cid, t.effect, t.text, t.time, t.color)
        end
    end
return true
end

function SendEffect(cid, effect, text, time, color)
if isPlayer(cid) then
    doSendMagicEffect(getPlayerPosition(cid), effect)
    doSendAnimatedText(getPlayerPosition(cid), text, color)
    addEvent(SendEffect, time*1000, cid, effect, text, time, color) 
end
return true
end

 

 

Use them in addition to the first.

 

Editado por Dwarfer (veja o histórico de edições)

Contato:

 

Link para o post
Compartilhar em outros sites
Em 17/08/2017 em 10:16, Dwarfer disse:

When player with top frags login the game, the effect will be shown.

 

Create a file in creaturescripts/scripts:

 

frageffect.lua

 

  Ocultar conteúdo


local t = {
text = "KILLER", 
effect = 28, 
time = 5 -- interval in second between effects
}

function onLogin(cid)
query = db.getResult("SELECT `player_id`, COUNT(`player_id`) as count FROM `player_killers` GROUP BY `player_id` ORDER BY count DESC LIMIT 1")
    if query:getID() ~= -1 then
        name = getPlayerNameByGUID(query:getDataString("player_id"))
        if getPlayerName(cid) == name then
            SendEffect(cid)
        end
    end
return true
end

function SendEffect(cid)
if isPlayer(cid) then
    doSendMagicEffect(getPlayerPosition(cid), t.effect)
    doSendAnimatedText(getPlayerPosition(cid), t.text, COLOR_LIGHTGREEN)
    addEvent(SendEffect, t.time*1000, cid) 
end
return true
end

 

 

In creaturescripts.xml, add the tag:  <event type="login" name="TopFrags" event="script" value="frageffect.lua"/>

 

Error

 

http://prntscr.com/gai6q3

 

>Tfs 0.4

O rei de seu proprio destino é aquele que luta pela gloria do amanhã!
Discord : ZoR#9373


 

Link para o post
Compartilhar em outros sites

same error here too

@Dwarfer

 

[2:29:29.883] Santa Slayer has logged in.

[2:29:29.885] [Error - CreatureScript Interface]
[2:29:29.885] data/creaturescripts/scripts/toplvlmag.lua:onLogin
[2:29:29.886] Description:
[2:29:29.887] (luaGetPlayerNameByGUID) Player not found

 

and i have this script for top level 

can you make it work for magic lvl

and it have storage and on advance so its better 

and thanks again for making time to help me .

 

local config = {
   time = 10, --time in seconds
   message = {
      text = "TOP LEVEL", -- Dont use more than 10 characters
      effect = TEXTCOLOR_LIGHTGREEN --effect on doSendAnimatedText
   },
   effect = 30, --effect on MagicEffect
   globalstr = 150202 -- globalstorage empty
}
function TopEffect(cid)
   local var = tostring(getGlobalStorageValue(config.globalstr)):gsub(':', ''):explode(',')
   if not isCreature(cid) or getPlayerName(cid) ~= var[1] then return LUA_ERROR end
   doSendAnimatedText(getCreaturePosition(cid), config.message.text, config.message.effect)
   doSendMagicEffect(getCreaturePosition(cid), config.effect)
   addEvent(TopEffect, config.time*1000, cid)
end
function onLogin(cid)
   if tonumber(getGlobalStorageValue(config.globalstr)) then -- virgin
      local query = db.getResult("SELECT `name`, `level` FROM `players` WHERE `group_id` < 2 ORDER BY `level` DESC LIMIT 1")
      if (query:getID() ~= -1) then
         setGlobalStorageValue(config.globalstr, ":"..query:getDataString("name")..",:"..query:getDataInt("level"))
         TopEffect(cid)
      end
   else
      TopEffect(cid)
   end
   registerCreatureEvent(cid, "CheckTop")
   return true
end
function onAdvance(cid, skill, oldLevel, newLevel)
   if skill ~= SKILL__LEVEL then return true end
   local var = tostring(getGlobalStorageValue(config.globalstr)):gsub(':', ''):explode(',')
   if newLevel > tonumber(var[2]) then
      doBroadcastMessage("Good Job " .. getPlayerName(cid) .. " you are the TOP LEVEL now!", 21)
      setGlobalStorageValue(config.globalstr, ":"..getPlayerName(cid)..",:"..newLevel)
      TopEffect(cid)
   end  
   return true
end

 

Link para o post
Compartilhar em outros sites

Is this error for magic or guild? Actually, for topguild i realized an error maybe when i copied and pasted.

 

local t = {effect = 30, text = "HOT GUILD", time = 10, color = COLOR_LIGHTBLUE}

function onLogin(cid)
query = db.getResult("SELECT `g`.`id` AS `id`, `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 1")
    if query:getID() ~= -1 then
        name = query:getDataString("name")
        if getPlayerGuildName(cid) == name then
            SendEffect(cid, t.effect, t.text, t.time, t.color)
        end
    end
return true
end

function SendEffect(cid, effect, text, time, color)
if isPlayer(cid) then
    doSendMagicEffect(getPlayerPosition(cid), effect)
    doSendAnimatedText(getPlayerPosition(cid), text, color)
    addEvent(SendEffect, time*1000, cid, effect, text, time, color) 
end
return true
end

 

You can use for magic that i did before. You can talk to the owner's script about modifications. 

Editado por Dwarfer (veja o histórico de edições)

Contato:

 

Link para o post
Compartilhar em outros sites

@Dwarfer this what happened when i logged in

 

[0:45:49.724] Pally has logged in.

[0:45:49.726] [Error - CreatureScript Interface]
[0:45:49.726] data/creaturescripts/scripts/topfrag.lua:onLogin
[0:45:49.727] Description:
[0:45:49.727] data/creaturescripts/scripts/topguild.lua:18: attempt to perform a
rithmetic on local 'time' (a nil value)
[0:45:49.727] stack traceback:
[0:45:49.727]   data/creaturescripts/scripts/topguild.lua:18: in function 'SendE
ffect'
[0:45:49.728]   data/creaturescripts/scripts/topfrag.lua:12: in function <data/c
reaturescripts/scripts/topfrag.lua:7>
[0:45:49.796] Pally has logged out.

 

Link para o post
Compartilhar em outros sites

@Dwarfer 

top guild err

[0:45:49.727] data/creaturescripts/scripts/topguild.lua:18: attempt to perform a
rithmetic on local 'time' (a nil value)
[0:45:49.727] stack traceback:
[0:45:49.727]   data/creaturescripts/scripts/topguild.lua:18: in function 'SendE
ffect'

@Dwarfer great support here 

 

working fine 

thanks to Dwarfer <3

 

Solved 

Link para o post
Compartilhar em outros sites
  • 3 years later...

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo