• Sign up for TFS Icon Competition! The prize includes Otland Premium time and a medal, as well as obviously taking part in TFS history.
  • 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!

TFS 0.X War Anti-entrosa

jukilo3d

New Member
Joined
May 5, 2011
Messages
16
Reaction score
2
Good night guys!
I have a little problem in my anti-war war.

when will you accept this error

[21: 3: 38.589] [Error - TalkAction interface]
[21: 3: 38.590] data / talkactions / scripts / events / warEntrosa.lua: onSay
[21: 3: 38.590] Description:
[21: 3: 38.590] data / lib / citywar_lib.lua: 106: attempt to compare the number with the Boolean
[21: 3: 38.592] stack tracking:
[21: 3: 38.593] data / lib / citywar_lib.lua: 106: in the 'accept' function
[21: 3: 38.593] data / talkactions / scripts / events / warEntrosa.lua: 7: in the function <data / talkactions / scripts / events / warEntrosa.lua: 1>

Can someone help me. Thank you very much!

-- #################################################################### --
-- ############ Desenvolvido por Tony Araújo (OrochiElf) ############## --
-- #################################################################### --

CityWar_Configurations = {
Players_Mode = {min = 5, max = 50},
TimePrice_Mode = {[15] = 50000, [30] = 75000, [60] = 90000, [120] = 120000},
War_Mode = {
["tradicional, padrao, normal, 1"] = 1,
["sem ue, semue, 2"] = 2,
["sosd, apenas sd, só sd, soh sd, 3"] = 3;
},
Maps_Mode = {
["carlin"] = {teamA = {x = 1424, y = 377, z = 7}, teamB = {x = 1378, y = 378, z = 7}},
["darashia"] = {teamA = {x = 32859, y = 34023, z = 8}, teamB = {x = 32935, y = 34044, z = 6}},
["thais"] = {teamA = {x = 32514, y = 33722, z = 7}, teamB = {x = 32479, y = 33681, z = 7}},
[""] = {teamA = {x = 32441, y = 33527, z = 7}, teamB = {x = 32503, y = 33506, z = 7}},
["fibula"] = {teamA = {x = 32309, y = 33886, z = 7}, teamB = {x = 32356, y = 33956, z = 6}},
["edron"] = {teamA = {x = 33038, y = 33663, z = 7}, teamB = {x = 32969, y = 33541, z = 6}},
["new island"] = {teamA = {x = 32573, y = 34007, z = 7}, teamB = {x = 32496, y = 33949, z = 6}},
["venore"] = {teamA = {x = 32820, y = 33606, z = 7}, teamB = {x = 32725, y = 33629, z = 7}};
}
}

CityWar_WarsRunning = {}
CityWar = {}
War = {}

local function getGuildName(id)
local Info = db.getResult("SELECT name FROM guilds WHERE id = " .. id .. ";")
if Info:getID() ~= LUA_ERROR then
local Name = Info:getDataString("name")
Info:free()
return Name
end
return true
end

function CityWar.setMode(_player, _mode)
return setPlayerStorageValue(_player, 87511, _mode)
end

function CityWar.checkWar(_city)
if not CityWar_WarsRunning[_city].accepted then
CityWar_WarsRunning[_city]:broadcast(22, "[City War]\nO convite nao foi aceito, portanto a war foi cancelada.", true)
CityWar_WarsRunning[_city] = nil
return true
end
end

function CityWar.inWar(_guildID)
for _, war in pairs(CityWar_WarsRunning) do
if war.challengedGuildID == _guildID or war.challengerGuildID == _guildID and war.accepted then
return true
end
end
return false
end

