Author Topic: Help with 'Parent::'  (Read 906 times)

Client.cs:
Code: [Select]
if (!$ScopeToggle)
{
$remapDivision[$remapCount] = "Zooms";
$remapName[$remapCount] = "Scope";
$remapCmd[$remapCount] = "Scope_Toggle";
$remapCount++;
$ScopeToggle = 1;
}

function Scope_Toggle(%v)
{
   if(%v == 1)
   {
       Crosshair.setBitmap("Add-ons/Zoom_Scope_Rifle/BarrelScope/crossHair");
       Crosshair.resize(0,0,800,600);
       Parent::toggleScope(%1);
       %v == 0;
   }
   else
   {
       Crosshair.setBitmap("Add-ons/Zoom_Scope_Rifle/Default/crossHair");
       Crosshair.resize(304,224,32,32);
       Parent::toggleScope(%0);
       %v == 1;
   }
}

Console error:
Code: [Select]
--------- Loading Client Add-Ons ---------
Loading compiled script base/server/crapOns.cs.
%
Client checking Add-On: Zoom_Scope_Rifle
Loading Add-On: Zoom_Scope_Rifle
Add-Ons/Zoom_Scope_Rifle/client.cs Line: 16 - Syntax error.
>>> Some error context, with ## on sides of error halt:
       Crosshair.resize(0,0,800,600);
       Parent::toggleScope(%1)##;##
       %v == 0;
   }
   else
   {
       Crosshair.setBitmap("Add-ons/Zoom_Scope_Rifle/Default/crossHair");
>>> Error report complete.

Executing Add-Ons/Zoom_Scope_Rifle/client.cs.
Add-Ons/Zoom_Scope_Rifle/client.cs Line: 16 - Syntax error.
>>> Some error context, with ## on sides of error halt:
       Crosshair.resize(0,0,800,600);
       Parent::toggleScope(%1)##;##
       %v == 0;
   }
   else
   {
       Crosshair.setBitmap("Add-ons/Zoom_Scope_Rifle/Default/crossHair");
>>> Error report complete.

%

Why are you trying to Parent outside of a Package?

And %1 and %0 are invalid variable names. They have to start with a-z or an underscore.

You're doing parent::toggleScope on function scope_toggle. This is wrong, I'm pretty sure.

And %1 and %0 are invalid variable names. They have to start with a-z or an underscore.

It would be that causing the syntax errors. Calling Parent outside of a package won't cause that, It just won't run the function right.

%v == 0; (line 17) is invalid, it isn't a 'test' or comparison statement. One equals sign for assignment (set %v to 0), two for comparison. (is %v equal to 0)

Client.cs:
Code: [Select]
if (!$ScopeToggle)
{
$remapDivision[$remapCount] = "Zooms";
$remapName[$remapCount] = "Scope";
$remapCmd[$remapCount] = "Scope_Toggle";
$remapCount++;
$ScopeToggle = 1;
}

function Scope_Toggle()
{
   if(%v == 1)
   {
       Crosshair.setBitmap("Add-ons/Zoom_Scope_Rifle/BarrelScope/crossHair");
       Crosshair.resize(0,0,800,600);
       Parent::toggleScope(%v1);
       %v = 0;
   }
   else
   {
       Crosshair.setBitmap("Add-ons/Zoom_Scope_Rifle/Default/crossHair");
       Crosshair.resize(304,224,32,32);
       Parent::toggleScope(%v0);
       %v = 1;
   }
}

Console:
Code: [Select]
Add-Ons/Zoom_Scope_Rifle/client.cs (23): Unknown command toggleScope.This line is added to the console whenever I push the binded key or release it.

Also, when the script runs, my crosshair is placed a little towards the top-right while keeping the default bitmap.

You seriously have no idea what you're doing...

List of problems:
  • You're trying to call a parent function when there is no parent to call.
  • You're trying to use %v as a global variable.
  • You're trying to pass %v0 and %v1 to a non-existant toggleScope function.
  • %v1 and %v0 have not and never will have a value.
  • You're trying to check %v at the top when it doesn't have a value.

Its just a mess...

Honestly, I don't.  I'm piecing together lines of code people are giving to me.
Package/parent toggleScope(%val)
This is what was given to me when I requested the line that zooms a player's view.
« Last Edit: February 21, 2009, 05:34:22 PM by Quantum »

Client.cs:
Code: [Select]
if (!$ScopeToggle)
{
$remapDivision[$remapCount] = "Zooms";
$remapName[$remapCount] = "Scope";
$remapCmd[$remapCount] = "Scope_Toggle";
$remapCount++;
$ScopeToggle = 1;
}
package scopetoggle {
   function Scope_Toggle(%v)
   {
      if(%v $= 1)
      {
          Crosshair.setBitmap("Add-ons/Zoom_Scope_Rifle/BarrelScope/crossHair");
          Crosshair.resize(0,0,800,600);
          Parent::Whateverthefunctionis(1);
          %v = 0;
      }
      else
      {
          Crosshair.setBitmap("Add-ons/Zoom_Scope_Rifle/Default/crossHair");
          Crosshair.resize(304,224,32,32);
          Parent::whateverthefunctionis(0);
          %v = 1;
      }
   }
};
Console:
Code: [Select]
Add-Ons/Zoom_Scope_Rifle/client.cs (23): Unknown command toggleScope.This line is added to the console whenever I push the binded key or release it.
use common sense, it clearly states its not a function.
Also, when the script runs, my crosshair is placed a little towards the top-right while keeping the default bitmap.
Reposition it on the image itself, Offsets would be more complicated.