I searched. Found several radars. None really did what I wanted.
I dug into the Redeemer nuke swep at FP. (I'm at work, can't grab the link right now, darn Websense!! Geez. Like they don't want me to slack or something inbetween other work coding.
)
Here's my version of the 'targetting' code I will hopefully use. (Oh, feel free to modify/edit/use, just credit original SWEP at FP, and tweaks I made.)
HOWEVER... I'd like help with the following....
As discussed previously, I'd like to use rectangles (or some type of sprite? I'm thinking combine ball in reasonable shape of player would be great)instead of Text.
I have no problem drawing a plain rectangle for use in a menu, its pretty static. However, players/npcs move. Am I going to have to write think code to automatically adjust the size of the rectangle? Or can the size of the rectangle be set on the players position, and then it adjust as I move closer/farther away, like the text automatically does now?
--Target code idea is from Apocolypse Mod "redeemer" SWEP from FP forums, heavily modified
targs = {}
radius = 9999
function findtargets(predid, centervec, radius)
targs = _EntitiesFindInSphere( centervec, radius )
for i = 1,table.getn(targs) do
if (string.find (_EntGetType(targs[i]),"npc_",1,true) ~= nil) or
(_EntGetType(targs[i]) == "player")
then
_GModText_Start("Default")
_GModText_SetText("\[ ]")
_GModText_SetColor(255,20,50,200)
_GModText_SetTime(9999,0.1,0.1)
_GModText_SetEntity( targs[i] )
_GModText_SetEntityOffset(vector3(0,0,32))
_GModText_Send(predid,888 + i + predid)
end
end
end
--[[
There were originally 15 or more 'if (_EntGetType(targs[i]) == "npc_BLAHBLAH") or' comparisons above.
Where BLAHBLAH was each npc individually from game.
JamminR had hoped there was an easier way.
There is. Thanks to string handling explanation http://www.lua.org/manual/5.1/manual.html#5.4
string.find (s, pattern [, init [, plain]])
JamminR hasn't timed the two different ones.
Even if not faster, at least its neater/smaller code.
]]--
function hidetargets( predid, channel )
if (allowindicators == 1) then
for i = 1,table.getn(targs) do
_GModText_Hide(predid,channel + i + predid)
end
end
end
function DoShowTargets(predid)
local targetvector = _PlayerGetShootPos(predid)
findtargets(predid, targetvector, 9999)
end
CONCOMMAND("target",DoShowTargets)
CONCOMMAND("notarget",hidetargets,888)
Edit: I just realized the rectangle can be made into any VMT material. Nice. I can work with that instead of gmod/white. Still, anyone help me with other concerns? I'm concerned width/heigth won't auto if I use _GmodRect_SetPos and SetPosOffset, anyone know? I've not ever worked with the vectors before, and am trepid about doing so