Author Topic: Targeting all players within a certain radius  (Read 668 times)

I want to apply the whiteout affect to every player within a certain radius when an explosion goes off, but its not working.

Code: [Select]
function SLCZProjectile::onExplode(%this,%obj,%flash)
{
parent::onExplode(%this, %obj); //explode once

%this.schedule(800, "Boom", %obj, 1); //then explode again

initContainerRadiusSearch(%obj.getPosition(),10,$TypeMasks::PlayerObjectType);

for(%num=0; %num<%flash; %num++)
{
%obj.setWhiteout(0.25);
}
}
Ignore the first two lines, they're for something else

Console says "unable to find object: ' ' attempting to call function 'getPosition'", so obviously I'm using the containersearch wrong, but I don't know what about it is wrong

help would be appreciated

Move parent::onExplode to the lines below the search.

The issue is that parenting the function means that the projectile finishes it's main code (which deletes it) before your code is reached. That's why you can't call getPosition() on the projectile.

Move parent::onExplode to the lines below the search.

The issue is that parenting the function means that the projectile finishes it's main code (which deletes it) before your code is reached. That's why you can't call getPosition() on the projectile.
wait

forget

I didn't even think to consider that, damn

now it's saying "unknown command setWhiteOut" some 20 something times everytime I fire the weapon

but I know its the right function because I cross-checked it with an Add-On that uses it

am I maybe targeting the client instead of the player object? no that wouldn't make sense, so I guess it's something wrong with the containersearch after all

You are not doing anything with the container radius search anywhere. You are just initiating it.

while (%col = containerSearchNext())
{
  // do something with %col
}

wouldn't I need to use a for loop to target all players at once?

actually nevermind, I wasn't thinking about it properly

but its still saying unknown command

maybe the setwhiteout command is part of a default add-on and not main game code?
« Last Edit: April 28, 2014, 02:37:45 PM by takato14 »

Unknown command for what exactly? You should be doing %col.setWhiteOut(<value>);, not %obj.setWhiteOut(<value>);. In your code, %obj refers to the projectile.

Unknown command for what exactly? You should be doing %col.setWhiteOut(<value>);, not %obj.setWhiteOut(<value>);. In your code, %obj refers to the projectile.
*facepalm*

fixed