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

Lua Help to fix my /zones talkaction

warriorfrog

Active Member
Joined
Jul 29, 2015
Messages
334
Reaction score
35
Someone can help me to fix my /zones? To check wich guilds own citys
I found this script but is incompatible to my sources 0.4 (3884)

Error img:
https://i.imgur.com/Gt6X6tX.png

code:
Code:
function onSay(cid)
    local str =""
    for name, count in pairs(cityMonsters)do
        local guildName = getGuildName(getGlobalStorageValue(count + DEFAULT_STORAGE))
        if guildName then
            if str ==""then
                str ="Cidade "..name:explode(" ")[2].." dominada por "..guildName.."."
            else
                str = str.."\nCidade "..name:explode(" ")[2].." dominada por "..guildName.."."
            end
        end
    end
    doPlayerPopupFYI(cid, str ==""and"Nenhuma cidade conquistada."or str)
    return true
end
 
Code:
for name, count in pairs(cityMonsters)do
Where do you define cityMonsters?

It looks like your function is working, just not getting all the info it needs.

In my lib
Code:
cityMonsters = {
  --["monster_name"] = recomendo número anterior + 1,
  ["Chanceler Aurea"] = 1,
  ["Chanceler Kazz"] = 2,
  ["Chanceler Ab"] = 3,
   ["Chanceler Egron"] = 4,
   ["Chanceler Saari"] = 5,
   ["Chanceler Lirazarth"] = 6,
   ["Chanceler Rookgaardia"] = 7,
   ["Chanceler Snowden"] = 8,
  --etc
}
DEFAULT_STORAGE = 49198
function setGuildExperience(guildId, exp)
  for _, pid in pairs(getPlayersOnline()) do
  if getPlayerGuildId(pid) == guildId then
  doPlayerSetExperienceRate(pid, exp)
  end
  end
end
function getGuildExpRate(guildId)
  for _, pid in pairs(getPlayersOnline()) do
  local playerRate = getPlayerRates(pid)[8]
  if getPlayerGuildId(pid) == guildId and playerRate > 1 then
  return playerRate
  end
  end
  return 1.0
end
function getGuildName(guild_id)  --Omega
  local query = db.getResult("SELECT name FROM guilds WHERE id = "..guild_id)
  local ret = query:getID() == -1 and false or query:getDataString("name")
  query:free()
  return ret
end


What errors do you get on console when you try to run it?

U server is nice

Erros : https://i.imgur.com/Gt6X6tX.png
 
After this line:



Type

Code:
print(query:getDataString("name"))

Run the script until you get the bug and tell me what appear on your Distro terminal.

OnKill monster to capture new zone

Code:
function onTarget(cid, target)
  local m, playerGuild = cityMonsters[getCreatureName(target)], getPlayerGuildId(cid)
  if isPlayer(cid) and isMonster(target) and m and playerGuild > 0 then
  return getGlobalStorageValue(DEFAULT_STORAGE + m) ~= playerGuild
  end
  return true
end
function onStatsChange(cid, attacker, type, combat, value)
  if isPlayer(attacker) and isMonster(cid) and type == STATSCHANGE_HEALTHLOSS then
  local m, playerGuild = cityMonsters[getCreatureName(cid)], getPlayerGuildId(attacker)
  if m and playerGuild > 0 then
  return getGlobalStorageValue(DEFAULT_STORAGE + m) ~= playerGuild
  end
  end
  return true
end
function onLogin(cid)
  local guildId = getPlayerGuildId(cid)
  if guildId > 0 and getGuildExpRate(guildId) > 1 then
  doPlayerSetExperienceRate(cid, getGuildExpRate(guildId))
  end
  registerCreatureEvent(cid, "mTarget")
  registerCreatureEvent(cid, "mStatsChange")
  return true
end   
function onDeath(cid, corpse, deathList)
  local killer, m = deathList[1], cityMonsters[getCreatureName(cid)]
  if killer and isPlayer(killer) and m then
  local atualGuild, playerGuild = getPlayerStorageValue(cid, DEFAULT_STORAGE + m), getPlayerGuildId(killer)
  if playerGuild > 0 and atualGuild ~= playerGuild then
  if atualGuild > -1 then
  setGuildExperience(atualGuild, getGuildExpRate(atualGuild) - 0.05)
  end
  setGuildExperience(playerGuild, getGuildExpRate(playerGuild) + 0.05)
  setGlobalStorageValue(DEFAULT_STORAGE + m, playerGuild)
  broadcastMessage("A guild "..getPlayerGuildName(killer).." acaba de dominar "..getCreatureName(cid):explode(" ")[2].."!")
  end
  end
  return true
end


/territorios (/zones)
Code:
function onSay(cid)
  local str = ""
  for name, count in pairs(cityMonsters) do
  local guildName = getGuildName(getGlobalStorageValue(count + DEFAULT_STORAGE))
  if guildName then
  if str == "" then
  str = "Cidade "..name:explode(" ")[2].." dominada por "..guildName.."."
  else
  str = str.."\nCidade "..name:explode(" ")[2].." dominada por "..guildName.."."
  end
  end
  end
  doPlayerPopupFYI(cid, str == "" and "Nenhuma cidade conquistada." or str)
  return true
end

Error

https://i.imgur.com/RYg8uli.png
 
Back
Top