Hey guys, I'm making a possession gamemode where a person can press the light key to possess someone in their vicinity. Here's the code:
function servercmdLight(%client)
{
if(%client.isBossGhost == 1 && $gamemode $= "Possession" && %client.ghostCD < $Sim::Time)
{
%client.ghostCD = $Sim::Time + 3;
%start = %client.player.getEyePoint();
%scaled = vectorScale(%client.player.getEyeVector(), 4);
%end = vectorAdd(%start, %scaled);
%result = containerRaycast(%start, %end, $Typemasks::PlayerObjectType, %client.player);
%tPlayer = getWord(%result, 0);
if(isObject(%tPlayer))
{
%client.player.delete();
%client.setControlObject(%tPlayer);
%tPlayer.client.setControlObject(%tPlayer.client.camera);
//Exposition
%client.chatMessage("\c6You have successfully possessed" SPC %tPlayer.client.name @ "!");
%tPlayer.client.chatMessage("\c7You have been possessed by the \c6ghost\c7," SPC %client.name);
}
return;
}
parent::servercmdLight(%client);
}
The problem is that the ghost takes control fine and dandy, and can walk around. Yet, the target client can still control the tools, and can Ctrl-K the problem away. Is there any way to completely kick out the old controller, or do I have to spawn a player at the target's coordinates and painstakingly copy the avatar's appearance?
edit: if so, how could i do that?