Author Topic: Help finding Cleint  (Read 400 times)

I am trying to make a reloading weapon, it works by calling the function setCC45A2Ammo when the gun is in the activate phase. Then while the gun fires the same function is called with %subtract set to 1. This is not the part i need help with though. I am trying to find out how to mount a diffrent image when ammo = 0. This image is basically the reloading gun then it switches back to the normal image.
Code: [Select]
function setCC45A2Ammo(%amount,%subtract)
{
%ammo = %amount;
%ammo -= %subtract;
if ( %ammo == 0 )
{
reloadThisstuff();
}

}
function reloadThisstuff(%client)
{
%client.player.mountImage(CC45A2CImage,0);
}
function CC45A2Reload(%client)
{
%client.player.mountImage(CC45A2Image,0);
}

This is where the function is called:

Code: [Select]
   // Initial start up state
stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.15;
stateTransitionOnTimeout[0]       = "Ready";
stateSound[0] = weaponSwitchSound;

stateName[1]                     = "Ready";
stateTimeoutValue[0]             = 0.01;
stateTransitionOnTimeout[1]  = "Reload";
stateAllowImageChange[1]         = true;
stateSequence[1] = "Ready";

stateName[2] = "Reload";
stateSequence[2]                = "Reload";
stateScript[2] = "onReload";
stateTimeoutValue[2]             = 2;
stateTransitionOnTimeout[2]  = "Wep";

stateName[3] = "Wep";
stateSequence[3]                = "Reload";
stateScript[3] = "onWep";
stateTransitionOnTriggerUp[3]     = "Ready";
stateSequence[3] = "Reload";
};
function CC45A2CImage::onWep()
{
CC45A2Reload();
}

I am not that great of a torque scripter. Although I did take the CTY program for the fundamentals of C++, I am still use to programing in BASIC and I am not use to the client\server format of TGE. Any help would be appreciated.

Hint: the arguements for any state script are %image,%player,%slot.

Double hint:

==>findClientByName(b).player.dump();
Member Fields:
  canSetIFLs = "0"
  dataBlock = "PlayerStandardArmor"
  position = "100.562 -103.522 286.314"
  rotation = "0 0 -1 102.359"
  scale = "1 1 1"
Tagged Fields:
  canDismount = "1"
  client = "6028"
  currTool = "1"
  currWeaponSlot = "-1"
  hasShotOnce = "1"
  mountVehicle = "1"
  spawnTime = "2807810"
  tempBrick = "7144"
  tool0 = "71"
  tool1 = "81"
  tool2 = "393"
  tool3 = "0"
  tool4 = "0"
  weaponCount = "0"
Methods:
blah blah blah...