function CityWar.invite(_challengerID, _challengedGuildName, _city, _players, _mode, _time)
if getPlayerGuildLevel(_challengerID) >= 3 then
if getGuildId(_challengedGuildName) and getPlayerGuildId(_challengerID) ~= getGuildId(_challengedGuildName) then
if not CityWar.inWar(getGuildId(_challengedGuildName)) then
if CityWar_Configurations.Maps_Mode[_city] then
if not CityWar_WarsRunning[_city] then
if _players ~= nil and _players >= CityWar_Configurations.Players_Mode.min and _players <= CityWar_Configurations.Players_Mode.max then
for mode, typeID in pairs(CityWar_Configurations.War_Mode) do
if _mode ~= nil and mode:find(_mode) then
if _time ~= nil and CityWar_Configurations.TimePrice_Mode[_time] then
if(doPlayerRemoveMoney(_challengerID, CityWar_Configurations.TimePrice_Mode[_time]) == true)then
CityWar_WarsRunning[_city] = War:new(getPlayerGuildId(_challengerID), getGuildId(_challengedGuildName), _players, _time, typeID, _city)
return true
else
doPlayerSendTextMessage(_challengerID, MESSAGE_STATUS_CONSOLE_BLUE, "Voce nao tem dinheiro suficiente.")
return true
end
else
doPlayerSendTextMessage(_challengerID, MESSAGE_STATUS_CONSOLE_BLUE, "O tempo requisitado nao e disponivel.")
return true
end
end
end
doPlayerSendTextMessage(_challengerID, MESSAGE_STATUS_CONSOLE_BLUE, "Este modulo nao existe, escolha entre 1 e 3. Para mais informacoes, digite !citywar info")
else
doPlayerSendTextMessage(_challengerID, MESSAGE_STATUS_CONSOLE_BLUE, "Este numero de jogadores e invalido, use apenas de " .. CityWar_Configurations.Players_Mode.min .. " a " .. CityWar_Configurations.Players_Mode.max .. ".")
end
else
doPlayerSendTextMessage(_challengerID, MESSAGE_STATUS_CONSOLE_BLUE, "Esta cidade ja está sendo usada")
end
else
doPlayerSendTextMessage(_challengerID, MESSAGE_STATUS_CONSOLE_BLUE, "Nao foi possivel encontrar esta cidade.")
end
else
doPlayerSendTextMessage(_challengerID, MESSAGE_STATUS_CONSOLE_BLUE, "Esta guild ja foi convidada por outra guild.")
end
else
doPlayerSendTextMessage(_challengerID, MESSAGE_STATUS_CONSOLE_BLUE, "Esta guild e invalida.")
end
else
doPlayerSendTextMessage(_challengerID, MESSAGE_STATUS_CONSOLE_BLUE, "Voce nao e lider de guild.")
end
return true
end

function CityWar.accept(_challengedID)
if getPlayerGuildLevel(_challengerID) >= 3 then
for _, war in pairs(CityWar_WarsRunning) do
if war.challengedGuildID == getPlayerGuildId(_challengedID) then
if doPlayerRemoveMoney(_challengedID, war.price) then
war:start()
doPlayerSendTextMessage(_challengedID, MESSAGE_STATUS_CONSOLE_BLUE, "Voce aceitou o convite da guild " .. war.challengerGuildName)
return true
else
doPlayerSendTextMessage(_challengedID, MESSAGE_STATUS_CONSOLE_BLUE, "Voce nao tem dinheiro suficiente.")
return true
end
end
end
doPlayerSendTextMessage(_challengedID, MESSAGE_STATUS_CONSOLE_BLUE, "Sua guild nao foi convidada para nenhuma war")
return true
end
doPlayerSendTextMessage(_challengerID, MESSAGE_STATUS_CONSOLE_BLUE, "Voce nao e lider de guild.")
end

function CityWar.stop(_leaderGuild)
for _, war in pairs(CityWar_WarsRunning) do
if getPlayerGuildLevel(_leaderGuild) >= 3 and getPlayerGuildId(_leaderGuild) == war.challengerGuildID or getPlayerGuildId(_leaderGuild) == war.challengedGuildID then
if war.accepted then
if not war.stopped then
war.stopped = true
war.countTime = 10
war:broadcast(22, "[City War] A War entre " .. war.challengerGuildName .. " e " .. war.challengedGuildName .. " foi cancelada! em " .. war.countTime .. " minutos a war vai se encerrar.", true)
doPlayerSendTextMessage(_leaderGuild, MESSAGE_STATUS_CONSOLE_BLUE, "Voce acaba de cancelar a war da sua guild.")
return true
else
doPlayerSendTextMessage(_leaderGuild, MESSAGE_STATUS_CONSOLE_BLUE, "Ja foi requisitado o cancelamento da war da sua guild, aguarde " .. war.countTime .. " minutos.")
return true
end
else
doPlayerSendTextMessage(_leaderGuild, MESSAGE_STATUS_CONSOLE_BLUE, "A sua guild nao esta em uma war valida para ser cancelada.")
return true
end
end
end
doPlayerSendTextMessage(_leaderGuild, MESSAGE_STATUS_CONSOLE_BLUE, "Sua Guild não está em war ou voce não é o lider da sua guild.")
return true
end

