• 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 onJoinChannel Example

chojrak

Banned User
Joined
Oct 25, 2008
Messages
5,832
Solutions
2
Reaction score
160
Hello! I've written an onJoinChannel example, script will display users list of Help Channel when you join and if your access is higher than 2.

Code:
function onJoinChannel(cid, channelId, users)
	if (channelId == CHANNEL_HELP) then
		-- Prepare locals.
		local list = {}
		local message = "[GM Info] Users on help"
		local ranks = {"Player", "Tutor", "Senior Tutor", "Game Master", "Community Manager", "GOD"}

		-- Push user names into `list` table.
		for i = 1, #users do
			local access = getPlayerAccess(users[i])
			local rank = "Unknown"
			if (ranks[access+1]) then
				rank = ranks[access+1]
			end
			list[i] = getCreatureName(users[i]) .. " [".. rank .."]"
		end

		-- Create message using `list` table.
		for i = 1, #list do
			if i == 1 then
				message = message .. " : ".. list[i] ..""
			else
				message = message .. ", ".. list[i] ..""
			end
		end

		-- Check access and send message.
		if (getPlayerAccess(cid) >= 3) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, message)
		end
	end
	return TRUE
end

creaturescripts.xml:
Code:
<event type="joinchannel" name="Help" event="script" value="help.lua"/>

Note: I don't use getGroupInfo(), cause here you can use shortcuts like "GM", "CM" etc. :>
 
Last edited:
Put this into my new server, works great! Changed it a bit but will put you into server credits.
 
Back
Top