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

[request] Guild broadcast

Serginov

Onkonkoronkonk
Joined
Jun 28, 2008
Messages
1,321
Reaction score
18
Location
Sweden - Dalarna
Hello

I need a script for a talkaction on my server
This will just work for the guild leader and vice leaders!


!guild "Hello <-- Will broadcast a message to everyone in the guild in red.

When a leader broadcast it will say (leader) after the name and when a vice leader broadcast it will say (vice-leader) after the name.
Example,
00:00 Terry(leader)[123]: Hello
00:00 Bobby(vice-leader) [99]: Hello
and if the leader/vice leader title is changed,
example,
00:00 Terry(Psycho) [123]: Hello
00:00 Bobby(Ninja) [99]: Hello


Thanks in Advance!
 
Code:
local config = {
	rankToBroadcast = GUILDLEVEL_VICE,
	broadcastType = MESSAGE_STATUS_CONSOLE_BLUE
}

function onSay(cid, words, param)
	local rank = ""
	if getPlayerGuildId(cid) ~= FALSE then
		if param ~= nil then
			if getPlayerGuildLevel(cid) >= config.rankToBroadcast then
				if getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER then rank = "leader"
				else rank = "vice-leader" end
				
				for _, pl in pairs(getOnlinePlayers()) do
					if getPlayerGuildId(pl) == getPlayerGuildId(cid) then
						doPlayerSendTextMessage(pl, config.broadcastType, getCreatureName(cid).." ["..getPlayerLevel(cid).."] ("..rank.."): "..param)
					end
				end
			else
				doPlayerSendCancel(cid, "You rank is too low.")
			end
		else
			doPlayerSendCancel(cid, "You have to type a message.")
		end
	else
		doPlayerSendCancel(cid, "You do not have a guild.")
	end
	return FALSE
end

try
 
Code:
local config = {
	rankToBroadcast = GUILDLEVEL_VICE,
	broadcastType = MESSAGE_STATUS_CONSOLE_BLUE
}

function onSay(cid, words, param)
	local rank = ""
	if getPlayerGuildId(cid) ~= FALSE then
		if param ~= nil then
			if getPlayerGuildLevel(cid) >= config.rankToBroadcast then
				if getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER then rank = "leader"
				else rank = "vice-leader" end
				
				for _, pl in pairs(getOnlinePlayers()) do
					if getPlayerGuildId(pl) == getPlayerGuildId(cid) then
						doPlayerSendTextMessage(pl, config.broadcastType, getCreatureName(cid).." ["..getPlayerLevel(cid).."] ("..rank.."): "..param)
					end
				end
			else
				doPlayerSendCancel(cid, "You rank is too low.")
			end
		else
			doPlayerSendCancel(cid, "You have to type a message.")
		end
	else
		doPlayerSendCancel(cid, "You do not have a guild.")
	end
	return FALSE
end

try

if getPlayerGuildId(pl)


What does PL mean .. ? XD
 
Code:
local config = {
	rankToBroadcast = GUILDLEVEL_VICE,
	broadcastType = MESSAGE_STATUS_CONSOLE_BLUE
}

function onSay(cid, words, param)
	local rank = ""
	if getPlayerGuildId(cid) ~= FALSE then
		if param ~= nil then
			if getPlayerGuildLevel(cid) >= config.rankToBroadcast then
				if getPlayerGuildLevel(cid) == GUILDLEVEL_LEADER then rank = "leader"
				else rank = "vice-leader" end
				
				for _, pl in pairs(getOnlinePlayers()) do
					if getPlayerGuildId(pl) == getPlayerGuildId(cid) then
						doPlayerSendTextMessage(pl, config.broadcastType, getCreatureName(cid).." ["..getPlayerLevel(cid).."] ("..rank.."): "..param)
					end
				end
			else
				doPlayerSendCancel(cid, "You rank is too low.")
			end
		else
			doPlayerSendCancel(cid, "You have to type a message.")
		end
	else
		doPlayerSendCancel(cid, "You do not have a guild.")
	end
	return FALSE
end

try

We all know you are pl! You don't need to highlight it by using variables named 'pl' :S What's next, br?

@Jesper
It's short for player :p
 
Code:
function onSay(cid, words, param)
	local playerGuild = getPlayerGuildId(cid)
	if playerGuild > 0 then
		local playerGuildLevel = getPlayerGuildLevel(cid)
		if playerGuildLevel >= GUILDLEVEL_VICE then
			local players = getOnlinePlayers()
			local message = "*Guild* " .. getCreatureName(cid) .. " [" .. getPlayerLevel(cid) .. "]:\n" .. param;
			for i,playerName in ipairs(players) do
				local player = getPlayerByName(playerName);
				if getPlayerGuildId(player) == playerGuild then
					doPlayerSendTextMessage(player, MESSAGE_STATUS_WARNING, message);
				end
			end
			doPlayerSendCancel(cid, "Message sent to whole guild.");
		else
			doPlayerSendCancel(cid, "You have to be at least Vice-Leader to guildcast!");
		end
	else
		doPlayerSendCancel(cid, "Sorry, you're not in a guild.");
	end
	doPlayerSendTextMessage(cid, 25, words)
	return FALSE
end

rep++?
 
Back
Top