Author Topic: Tumble Wand Not Working [Fixed]  (Read 1260 times)

Somehow, the addon works, but it in the console it says Unknown Command: AddVelocity. Here is the Function code:

Code: [Select]
function TumbleWandImage::onFire(%this, %obj, %slot)
{
if(!isObject(%obj.client))
return;
%start = %obj.getEyePoint();
%end = vectorScale(%obj.getEyeVector(), %this.projectile.range);
%rayCast = containerRayCast(%start, vectorAdd(%start, %end), %this.projectile.mask, %obj);
%target = firstWord(%rayCast);
if(!isObject(%target))
{
return;
}
%client = %obj.client;
%pos = posFromRaycast(%raycast);
%projectile = new projectile()
{
dataBlock = %this.projectile;
initialVelocity = %obj.getEyeVector();
initialPosition = %pos;
sourceObject = %obj;
sourceSlot = %slot;
client = %client;
};
missionCleanup.add(%projectile);
%class = %target.getClassName();
if(%class $= "AiPlayer" ||%class $= "Player" && (%obj.client.isAdmin))
%target.client.addvelocity("0 0 400");
schedule(100, 0, tumble, %target.client, 0.1);
}

Fixed. And is working.
« Last Edit: December 04, 2012, 10:55:45 PM by Advanced Bot »

Code: [Select]
if(%class $= "AiPlayer" ||%class $= "Player" && (%obj.client.isAdmin))
%target.client.addvelocity("0 0 400");
schedule(100, 0, tumble, %target.client, 0.1);
}

Lol, this isn't python.



Anyways, you're trying to add velocity to the client. Instead you should have %target.addVelocity();

I did that and it still says in the console: Unknown Command: AddVelocity

Try this.

Code: [Select]
function TumbleWandImage::onFire(%this, %obj, %slot)
{
if(!isObject(%client = %obj.client))   //Defines the client object in the same line
return;
%start = %obj.getEyePoint();
%end = vectorScale(%obj.getEyeVector(), %this.projectile.range);
%rayCast = containerRayCast(%start, vectorAdd(%start, %end), %this.projectile.mask, %obj);
if(!isObject(%target = firstWord(%raycast)))   //Combining another definition line
return;   //Brackets aren't needed for one item
%pos = posFromRaycast(%raycast);   //This is good practice
%projectile = new projectile()
{
dataBlock = %this.projectile;
initialVelocity = %obj.getEyeVector();
initialPosition = %pos;
sourceObject = %obj;   //Are these two lines even things?
sourceSlot = %slot;   //They're certainly not necessary
client = %client;
};
missionCleanup.add(%projectile);
%class = %target.getClassName();
if(%class $= "AiPlayer" ||%class $= "Player" && (%obj.client.isAdmin))   //Brackets ARE needed for two items
{
%target.addvelocity("0 0 400");   //Can't add velocity to a non-physical object.
schedule(100, 0, tumble, %target, 0.1);   //I'm 99% sure tumble uses a player too
}
}

Thanks Xalos. I need to learn more about coding. Lol.

Thanks Xalos. I need to learn more about coding. Lol.

Asking questions is a way to learn. Question for you; do you know what Xalos did to make that function work?

Yes. He added brackets in the function, and also added a "return;" thingy..