Author Topic: I'm having problems with my first weapon add-on...  (Read 338 times)

Now, I know some people are going to start saying "gtfo newcigarette", but I just need some help with this script. I'm getting syntax errors in the following code:
Code: [Select]
function SORImage::onFire(%this,%obj,%slot)
{
if(%obj.getImageAmmo(%slot))
{
%projectile = SORProjectileA;
%spread = 0;
%shellcount = 1;

for(%shell=0; %shell<%shellcount; %shell++)
{
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector,(%projectile.muzzleVelocity));
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);

%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
originPoint = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
serverPlay3D(SORShot1Sound, %obj.getMuzzlePoint(%slot));
};
MissionCleanup.add(%p);
}
return %p;
}
else
{
%projectile = SORProjectileB;
%spread = 0.010;
%shellcount = 8;

for(%sh=0; %sh<%shellcount; %sh++)
{
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector,%projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);

%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
originPoint = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
if %sh=1 {
serverPlay3D(SORShot2Sound, %obj.getMuzzlePoint(%slot));
};
};
MissionCleanup.add(%p);
}
return %p;
}
}

It's on the first serverPlay3D. Any ideas? I'm not really sure what to do...
And yeah, I know it's an ASKR edit... Sorry for not knowing this language.

Never mind. I figured it out myself.