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

CreatureEvent [War System] Who are your enemies onLogin

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,858
Reaction score
96
Location
Brazil
Working 100%
Script made by Jetro. All credits to him.

Screen:
upd3.jpg

Lua:
local guild, enemy, guildFrags, enemyFrags = getPlayerGuildId(cid)
local fightingGuilds = {}
local tmp = db.getResult("SELECT `guild_id`,  `enemy_id`, `guild_kills`, `enemy_kills`, `frags` FROM `guild_wars` WHERE `status` = 1 and (`guild_id` = "..getPlayerGuildId(cid).." or  `enemy_id` = "..getPlayerGuildId(cid).. ")  ;")
warString = ""
if tmp:getID() ~= -1 then
	i = 1
	
	repeat
	
		if tmp:getDataInt("guild_id") == guild   then
			enemy = tmp:getDataInt("enemy_id")
			guildFrags = tmp:getDataInt("guild_kills")
			enemyFrags = tmp:getDataInt("enemy_kills")
		else
			enemy = tmp:getDataInt("guild_id")
			guildFrags = tmp:getDataInt("enemy_kills")
			enemyFrags = tmp:getDataInt("guild_kills")
		end
		local enemyName, _tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
		if(_tmp:getID() ~= -1) then
			enemyName = _tmp:getDataString("name")
			_tmp:free()
 
		end
	
		fightingGuilds[i] = {}
		fightingGuilds[i].name = enemyName
		fightingGuilds[i].guildFrags = guildFrags
		fightingGuilds[i].enemyFrags = enemyFrags
		fightingGuilds[i].limit = tmp:getDataInt("frags")
 
		i = i + 1
	until not(tmp:next())
	tmp:free()
 
	table.sort(fightingGuilds, function (a, b)
		return (a.name < b.name)
	end)
 
		
	
	for k, v in pairs(fightingGuilds) do

		if (v.guildFrags  < v.limit and v.enemyFrags < v.limit  ) then
			if (warString == "") then
				warString = "Your guild is currently in war with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags .. " frags, limit ".. v.limit ..")"
			else
				warString = warString .. " and with the " .. v.name .. " (" .. v.guildFrags .. ":" .. v.enemyFrags.." frags, limit ".. v.limit .. ")"
			end
		end
	end

end

if (warString ~= "") then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, warString .. ".")
end

You just have to add in login.lua
 
Last edited:
I do not work. There is no error in the console. As calling war, then accept it and re-login nothing is displayed.
 
I have 3841. He can be out of order because it is an older version, whether rather no?
 
I compiled 3884, I launched, I did guilds anew, I called the strike, re-login oneself and farther nothing. I added it to data\creaturescripts\scripts\login.lua. I am using this script:

http://otland.net/f132/onlogn-war-points-127353/index4.html

Lua:
local guild, enemy, guildFrags, enemyFrags = getPlayerGuildId(cid)
local tmp = db.getResult("SELECT `guild_id`, `enemy_id`, `guild_kills`, `enemy_kills`, `frags` FROM `guild_wars` WHERE `guild_id` = "..guild.." OR `enemy_id` = "..guild.." AND `status` = 1;")
if tmp:getID() ~= -1 then
	local msg
	repeat
		if tmp:getDataInt("guild_id") == guild then
			enemy = tmp:getDataInt("enemy_id")
			guildFrags = tmp:getDataInt("guild_kills")
			enemyFrags = tmp:getDataInt("enemy_kills")
		else
			enemy = tmp:getDataInt("guild_id")
			guildFrags = tmp:getDataInt("enemy_kills")
			enemyFrags = tmp:getDataInt("guild_kills")
		end
		local enemyName, _tmp = "", db.getResult("SELECT `name` FROM `guilds` WHERE `id` = " .. enemy)
		if(_tmp:getID() ~= -1) then
			enemyName = _tmp:getDataString("name")
			_tmp:free()
		end
		if not msg then
			msg = "Your guild is currently in war with the ".. enemyName.." ("..guildFrags..":"..enemyFrags.." frags, limit "..tmp:getDataInt("frags")..")"
		else
			msg = msg.. " and " . enemyName.." ("..guildFrags..":"..enemyFrags.." frags, limit "..tmp:getDataInt("frags")..")"
		end
	until not tmp:next()
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg..".")
	tmp:free()
end
 
Error:
Code:
[3:23:48.960] [Error - CreatureScript Interface]
[3:23:48.960] data/creaturescripts/scripts/login.lua
[3:23:48.960] Description:
[3:23:48.960] (internalGetPlayerInfo) Player not found when requesting player info #11

[3:23:48.960] [Error - CreatureScript Interface]
[3:23:48.960] data/creaturescripts/scripts/login.lua
[3:23:48.960] Description:
[3:23:48.960] data/creaturescripts/scripts/login.lua:3: attempt to concatenate local 'guild' (a boolean value)
[3:23:48.960] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/login.lua)
 
Error:
Code:
[3:23:48.960] [Error - CreatureScript Interface]
[3:23:48.960] data/creaturescripts/scripts/login.lua
[3:23:48.960] Description:
[3:23:48.960] (internalGetPlayerInfo) Player not found when requesting player info #11

[3:23:48.960] [Error - CreatureScript Interface]
[3:23:48.960] data/creaturescripts/scripts/login.lua
[3:23:48.960] Description:
[3:23:48.960] data/creaturescripts/scripts/login.lua:3: attempt to concatenate local 'guild' (a boolean value)
[3:23:48.960] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/login.lua)

same
 
Code:
local tmp = db.getResult("SELECT `guild_id`, `enemy_id`, `guild_kills`, `enemy_kills`, `frags` FROM `guild_wars` WHERE `guild_id` = "..guild.." OR `enemy_id` = "..guild.." AND `status` = 1;")

Why execute a query before the script even runs? Change it so that the mysql query runs only when it is needed.
 
MMm when the war ended and .. the page says end .. as I finish the war ..
but every time I go online it tells me
how I can fix that?

15:19 Your guild is currently in war with the PIpo team (4:10 frags, limit 10).
 
Error:
Code:
[3:23:48.960] [Error - CreatureScript Interface]
[3:23:48.960] data/creaturescripts/scripts/login.lua
[3:23:48.960] Description:
[3:23:48.960] (internalGetPlayerInfo) Player not found when requesting player info #11

[3:23:48.960] [Error - CreatureScript Interface]
[3:23:48.960] data/creaturescripts/scripts/login.lua
[3:23:48.960] Description:
[3:23:48.960] data/creaturescripts/scripts/login.lua:3: attempt to concatenate local 'guild' (a boolean value)
[3:23:48.960] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/login.lua)

i got same error
 
Not fail...just do not know how to put it in the right place ..
could also post your login .. and adds another ...

Topic: you know how to solve the problem I told you?


MMm when the war ended and .. the page says end .. as I finish the war ..
but every time I go online it tells me
how I can fix that?

15:19 Your guild is currently in war with the PIpo team (4:10 frags, limit 10).
 
Back
Top