Author Topic: RC Sapper's With Names  (Read 927 times)


If only I could display player's names over their RC Sapper's, I could tell who was controlling it. I desperately need this for my RC racing so I can tell who wins. What do I need to add to this code in order for the player's names to show up?

Code: [Select]
exec("./playertype.cs");
exec("./emitters.cs");

datablock ItemData(BombBotItem)
{
category = "Item";  // Mission editor category
equipment = true;

//its already a member of item namespace so dont break it
//className = "Item"; // For inventory system

// Basic Item Properties
   shapeFile = "./rcbombItem.dts";
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "RC Sapper";
iconName = "./icon_rc_bomb";
doColorShift = false;
colorShiftColor = "0.200 0.200 0.200 1.000";

// Dynamic properties defined by the scripts
image = BombBotImage;
canDrop = true;
};

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(BombBotImage)
{
   // Basic Item properties
   shapeFile = "./rcbombItem.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "0 0 0.2";
   rotation = eulerToMatrix("0 0 0");
   eyeOffset = "0.005 1.1 -1.25";
   eyeRotation = eulerToMatrix("-28 4 4");

   doColorShift = true;
colorShiftColor = BombBotItem.colorShiftColor;
   

   // When firing from a point offset from the eye, muzzle correction
   // will adjust the muzzle vector to point to the eye LOS point.
   // Since this weapon doesn't actually fire from the muzzle point,
   // we need to turn this off. 
   correctMuzzleVector = false;

   // Add the WeaponImage namespace as a parent, WeaponImage namespace
   // provides some hooks into the inventory system.
   className = "ToolImage";

   // Projectile && Ammo.
   item = BombBotItem;

   //melee particles shoot from eye node for consistancy
   melee = true;
   //raise your arm up or not
   armReady = true;

   doColorShift = true;
   minShotTime = 15000;
   colorShiftColor = BombBotItem.colorShiftColor; //"0.200 0.200 0.200 1.000";

   // Images have a state system which controls how the animations
   // are run, which sounds are played, script callbacks, etc. This
   // state system is downloaded to the client so that clients can
   // predict state changes and animate accordingly.  The following
   // system supports basic ready->fire->reload transitions as
   // well as a no-ammo->dryfire idle state.

   // Initial start up state
stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.5;
stateTransitionOnTimeout[0]       = "Ready";

stateName[1]                     = "Ready";
stateScript[1]                  = "onUse";
stateTransitionOnTriggerDown[1]  = "Fire";
stateAllowImageChange[1]         = true;

stateName[2]                    = "Fire";
stateTransitionOnTriggerUp[2] = "Ready";
stateScript[2]                  = "onFire";
};

function BombBotImage::onMount(%this, %obj, %slot)
{
if((%obj.lastFireTime+%this.minShotTime) > getSimTime() && %this.usedsapper == 1)
{
centerprint(%obj.client,"Can't deploy another RC Sapper yet!<br><br>Give it a while to respawn..." ,5);
serverCmdUnUseTool(%obj.client);
return;
%obj.playThread(2, undo);
}


%obj.playthread(1, armReadyBoth);
}

function BombBotImage::onUnMount(%this,%obj,%slot)
{
Parent::onUnMount(%this, %obj, %slot);

fixArmReady(%obj);
}

function BombBotImage::onFire(%this, %obj, %slot)
{
%obj.lastFireTime = getSimTime();
%this.usedsapper = 1;
SpawnBomber(%obj.client);
%obj.playThread(1, plant);
%obj.playThread(2, activate2);
serverCmdUnUseTool(%obj.client);
}

function SpawnBomber(%client)
{
%obj = %client.player;
%pos = vectorAdd(%obj.getTransform(), vectorScale(%obj.getForwardVector(), 4)) @ getWords(%obj.getTransform(), 3, 6);


%bot = new AIPlayer()
{
datablock = "bomberbotArmor";
position = %pos;
};
%bot.setTransform(%pos);

%client.setcontrolobject(%bot);
%client.player.bomberbotarmor = %bot;

%bot.name = "RC Bomb";
%bot.bomberOwner = %client;
%bot.minigame = %obj.client.minigame;
%bot.client = %bot;
%bot.tdmTeam = %obj.client.tdmTeam;
%bot.player = %bot;
}

function bomberbotarmor::onDisabled(%this,%obj,%state)
{
bomberbotarmorExplosion(%obj);
}

function bomberbotarmor::onTrigger(%this, %obj, %slot, %val)
{
if(%val == 1 && %slot == 4)
{
bomberbotarmorExplosion(%obj);
}
}

function bomberbotarmorExplosion(%obj)
{
if(isObject(%obj.getControllingClient()))
%obj.getControllingClient().setControlObject(%obj.getControllingClient().player);

%projectile = gravityrocketProjectile;
%p = new Projectile()
{
dataBlock = %projectile;
initialVelocity = "0 0 1";
initialPosition = %obj.getPosition();
sourceObject = %obj.bomberOwner.player;
sourceSlot = %slot;
client = %obj.bomberOwner;
};

MissionCleanup.add(%p);
%p.explode();

%obj.schedule(10, delete);
}


By the way guys, he means it will help MY raceway. So, you'll be supporting my server if you help him.

The RC sapper is an AIPlayer, thus you cannot by standard give it it's own built-in name.
You can, however, do something like this:

Code: [Select]
// %rc is the RC Sapper
%rc.shapeCam = new Camera()
{
datablock = Observer;
rcSapper = %rc;
};

missionCleanup.add( %rc.shapeCam );
%rc.shapeCam.setMode( "Corpse", %rc );
%rc.shapeCam.setShapeName( "whatever" );

Make sure to remove %rc.shapeCam when the RC Sapper is removed.

Use search more often.
A topic named "Names on top of the RC snapper." [sic] was actually right on the second page.
« Last Edit: December 28, 2011, 05:38:51 AM by Port »

Ok, How do I remove %rc.shapeCam when the RC Sapper is removed? Is this another code or what? And, does the "whatever" represent the name? Finally, does this code put the player's name above the RC? If it doesn't, is it possible to set the Name while in game with setbotname or setvehiclename?

%rc.shapeCam.delete();

It puts "whatever" on top of it.