Author Topic: Is there anything wrong with this?  (Read 498 times)

well, it looks fine to me, but everytime I try it, it just says:
Code: [Select]
Add-Ons/Weapon_Baseball_bat/server.cs (507): Unable to find object: '' attempting to call function 'mountImage'
BackTrace: ->servercmdUseTool->Weapon::onUse->BaseBallBatImage::onMount
Can someone tell me what im doing wrong here?
Code: [Select]
function BaseballbatImage::onMount(%this, %obj, %slot, %client)
{
   if(%obj.BatBroken = 1)
   {
  %obj.mountimage(BaseballbatBrokenImage);
}
   else if(%client.Rarm = 1)
   {
  %obj.hidenode("RHand");
}
else
{
  %obj.hidenode("Rhook");
  }
}

Change:

if(%obj.BatBroken = 1)
to:
if(%obj.BatBroken == 1)

...batBrokenImage);
to:
...batBrokenImage,0);

...ent.Rarm = 1)
to:
...ent.Rarm == 1)

That's about all I can see.

Explanations for those who need it:

Code: [Select]
if(%obj.BatBroken == 1)
Code: [Select]
...ent.Rarm == 1)

Numerical comparions need to use a double equals sign. If you use a single equals sign in an if test, what it performs is:

1) Set the variable to the value you provide
2) 'Returns' the value that it was set to

Meaning the if test would pass unintentionally if you set it to 1 or 2, but not 0; for example.

Code: [Select]
...batBrokenImage,0);

the .mountImage method requires that you provide an image name and a slot to mount to. This slot is not the mountPoint: that is defined in the image itself. The slot is what you trigger the weapon from (Blockland accepts 0 by default for clicking).