function CityWar.enter(_player)
for _, war in pairs(CityWar_WarsRunning) do
if getPlayerGuildId(_player) == getGuildId(war.challengerGuildName) or getPlayerGuildId(_player) == getGuildId(war.challengedGuildName) and war.accepted then
for _, player in ipairs(war.players_in_war[getPlayerGuildId(_player)]) do
if player == _player then
doPlayerSendTextMessage(_player, MESSAGE_STATUS_CONSOLE_BLUE, "Voce ja faz parte dessa war")
return true
end
end
if #war.players_in_war[getPlayerGuildId(_player)] < war.players then
if getTilePzInfo(getThingPos(_player)) then
registerCreatureEvent(_player, "CityWar_Kill")
setPlayerStorageValue(_player, 87512, 0)
setPlayerStorageValue(_player, 87513, 0)
CityWar.setMode(_player, war.mode)
war:addPlayer(_player)
war:broadcast(22, "[CityWar] O jogador " .. getCreatureName(_player) .. " acaba de entrar na war, na guild " .. getPlayerGuildName(_player))
return true
else
doPlayerSendTextMessage(_player, MESSAGE_STATUS_CONSOLE_BLUE, "Por favor va para uma protection zone.")
return true
end
else
doPlayerSendTextMessage(_player, MESSAGE_STATUS_CONSOLE_BLUE, "O time da sua guild ja esta completo.")
return true
end
end
end
doPlayerSendTextMessage(_player, MESSAGE_STATUS_CONSOLE_BLUE, "Sua guild nao esta em nenhuma war")
return true
end

function CityWar.exit(_player, _force)
for _, war in pairs(CityWar_WarsRunning) do
if getPlayerGuildId(_player) == getGuildId(war.challengerGuildName) or getPlayerGuildId(_player) == getGuildId(war.challengedGuildName) then
for index, player in ipairs(war.players_in_war[getPlayerGuildId(_player)]) do
if player == _player then
if _force or getTilePzInfo(getCreaturePosition(_player)) then
CityWar.setMode(_player, 0)
doPlayerSendTextMessage(_player, MESSAGE_STATUS_CONSOLE_BLUE, "Voce acaba de deixar a war da sua guild.")
war:removePlayer(index, _player)
war:broadcast(22, "[CityWar] O jogador " .. getCreatureName(_player) .. " deixou a war. Ele matou " .. getPlayerStorageValue(_player, 87512) .. " e morreu " .. getPlayerStorageValue(_player, 87513))
return true
else
doPlayerSendTextMessage(_player, MESSAGE_STATUS_CONSOLE_BLUE, "Por favor va para uma protection zone.")
return true
end
end
end
doPlayerSendTextMessage(_player, MESSAGE_STATUS_CONSOLE_BLUE, "Voce nao faz parte da war.")
return true
end
end
doPlayerSendTextMessage(_player, MESSAGE_STATUS_CONSOLE_BLUE, "Este comando esta invalido.")
return true
end

function CityWar.kill(_killer, _killed)
for _, war in ipairs(CityWar_WarsRunning) do
if getPlayerGuildId(_killer) == getGuildId(war.challengerGuildName) and getPlayerGuildId(_killed) == getGuildId(war.challengedGuildName) or getPlayerGuildId(_killed) == getGuildId(war.challengerGuildName) and getPlayerGuildId(_killer) == getGuildId(war.challengedGuildName) then
war:kill(_killer, _killed)
war:broadcast(22, "[City War]\n" .. getCreatureName(_killer) .. " matou " .. getCreatureName(_killed) .. ".\nPlacar: " .. getPlayerGuildName(_killer) .. ": " .. self.guildwar_frags[getPlayerGuildId(_killer)] .. " x " .. self.guildwar_frags[getPlayerGuildId(_killed)] .. " :" .. getPlayerGuildName(_killed), false)
return true
end
end
end

