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

Lua Private war system issue

Axelor

Member
Joined
Sep 2, 2010
Messages
505
Reaction score
9
Hello,

I have baught private war system from a guy. I have some errors on the console someone can help me?
I will pay if needed.
This is the error when trying to invite a guild to citywar:
PHP:
[17:39:29.622] [Error - TalkAction Interface]
[17:39:29.622] data/talkactions/scripts/citywar.lua:onSay
[17:39:29.622] Description:
[17:39:29.622] data/lib/050-function.lua:38: bad argument #1 to 'pairs' (table expected, got nil)
[17:39:29.622] stack traceback:
[17:39:29.622]  [C]: in function 'pairs'
[17:39:29.622]  data/lib/050-function.lua:38: in function 'isGuildAntiEntrosa'
[17:39:29.622]  data/talkactions/scripts/citywar.lua:17: in function 'cityWarInvite'
[17:39:29.622]  data/talkactions/scripts/citywar.lua:163: in function <data/talkactions/scripts/citywar.lua:140>

This is 050-function.lua line 38:
Lua:
WAR_TYPE_STORAGE = 210414

function isGuildLeader(cid)
	return getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER
end

function isInAnyArray(array, value)
	if not type(array) == 'table' then
		return false
	end
	for k, v in pairs(array) do
		if type(v) == 'table' then
			ret = isInAnyArray(v, value)
			if ret ~= false then
				return true, k
			end
		else
			if v == value then
				return true, k
			end
		end
	end
	return false
end

function setPlayerWarType(cid, value)
	return doCreatureSetStorage(cid, WAR_TYPE_STORAGE, value)
end

function getPlayerWarType(cid)
	return getCreatureStorage(cid, WAR_TYPE_STORAGE)
end

function isGuildAntiEntrosa(guildId)
if not type(guildId) == 'number' then
	return false
end
	for _, v in pairs(Wars) do
		if type(v) == "table" then
			if v:isGuildOnWar(guildId) then
				return true
			end
		end
	end
	return false
end

This is citywar.lua:
Lua:
-- Criado por Samuel Bertanha
-- Não disponibilizar esse script a ninguem
-- Criado dia 27/07/2017
-- Servidores Tibia
-- /citywar invite, guild, cidade, numero, modo, tempo
local function cityWarInvite(cid, param)

local guildId = getGuildId(param[2])
	if guildId == false then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid guild name.")
		return false
	end
	if guildId == getPlayerGuildId(cid) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid guild invite.")
		return false	
	end
	if isGuildAntiEntrosa(guildId) or isGuildAntiEntrosa(getPlayerGuildId(cid)) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Guild already on war.")
		return false		
	end
local nomeB = param[2]
	
	--if not cityWarExtraRequirements(cid, guildId) then
		--return false
	--end	
local ret, instance = isInAnyArray(War.cidade_string, param[3])
	if ret then		
		instanceid = Instance:getFree(instance)
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid city name.")
		return false
	end
	
local numero = 0
	if tonumber(param[4]) and isInAnyArray(War.numero, tonumber(param[4])) then
		numero = tonumber(param[4])
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid number of players.")
		return false
	end
	
local ret, modo = isInAnyArray(War.modo_string, param[5])
	if not ret then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid type name.")
		return false
	end

local preco, tempo = 0, 0
	if tonumber(param[6]) then
		tempo = tonumber(param[6])
		ret, preco = isInAnyArray(War.tempo, tonumber(param[6]))
		if not ret then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid duration time.")
			return false
		end
		if not doPlayerWithdrawMoney(cid, War.preco[preco]) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Not enough money.")
			return false			
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid duration time.")
		return false
	end		

local config = {
	desafiante = cid,
	nomeA = getPlayerGuildName(cid),
	nomeB = nomeB,
	tempo = tempo,
	valor = War.preco[preco],
	modo = modo,
	numero = numero,
	cidade = instance,
	instanceid = instanceid,
	guildA = getPlayerGuildId(cid),
	guildB = guildId
}

	Wars(config)
end

-- /citywar accept, guild
local function cityWarAccept(cid, param)
local selfGuild = getPlayerGuildId(cid)
local invitingGuild = getGuildId(param[2])
	if selfGuild == invitingGuild then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot accept your own request.")
		return
	end
	for _, v in pairs(Wars) do
		if type(v) == 'table' then
			if v:isGuildOnWar(invitingGuild) and v:isGuildOnWar(selfGuild) then
				if doPlayerWithdrawMoney(cid, v.valor) then
					v:start()
				else
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Not enough money.")
				end
			end
		end
	end
end

