Issue 106: Pointable commands, like ULX (^ and @)
Status:  Done
Owner: ----
Closed:  Sep 2010
Reported by roelofhy...@gmail.com, Jun 16, 2010
Hey,

I recoded one function in ev_framework.lua

It makes you able to use ^ (target yourself) and @ (target the player you are looking at).

Paste the following code over the old function evolve:FindPlayers (with revision 114 that is line 216 - 236.

TortoiseSVN will show the file in red... but maybe overv installs it in the svn.

function evolve:FindPlayer( name, def, nonum )
	local matches = {}
	
	if ( !name or #name == 0 ) then
		matches[1] = def
	elseif ( (name[1]=="^" and #name==1) or name=="^" ) then
		matches[1] = def
	elseif ( (name[1]=="@" and #name==1) or name=="@" ) then
		local foundCloseby = ents.FindInSphere( def:GetShootPos( ), 16 )
		for _,thingies in pairs(foundCloseby) do
			if(thingies:IsValid() and thingies:IsPlayer()) then
				table.insert(matches,thingies)
			end
		end
	else
		if ( type( name ) != "table" ) then name = { name } end
		local name2 = table.Copy( name )
		if ( nonum ) then
			if ( #name2 > 1 and tonumber( name2[ #name2 ] ) ) then table.remove( name2, #name2 ) end
		end
		
		for _, ply in ipairs( player.GetAll() ) do
			for _, pm in ipairs( name2 ) do
				if ( evolve:IsNameMatch( ply, pm ) and !table.HasValue( matches, ply ) ) then table.insert( matches, ply ) end
			end
		end
	end
	
	return matches
end

Enjoy,
Roelof
Sep 6, 2010
Project Member #1 overv161@gmail.com
^ is pretty useless, but I'll think about @.
Status: Done