function CityWar.info(_player)
local str = "Nao ha nada no momento"
local index = 0
for _, war in pairs(CityWar_WarsRunning) do
if getPlayerGuildId(_player) == war.challengerGuildID or getPlayerGuildId(_player) == war.challengedGuildID then
for _, player in ipairs(war.players_in_war[getPlayerGuildId(_player)]) do
if _player == player then
str = war.challengerGuildName .. " [" .. war.guildwar_frags[war.challengerGuildID] .. " frags] vs [" .. war.guildwar_frags[war.challengedGuildID] .. " frags] " .. war.challengedGuildName .."\n\n[" .. #war.players_in_war[war.challengerGuildID] .. "/" .. war.players .. "] jogadores na guild " .. war.challengerGuildName .. "\n"
for index, player in ipairs(war.players_in_war[war.challengerGuildID]) do
str = str .. index .. ". " .. getCreatureName(player) .. " (lv " .. getPlayerLevel(player) .. ")\n"
end
str = str .."\n[" .. #war.players_in_war[war.challengedGuildID] .. "/" .. war.players .. "] jogadores na guild " .. war.challengedGuildName .. "\n"
for index, player in ipairs(war.players_in_war[war.challengedGuildID]) do
str = str .. index .. ". " .. getCreatureName(player) .. " (lv " .. getPlayerLevel(player) .. ")\n"
end
doShowTextDialog(_player, 2160, str)
return true
end
end
end
index = index + 1
local status = war.accepted and war.stopped and "Cancelado" or war.accepted and not war.stopped and "Em andamento" or "Aguardando"
local timeLeft = war.accepted and war.countTime or war.time
str = index .. ". " .. war.challengerGuildName .. " [" .. war.guildwar_frags[war.challengerGuildID] .. " frags] vs [" .. war.guildwar_frags[war.challengedGuildID] .. " frags] " .. war.challengedGuildName .."\n"
str = str .. "Status: " .. status .. "\nCidade: " .. war.city .. "\nTempo: " .. war.time .. " minutos | " .. timeLeft .. " restantes\nJogadores: " .. war.players .. " para cada time\nJogadores na war: [" .. #war.players_in_war[war.challengerGuildID] .. "/" .. #war.players_in_war[war.challengedGuildID] .. "]\n\n"
end
doShowTextDialog(_player, 2160, str)
return true
end

function CityWar.help(_player)
local str = " =~> Bem vindo ao CityWar <~=\n\n1. Para convidar uma guild para uma war\ndigite: !citywar invite,GUILDNAME,CIDADE,MAXIMO_JOGADORES,MOOD,TEMPO\nexemplo: !citywar invite,GuildA,edron,10,2,30\n\n"
str = str .. "2. Para aceitar o convite de uma war\ndigite: !citywar accept\nobs: caso não queria aceitar o convite, aguarde 5 minutos que ele ira ser cancelado automaticamente\n\n"
str = str .. "3. Para cancelar uma war que ja esta acontecendo\ndigite: !citywar stop\n\n"
str = str .. "4. Para entrar na war da sua guild\ndigite: !citywar go\n\n"
str = str .. "5. Para sair da war em que voce esta participando\ndigite: !citywar exit\n\n"
str = str .. "6. Para ver mais informacoes dentro ou fora da war\ndigite: !citywar info"
doShowTextDialog(_player, 2160, str)
return true
end

function War:new(_challengerGuildID, _challengedGuildID, _players, _time, _mode, _city)
local war = {
challengerGuildID = _challengerGuildID,
challengedGuildID = _challengedGuildID,
challengerGuildName = getGuildName(_challengerGuildID),
challengedGuildName = getGuildName(_challengedGuildID),
players = _players,
price = CityWar_Configurations.TimePrice_Mode[_time],
time = _time,
mode = _mode,
city = _city,

-- Cache
accepted = false,
stopped = false,
guildwar_frags = {[_challengerGuildID] = 0, [_challengedGuildID] = 0},
players_in_war = {[_challengerGuildID] = {}, [_challengedGuildID] = {}}
}
doBroadcastMessage("[City War]\n" .. war.challengerGuildName .. " convidou a guild " .. war.challengedGuildName .. "\nA guerra sera na cidade de " .. war.city .. "\nSerao " .. war.players .. " jogadores para cada time. \nSerao " .. war.time .. " minutos de guerra.\nO Lider da guild tem 5 minutos para aceitar o convite.\nDigite: !citywar accept")
db.executeQuery("INSERT INTO city_war (id, GuildName_A, GuildFrags_A, GuildName_B, GuildFrags_B, War_Time, War_Map, War_Mode, War_PlayersLimit, War_Status, War_DateEnd) VALUES ('0','" .. war.challengerGuildName .. "', '0', '" .. war.challengedGuildName .. "', '0', '" .. war.time .. "', '" .. war.city .. "', '" .. war.mode .. "', '" .. war.players .. "', '1', '" .. os.time() + (war.time * 60 * 1000) .. "');")
return setmetatable(war, {__index = self}, addEvent(CityWar.checkWar, 5 * 60 * 1000, war.city))
end