-- /citywar go
local function cityWarGo(cid)
selfGuild = getPlayerGuildId(cid)
	for _, v in pairs(Wars) do
		if not v == false then
			if v:isGuildOnWar(selfGuild) then
				if getTileInfo(getThingPosition(cid)).protection == false then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Please go to a protection zone.")
					return true
				end
				return v:newPlayer(cid)
			end
		end
	end
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your guild is not in a war.")
	return true
end

-- /citywar exit
local function cityWarExit(cid)
	if getPlayerWarType(cid) <= 0 then
		return false
	end
	selfGuild = getPlayerGuildId(cid)
	for _, v in pairs(Wars) do
		if type(v) == 'table' then
			if v:isGuildOnWar(selfGuild) then
				if getTileInfo(getThingPosition(cid)).protection == false then
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Please go to a protection zone.")
					return true
				end
				v:removePlayer(cid)
			end
		end
	end
end

function onSay(cid, words, param, channel)
	if(param == '') then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command param required.")
		return true
	end	

	local t = string.explode(param, ",")
	local ret = RETURNVALUE_NOERROR

	local comando = t[1]
	if comando == "accept" then
		if isGuildLeader(cid) then
			if getPlayerWarType(cid) < 1 then
				cityWarAccept(cid, t)
			else
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are already in a war.")	
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are not a guild leader.")			
		end
	elseif comando == "invite" then
		if isGuildLeader(cid) then
			if getPlayerWarType(cid) < 1 then
				cityWarInvite(cid, t)
			else
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are already in a war.")	
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are not a guild leader.")			
		end
	elseif comando == "go" then
		if not cityWarGo(cid) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player number limit reached.")			
		end
	elseif comando == "exit" then
		if not cityWarExit(cid) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are not in war.")
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid command param.")
	end
	return true
end

I hope someone can help me
 
Last edited by a moderator:
Wars is most likely not global, thats why 050-function can't see it since it's local to citywar.lua.
 
Hello,

I baught a private city war system and somehow when I change positions of spawning for team 1 and team 2 the system gives weird errors on console. Example at this lines. (Explanation is also in the script) But I don't understand how to configure the positions. If I use different position on the first one. At the edron one. It gives me this error:
PHP:
[17:4:10.879] [Error - TalkAction Interface]
[17:4:10.879] data/talkactions/scripts/citywar.lua:onSay
[17:4:10.879] Description:
[17:4:10.879] data/lib/050-function.lua:38: bad argument #1 to 'pairs' (table expected, got nil)
[17:4:10.879] stack traceback:
[17:4:10.879]   [C]: in function 'pairs'
[17:4:10.879]   data/lib/050-function.lua:38: in function 'isGuildAntiEntrosa'
[17:4:10.879]   data/talkactions/scripts/citywar.lua:17: in function 'cityWarInvite'
[17:4:10.879]   data/talkactions/scripts/citywar.lua:163: in function <data/talkactions/scripts/citywar.lua:140>

This is the code :

PHP:
- [[
you can put as many maps as you want from the same city
in the map table, each array vector is composed of the Position of Time A and B

example:
[0] = {{posA, posB}, {posA2, posB2}, {posA3, posA4}} - here you have 3 maps configured for Edron

posA = city location where A guild players will be teleported
posB = place for the guild B

you are free to choose what and how many copies of the city

watch! the value of the string and the position must be the same!
]]
]]
   
   cidade_string = {
                         [0] = {'edron', "Edron", 'EDRON'},
                     [1] = {'dara', 'darashia', 'Darashia', 'DARASHIA'},
                         [2] = {'desert', 'deserte', 'DESERT'},
                         [3] = {'carlin', 'Carlin', 'CARLIN'},
                         [4] = {'cormaya', 'Cormaya', 'CORMAYA'},
                         [5] = {'ank', 'ankrahmun', 'Ankrahmun', 'ANKRAHMUN'},
                         [6] = {'yalahar', 'Yalahar', 'YALAHAR'},
                         [7] = {'venore', 'Venore', 'VENORE'}   
   },
   mapas = {   
                         [0] = {   {   {x=32366,y=32213,z=7},{x=32371,y=32216,z=7}       }       },       -- exemplo de apenas um mapa Edron configurado
                         [1] = {   {   {x=31316,y=32641,z=7},{x=31258,y=32717,z=8}       }       },
                         [2] = {   {   {x=31273,y=32338,z=7},{x=31268,y=32160,z=7}       }       },
                         [3] = {   {   {x=31680,y=32797,z=7},{x=31789,y=32793,z=7}       }       },
                         [4] = {   {   {x = 32366, y = 32217, z =  7}, {x = 32371, y = 32212, z = 7}       }       },
                         [5] = {},
                         [6] = {},
                         [7] = {}   
   },
}
 
if you bought it you should go to the person who made it
why should we be responsible for something you paid for
 
Back
Top