• 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 who is in a certain position.

Joined
Apr 17, 2008
Messages
1,922
Solutions
1
Reaction score
188
Location
Venezuela
Here is a command useful to check who is in a certain posisition (temple, depot, etc...)

...data/talkactions/scripts/SCRIPT_NAME.lua
LUA:
local positions =
{
	["temple"] = 
	{
		from = { x = 92, y = 114, z = 7 },
		to = { x = 98, y = 120, z = 7 }
	},
	["depot"] = 
	{
		from = { x = 81, y = 121, z = 7 },
		to = { x = 84, y = 128, z = 7 }
	},
	["trainers"] =
	{
		from = { x = 92, y = 138, z = 7 },
		to = { x = 96, y = 142, z = 7 }
	}
}
local t = 0
local tmp = {}

function onSay(cid, words, param, channel)

	local text = "Checking " .. param
 
	if(param == "") then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.") and true end
 
	if positions[param] then
		for _, pid in ipairs(getPlayersOnline()) do
			if isInArea(getCreaturePosition(pid), positions[param].from, positions[param].to) then
				table.insert(tmp, pid)
			end
		end
 
		text = text .. "\n" .. "Found " .. table.maxn(tmp) .. " players.\n"
		for _, pid in ipairs(tmp) do
			t = t + 1
			text = text .. "\n" .. t .. ". " .. getCreatureName(pid) .. " [Level: " .. getPlayerLevel(pid) .. "][" .. getVocationInfo(getPlayerVocation(pid)).name .. "]"
		end
		doShowTextDialog(cid, 1948, text)
	end
	return true
end

...data/talkactions/talkactions.xml
LUA:
	<talkaction log="yes" words="/check" access="4" event="script" value="SCRIPT_NAME.lua"/>

Here is an example:
2vv2elg.jpg
 
Last edited:
Sweet! Awesome! I'll try it out soon, thanks a lot!

Edit: Seems to work for me, I'll be changing how it displays the name a little, but great script! Rep++
 
Good job, altought I don't think "relocate" it's the correct word for it :p
 
Really nice one dude :D Just wonder if you can change it a little for me.

I would like my script to teleport all players in a sertain area to x x x co-ordinates.

I'll use your example:
Code:
local positions =
{
        ["jail"] =
        {
                from = { x = 92, y = 114, z = 7 },
                to = { x = 98, y = 120, z = 7 }
        },

Then I want the script to teleport the players inside that area to a special place I decide.

I've always wondered how to do something like that, and I hope you will be able to help me with it!
 
hey darkhaos this script can be used by vocations? hmm example:
Found 1 sorcerer.
Found 2 druid..
etc..

Thanks if is possible :)
 
This should work well

LUA:
local positions =
{
	["temple"] = 
	{
		from = { x = 92, y = 114, z = 7 },
		to = { x = 98, y = 120, z = 7 }
	},
	["depot"] = 
	{
		from = { x = 81, y = 121, z = 7 },
		to = { x = 84, y = 128, z = 7 }
	},
	["trainers"] =
	{
		from = { x = 92, y = 138, z = 7 },
		to = { x = 96, y = 142, z = 7 }
	}
}


function onSay(cid, words, param, channel)
 
		tmp = {}
		voc = {
				sorcerer = {},
				druid = {},
				paladin = {},
				knight = {}
			  }
	if(param == "") then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.") and true end
 
	if positions[param] then
		start = "Checking " .. param.."....."
		doPlayerSendTextMessage(cid,19,start)
		
			local function search()
					text = "Fetching "..param .." :"
					for _, pid in ipairs(getPlayersOnline()) do
						if getPlayerGroupId(pid) < 3 then
							if isInArea(getCreaturePosition(pid), positions[param].from, positions[param].to) then
								table.insert(tmp, pid)
								if isDruid(pid) then
									table.insert(voc.druid, pid)
								elseif isSorcerer(pid) then
									table.insert(voc.sorcerer, pid)
								elseif isPaladin(pid) then
									table.insert(voc.paladin, pid)
								elseif isKnight(pid) then
									table.insert(voc.knight, pid)
								end
							end
						end
					end
					if #tmp <= 0 then 
						text = text .. "\n      ¤ " .. "Found " .. #tmp .. " players.\n"
					else
							text = text .. "\n\n  ¤ " .. "Found " .. #tmp .. " players : \n     • Sorcerer :              "..#voc.sorcerer.."  player"..(#voc.sorcerer > 1 and "s." or ".").." \n     • Druid :              "..#voc.druid.."  player"..(#voc.druid > 1 and "s." or ".").." \n     • Paladin :              "..#voc.paladin.."  player"..(#voc.paladin > 1 and "s." or ".").."\n     • Knight :              "..#voc.knight.."  player"..(#voc.knight > 1 and "s." or ".")..""
					end
					doShowTextDialog(cid, 1949, text)
				end
 
		addEvent(search,2*1000)
	end
	return true
end
 
Back
Top