• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Check the war enemies online 1.0

Jetro

jangeldev
Joined
Aug 1, 2011
Messages
452
Reaction score
68
Location
Venezuela
This script basically shows all your enemies online, of course, it shows their name, level and voc, of course, supports multiwar, here is the script:



Update log
Code:
 [B]v1.0 Rev: 3:[/B]
	[B]Rev: 2 - [12 / 01 / 2012][/B]
		Better format in tables and algoritms.
		Show all players who are in war with you in a cool format, of course with multiwar support.
	[B]Rev: 3 - [15 / 01 / 2012][/B]
		Fixed a critical bug.

Lua:
local shield = 2511
function onSay(cid, words, param, channel)
	local guild = getPlayerGuildId(cid)
	local guilds = {}
	tmp = -1
	if guild > 0 then 
	
		 tmp = db.getResult("SELECT `guild_id`,  `enemy_id` FROM `guild_wars` WHERE `status` = 1 AND (`guild_id` = "..guild.. " OR  `enemy_id` = "..guild..")  ;")  
		
	else
		doPlayerSendCancel(cid, "You are not in a guild.")
		return true
	end
	warString = ""

	if tmp:getID() ~= -1 then 
			i = 1
	
	
			repeat
	
				if tmp:getDataInt("guild_id") == guild   then
					enemy = tmp:getDataInt("enemy_id")
				else
					enemy = tmp:getDataInt("guild_id")
				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
		
				guilds[i] = {}
				guilds[i].name = enemyName
				guilds[i].id = enemy
	

 
				i = i + 1
			until not(tmp:next())
			tmp:free()
	else
		doPlayerSendCancel(cid, "Your guild is not in war now.")
		return true
	end
		

	enemies = {}
	for i,x in pairs (guilds) do 
	
		enemies[x.name] = {}
		for _, pid in pairs(getPlayersOnline()) do
			if (getPlayerGuildId(pid) == x.id) then
				table.insert(enemies[x.name], getPlayerName(pid) .." ["..getPlayerLevel(pid).."]" .." ["..getPlayerVocationName(pid) .."]" )
			end
		end
			
	
	end
	
	str = "Guilds: \n"
	for v,w in pairs(enemies) do 
		str = str.. "•"..v.."("..#w.."): "..table.concat(w, "\n").."\n" 
	end
	doShowTextDialog(cid, shield, str)


	return true
end

XML:
<talkaction words="!warmembers"  event="script" value="nameofyourscript.lua"/>


Vqj2z.png
 
Last edited:
Known bug: it will show just the max characters of a normal message... Example:

Code:
21:40 Guilds: 
•Zona North(0): 
•Divine Rush(0): 
•Untouchables(18): Alahm Elehhm [217] [Elder Druid],Wingates [165] [Elder
Druid],Mataperquin [168] [Elder Druid],Fluttershy [216] [Elder Druid],Ft
Revolution [209] [Elder Druid],Sheisfter Wisks [170] [Elder Druid],Zfust ekk [218]
[Elite Knight],Cantos [184] [Elder Druid],Comotuquieras [138] [Elite Knight],Volxis
[252] [Elder Druid],Rudboy [211] [Elder Druid],Chichita [189] [Elder
Druid],Franquitius [210] [Elder Druid],Lordemans [189] [Elder Druid],Jeas [217] [Eli

Solution:
• Print Guild Name (number):
Print Sorcerers (number):
Print 10 names and levels.
Print 10 names and levels.
etc....
Print Druids (number):
Print 10 names and levels.
Print 10 names and levels.
etc...
...
...
• Print Guild Name (number):
etc..
etc...
...
...
 

Similar threads

Back
Top