Author Topic: Could Somebody please help? Thanks  (Read 746 times)

I cant remove the C4 from the inventory. Sheesh

Code: [Select]
//////////
// item //
//////////
datablock ItemData(C4BombItem)
{
category = "Weapon";  // Mission editor category
className = "Weapon"; // For inventory system

// Basic Item Properties
shapeFile = "./shapes/c4/c4.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "C4 Explosive";
iconName = "./ItemIcons/C4";
doColorShift = true;
colorShiftColor = "0.750 0.750 0.750 1.000";

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

function C4BombItem::onPickup(%this,%obj,%user,%amount)
{
return;
}

function C4BombItem::onCollision(%data,%obj,%col)
{
%id = getBrickGroupFromObject(%obj).client.bl_id;
%trust = getTrustLevel(getBrickGroupFromObject(%obj).client,%col.client);
%cl = getBrickGroupFromObject(%obj).client;
if(%obj.canpickup == 0){
return;
}
if(%col.client.minigame == 0){
%col.client.minigame = -1;

}
if(%cl.minigame == 0){
%cl.minigame = -1;

}
if(%col.client.minigame != %cl.minigame)
{
if(%col.client.minigame == -1){
centerprint(%col.client,"This item is part of a mini-game.",1,2);
return;
}
else
{
centerprint(%col.client,"This item is not part of the mini-game.",1,2);
return;
}
}
if(%col.client.minigame == %cl.minigame && %cl.minigame != -1 && %cl.minigame.useallplayersbricks == 0 && %cl.minigame.owner.bl_id != %id)
{
centerprint(%col.client,"This item is not part of the mini-game.",1,2);
return;
}
if(%trust >= $TrustLevel::Build || %cl== %col.client || %col.client.minigame == %cl.minigame && %cl.minigame != -1){
//
if(isobject(%obj.spawnbrick)){
for(%i=0;%i<5;%i++)
{
%toolDB = %col.tool[%i];
if(%obj.canpickup == 0){
return;
}
if(%toolDB == 0)
{
%col.tool[%i] = %obj.getdatablock();
%col.weaponCount++;
messageClient(%col.client,'MsgItemPickup','',%i,%obj.getdatablock());
%obj.canpickup = 0;
%obj.fadeout();
schedule(%obj.spawnbrick.itemrespawntime,0,C4overwrite,%obj);
break;
}
}
}
else{
for(%i=0;%i<5;%i++)
{
%toolDB = %col.tool[%i];
if(%obj.canpickup == 0){
return;
}
if(%toolDB == 0)
{
%col.tool[%i] = %obj.getdatablock();
%col.weaponCount++;
messageClient(%col.client,'MsgItemPickup','',%i,%obj.getdatablock());
%obj.delete();
break;
}
}
}
}
else{

centerprint(%col.client, ""@ %cl.name @" does not trust you enough to use this item.",1,2);

}

}

function getclientfromBLID(%id)
{
 for(%i=0;%i<ClientGroup.getCount();%i++){if(%id = ClientGroup.getObject(%i).bl_id){return ClientGroup.getObject(%i);}}
 return -1;
}

function C4overwrite(%obj)
{
if(isobject(%obj)){
%obj.fadein();
%obj.canpickup = 1;
}

}

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(C4BombImage)
{
   // Basic Item properties
   shapeFile = "./shapes/c4/c4.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "0 0 0";
   eyeOffset = 0; //"0.7 1.2 -0.5";
   rotation = eulerToMatrix( "0 0 0" );

   // 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 = true;

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

   // Projectile && Ammo.
   item = BowItem;
   ammo = " ";
   projectile = C4BombProjectile;
   projectileType = Projectile;

//casing = C4ShellDebris;
shellExitDir        = "1.0 -1.3 1.0";
shellExitOffset     = "0 0 0";
shellExitVariance   = 15.0;
shellVelocity       = 7.0;

   //melee particles shoot from eye node for consistancy
   melee = false;
   //raise your arm up or not
   armReady = true;
   minShotTime = 9000;   //minimum time allowed between shots (needed to prevent equip/dequip exploit)

   doColorShift = true;
   colorShiftColor = C4BombItem.colorShiftColor;//"0.400 0.196 0 1.000";

   //casing = " ";

   // 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.1;
stateTransitionOnTimeout[0]       = "Ready";
stateScript[3]                  = "onDMount";
stateSound[0] = weaponSwitchSound;

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

stateName[3]                    = "Fire";
stateTransitionOnTimeout[3]     = "End";
stateTimeoutValue[3]            = 0.1;
stateFire[3]                    = true;
stateAllowImageChange[3]        = false;
stateSequence[3]                = "Fire";
stateScript[3]                  = "onFire";
stateWaitForTimeout[3] = true;
stateEmitter[3] = null;
stateEmitterTime[3] = 0.05;
stateEmitterNode[3] = mountNode;
stateSound[3] = C4BombPlantSound;
   stateSequence[3]                = "Fire";
//stateEjectShell[3]       = true;

stateName[4] = "End";
stateScript[4]                  = "onDone";

};

function C4BombImage::onDMount(%this, %obj, %slot)
{
%obj.C4Bomblotsave = %obj.currTool;
}

function C4BombImage::onFire(%this, %obj, %slot)
{
%obj.playthread(2, shiftAway);
Parent::OnFire(%this, %obj, %slot);

for(%i=0;%i<5;%i++)
{
%toolDB = %obj.tool[%i];
if(%toolDB $= %this.item.getID() && %i == %obj.C4Bomblotsave)
{
%obj.tool[%i] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%i,0);
serverCmdUnUseTool(%obj.client);
break;
}
}
}

function C4BombImage::onDone(%this,%obj,%slot)
{
%obj.unMountImage(%slot);
}


Code: [Select]
%obj.C4Bomblotsave = %obj.client.currTool;Try that instead of %obj.