Ir para conteúdo

Featured Replies

Postado
  • 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:

 

  • Respostas 12
  • Visualizações 1.4k
  • Created
  • Última resposta

Top Posters In This Topic

Postado
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


 

Postado
  • Autor

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

 

Postado

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:

 

Postado
  • Autor

@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.

 

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo