Author Topic: Player Group  (Read 531 times)

PlayerGroup, like client group but for players.
This wont work, nothing happens, and on use, it crashes.
Code: [Select]
if(!isObject(PlayerGroup))
new ScriptGroup(PlayerGroup);
package PlayerGroup_Beta
{
function GameConnection::createPlayer(%client)
{
parent::createPlayer(%client);
PlayerGroup.add(%client.player);
}
function PLayer::playThread(%this,%slot,%thread)
{
parent::playThread(%this,%slot,%thread);
if(%thread $= "Death")
PlayerGroup.remove(%this);
}
function Player::delete(%this)
{
for(%i=0;%i<PlayerGroup.getCount();%i++)
{
if(PlayerGroup.getObject(%i) $= %this && PlayerGroup.getState() !$= "Dead")
PlayerGroup.remove(%this);
}
parent::delete(%this);
}
};activatepackage(PlayerGroup_Beta);

This should do the trick:

Code: [Select]
if(!isObject(playerGroup))
new simSet(playerGroup);

package PlayerGroup
{
function Player::onAdd(%this)
{
parent::onAdd(%this);
playerGroup.schedule(0,add,%this);
}
};
activatePackage(PlayerGroup);

This should do the trick:

Code: [Select]
if(!isObject(playerGroup))
new simSet(playerGroup);

package PlayerGroup
{
function Player::onAdd(%this)
{
parent::onAdd(%this);
playerGroup.schedule(0,add,%this);
}
};
activatePackage(PlayerGroup);
I fixed it myself with a bit of stuff.