Author Topic: SetNodeColor client sided?  (Read 614 times)

I was asked by a friend to post this.  He has no forum account.

Quote
Ok, so how do you make it so when you fire a weapon and all the bots and other clients turn red and only you can see the people as red and everyone else sees them  as normal then when you unequip the item the red people turn back to normal color they were before you equiped the item.

He basically wants to know if he can make people turn all one color, but only in the view of the person with the item.  Any ideas?

Getting them red would work just fine.
Getting them back isn't possible.

Getting them red would work just fine.
Getting them back isn't possible.
Hm.  So you can make the players look red client sided, but you can't put them back.  Interesting.  How would one go about making them red in the first place?

Depending on the number of bricks/objects in the server this can get very laggy.

Code: [Select]
%c = serverConnection.getCount();
for(%i = 0; %i < %c; %i++)
{
   if((%o = serverConnection.getObject(%i)).getType() & $Typemasks::PlayerObjectType)
   {
      %o.setNodeColor("ALL","1 0 0 1");
   }
}

Depending on the number of bricks/objects in the server this can get very laggy.

Code: [Select]
%c = serverConnection.getCount();
for(%i = 0; %i < %c; %i++)
{
   if((%o = serverConnection.getObject(%i)).getType() & $Typemasks::PlayerObjectType)
   {
      %o.setNodeColor("ALL","1 0 0 1");
   }
}
To reduce noticeable lag for the user, you could scan on connection to the server and then scan at intervals only on new objects.

This would be done some way like this:
Code: [Select]
$changeColorMod::PlayerCount=0;
package colorchange {
function serverConnection::onConnected(%this) {
parent::onConnected(%this);
schedule(500,0,scanForPlayers,0);
}
};
function scanForPlayers(%i)
{
for(%s=%i;%s<serverConnection.getCount();%s++)
{
if(serverConnection.getObject(%s).getType()$="Player")
{
$changeColorMod::Player[$changeColorMod::PlayerCount]=serverConnection.getObject(%s);
$changeColorMod::PlayerCount++;
}
}
%i=%s;
schedule(60000,0,scanForPlayers,%i);
}