Author Topic: Changing shapename not working.  (Read 2066 times)

Code: [Select]
function GameConnection::SpawnPlayer(%this){
parent::SpawnPlayer(%this);
if($TerroristMini){
if(%this.side $= "Terrorist" || %this.side $= "Chief Terrorist" || %this.side $= "Head Terrorist"){
commandtoclient(%this,'CenterPrint',"\c6You're a \c0Terrorist\c6.",3,3,5000);
%this.player.setTransform(vectorAdd($terroristSpawn,"0 0 1"));
%this.player.setShapeName(%this.name @ "[ Terrorist ]");
} else if(%this.side $= "SWAT"){
commandtoclient(%this,'CenterPrint',"\c6You're in the \c0SWAT\c6.",3,3,5000);
%this.player.setTransform(vectorAdd($SWATSpawn,"0 0 1"));
%this.player.setShapeName(%this.name @ "[ SWAT ]");
}
}
}

It is in a package.

Also, is there a way to make a trigger like center at a certain point.
« Last Edit: October 14, 2007, 07:02:26 AM by MrPickle »

Are you sure you activated the package?

%trigger.setTransform(vectorSub(%trigger.getTransform(),vectorScale(%trigger.scale,0.5)));

^^ Subtract half of the scale to 'center' it on a point. (Set transform to XYZ point, set scale, then use code)

Yeah package is activate because I can activate the minigame which is in the package.

Ok, The shapenames was a conflicting script, Thanks Space.

[Edit] - and that isn't working Space.

Code: [Select]
%trigger = new Trigger(){
datablock = terroristBase;
position = vectorAdd($terroristSpawn,"0 0 -2");
polyhedron = "0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 0.0000000 1.0000000";
};
%trigger.setScale("10 10 5");
%trigger.setTransform(vectorSub(%trigger.getTransform(),vectorScale(%trigger.scale,0.5)));

[Edit2] - Picture

[Edit3] - The triggers are ment to be at centered on the spawns to the left.
« Last Edit: October 16, 2007, 11:49:11 AM by MrPickle »

For the following, it is assumed that the spawn brick is assigned to some variable (e.g. %spawnbrick).

Code: [Select]
%trigger.setTransform(vectorAdd(%spawnbrick.getTransform(),"0 0 0.1"));

Also, this is making the client spawn as close to 0 0 0 as possible if the terrorist mini isn't on and I don't know why.

Code: [Select]
function GameConnection::SpawnPlayer(%this){
parent::SpawnPlayer(%this);
if($TerroristMini){
if(%this.side $= "Terrorist" || %this.side $= "Chief Terrorist" || %this.side $= "Head Terrorist"){
commandtoclient(%this,'CenterPrint',"\c6You're a \c0Terrorist\c6.",3,3,5000);
%this.player.setTransform(vectorAdd($terroristSpawn,"0 0 1"));
%this.player.setShapeName(%this.name @ "[ Terrorist ]");
} else if(%this.side $= "SWAT"){
commandtoclient(%this,'CenterPrint',"\c6You're in the \c0SWAT\c6.",3,3,5000);
%this.player.setTransform(vectorAdd($SWATSpawn,"0 0 1"));
%this.player.setShapeName(%this.name @ "[ SWAT ]");
}
}
}

Oops I forgot.  Triggers aren't positioned like normal objects.  The corner of the trigger is positioned by the .setTransform().  You'll need to make an adjustment for that.  Something like this:
Code: [Select]
%width = getWord(%trigger.getWorldBox(),3) - getWord(%trigger.getWorldBox(),0);
%length = getWord(%trigger.getWorldBox(),4) - getWord(%trigger.getWorldBox(),1);
%trigger.setTransform(vectorAdd($SWATSpawn.getTransform(),%width / -2 SPC %length / -2 SPC 0.1));

I'm assuming that $TerroristMini is set to the mini-game script object of your Terrorist Mini-Game.

Code: [Select]
function GameConnection::SpawnPlayer(%this)
{
     Parent::SpawnPlayer(%this);

     if(%this.minigame == $TerroristMini)
     {
          if(%this.side $= "Terrorist" || %this.side $= "Chief Terrorist" || %this.side $= "Head Terrorist")
          {
               commandtoclient(%this,'CenterPrint',"\c6You're a \c0Terrorist\c6.",3,3,5000);
               %this.player.setTransform(vectorAdd($terroristSpawn,"0 0 1"));
               %this.player.setShapeName(%this.name @ "[ Terrorist ]");
          }
          else if(%this.side $= "SWAT")
          {
               commandtoclient(%this,'CenterPrint',"\c6You're in the \c0SWAT\c6.",3,3,5000);
               %this.player.setTransform(vectorAdd($SWATSpawn,"0 0 1"));
               %this.player.setShapeName(%this.name @ "[ SWAT ]");
          }
     }
}

$TerroristMini is just true or false.

Well, just do this.  Whenever a terrorist mini-game is created set <minigame>.isTerroristMG to 1.  Then modify the code I posted like this:

Code: [Select]
function GameConnection::SpawnPlayer(%this)
{
     Parent::SpawnPlayer(%this);

     if(%this.minigame.isTerroristMG)
     {
          if(%this.side $= "Terrorist" || %this.side $= "Chief Terrorist" || %this.side $= "Head Terrorist")
          {
               commandtoclient(%this,'CenterPrint',"\c6You're a \c0Terrorist\c6.",3,3,5000);
               %this.player.setTransform(vectorAdd($terroristSpawn,"0 0 1"));
               %this.player.setShapeName(%this.name @ "[ Terrorist ]");
          }
          else if(%this.side $= "SWAT")
          {
               commandtoclient(%this,'CenterPrint',"\c6You're in the \c0SWAT\c6.",3,3,5000);
               %this.player.setTransform(vectorAdd($SWATSpawn,"0 0 1"));
               %this.player.setShapeName(%this.name @ "[ SWAT ]");
          }
     }
}