So in my case, I have the player object only.
I need the player(client) to search if the brick is within 128 horizontal units.
In essence, I want it to work kind of like the radio mod on RTB (though that's broken), where the client detects if a radio brick is within range.
So how would I use initContainerRadiusSearch to make the radio brick detect the client?
There are a number of ways to do it, I don't know which one would be more efficient.
function Player::getSpecialBrickInRange(%this, %range)
{
initContainerRadiusSearch(%this.getPosition(), %range * 0.5, $TypeMasks::fxBrickObjectType);
for(%i = containerSearchNext(); isObject(%i); %i = containerSearchNext())
{
if(%i.isSpecial)
return %i;
}
return -1;
}
This could be one way of doing it, and you run that on any player you want to test with. Modify it as needed.
The issue with this is that it may lag with larger numbers of bricks, especially with high playercounts if you're doing something like radios.
Another way could be to log every brick that you would want to search with and compare distances with the function we made before.
for(%i = 0; %i < $allSpecialBricksCt; %i++)
{
%x = $allSpecialBricks[%i].PlayerWithinRange(%player, 128);
//do stuff if %x returns true/false
}
This could potentially also be bad if you have lots of special bricks, but really it just depends.