function War:start()
if self.accepted then
return true
end
self.accepted = true
self.countTime = self.time
self:check()
self:broadcast(22, "[City War]\nA War entre " .. self.challengerGuildName .. " e " .. self.challengedGuildName .. " foi iniciada!\nPara entrar digite: !citywar go", true)
db.executeQuery("UPDATE city_war SET War_Status = 2 WHERE GuildName_A = " .. self.challengerGuildName .. " AND GuildName_B = " .. self.challengedGuildName)
return true
end

function War:check()
if self.countTime > 0 then
if not self.stopped then
self:broadcast(22, "[City War] Faltam " .. self.countTime .. " minutos para a war acabar.", false)
else
self:broadcast(22, "[City War] Sua war foi cancelada e faltam " .. self.countTime .. " minutos para acabar.", false)
end
end
if self.countTime <= 0 then
local status = war.stopped and "3" or "0"
self:broadcast(22, "[City War] A war entre " .. self.challengerGuildName .. " e " .. self.challengedGuildName .. " acabou!\nPlacar: " .. self.challengerGuildName .. ": " .. self.guildwar_frags[self.challengerGuildID] .. " vs " .. self.guildwar_frags[self.challengedGuildID] .. " :" .. self.challengedGuildName, true)
db.executeQuery("UPDATE city_war SET War_Status = ".. status .. " WHERE GuildName_A = " .. self.challengerGuildName .. " AND GuildName_B = " .. self.challengedGuildName)
for _, teams in pairs(self.players_in_war) do
for _, player in ipairs(teams) do
doTeleportThing(player, getPlayerMasterPos(player))
end
end
CityWar_WarsRunning[self.city] = nil
return true
end
self.countTime = self.countTime - 1
return addEvent(War.check, 60000, self)
end

function War:addPlayer(_player)
if getPlayerGuildId(_player) == self.challengerGuildID then
doTeleportThing(_player, CityWar_Configurations.Maps_Mode[self.city].teamA)
else
doTeleportThing(_player, CityWar_Configurations.Maps_Mode[self.city].teamB)
end
table.insert(self.players_in_war[getPlayerGuildId(_player)], _player)
return true
end

function War:removePlayer(_index, _player)
self.players_in_war[getPlayerGuildId(_player)][_index] = nil
doTeleportThing(_player, getPlayerMasterPos(_player))
return true
end

function War:kill(_killer, _killed)
setPlayerStorageValue(_killer, 87512, getPlayerStorageValue(_killer, 87512) + 1)
setPlayerStorageValue(_killed, 87513, getPlayerStorageValue(_killed, 87513) + 1)
self.guildwar_frags[getPlayerGuildId(_killer)] = self.guildwar_frags[getPlayerGuildId(_killer)] + 1
if getPlayerGuildId(_killed) == self.challengerGuildID then
doTeleportThing(_killed, CityWar_Configurations.Maps_Mode[self.city].teamA)
db.executeQuery("UPDATE city_war SET GuildFrags_B = " .. self.guildwar_frags[getPlayerGuildId(_killer)] .. " WHERE GuildName_A = " .. self.challengerGuildName .. " AND GuildName_B = " .. self.challengedGuildName .. " AND War_Status = 1")
else
doTeleportThing(_killed, CityWar_Configurations.Maps_Mode[self.city].teamB)
db.executeQuery("UPDATE city_war SET GuildFrags_A = " .. self.guildwar_frags[getPlayerGuildId(_killer)] .. " WHERE GuildName_A = " .. self.challengerGuildName .. " AND GuildName_B = " .. self.challengedGuildName .. " AND War_Status = 1")
end
end

function War:broadcast(_messageType, _message, _allplayers)
if _allplayers then
for _, player in ipairs(getPlayersOnline()) do
if getPlayerGuildId(player) == self.challengerGuildID or getPlayerGuildId(player) == self.challengedGuildID then
doPlayerSendTextMessage(player, _messageType, _message)
end
end
else
for _, teams in ipairs(self.players_in_war) do
for _, player in ipairs(teams) do
doPlayerSendTextMessage(player, _messageType, _message)
end
end
end
return true
end
 
Last edited:
Top