Author Topic: Image change on clear ghost bricks  (Read 1514 times)

This is what I have

Code: [Select]
package AWA1SwitchGrenade
{
function serverCmdCancelBrick(%this, %player, %slot, %val)
{
                if(isObject(%player.getMountedImage(0)))

                {

                       if((%player.getMountedImage(0).getName() $= "AWA1Image" || %player.getMountedImage(0).getName() $= "AWA1GrenadeImage" || %player.getMountedImage(0).getName() $= "AWA1RunningImage") && %slot $= 4 && %val)

                        {

                                switch$(%player.getMountedImage(0).getName())

                                {

       

                                        case "AWA1Image":

                                                %player.mountImage(AWA1GrenadeImage,0);

                                        case "AWA1GrenadeImage":

                                                %player.mountImage(AWA1Image,0);

                                        case "AWA1runningImage":

                                                %player.mountImage(AWA1GrenadeImage,0);

                                }

                         

                        }

                        else

                        {

                                Parent::serverCmdCancelBrick(%this, %player, %slot, %val);

                        }

                }

                else

                {

                        Parent::serverCmdCancelBrick(%this, %player, %slot, %val);

                }

        }
};
ActivatePackage(AWA1SwitchGrenade);
What I want it to do is be able to switch when you press the clear ghost button. This gives no console errors

This gives me a console error saying "getmountImage" doesn't exist.

because it doesen't

getMountedImage does


you made a typo in your post
« Last Edit: January 31, 2012, 12:16:58 PM by soba »

clientGroup.getObject(0).player.dump();


  getImageLoaded() - (int slot)
  getImageSkinTag() - (int slot)
  getImageState() - (int slot)
  getImageTrigger() - (int slot)
  getMountedImage() - (int slot)
  getMountedObject() - (int slot)
  getMountedObjectCount() -
  getMountedObjectNode() - (int node)
  getMountNodeObject() - (int node)
  getMountSlot() - (ShapeBaseImageData db)
  getObjectMount() - Returns the ShapeBase we're mounted on.
  getPendingImage() - (int slot)


You're confusing an error saying %player doesn't exist with an error saying the function doesn't exist.

The only argument for serverCmdCancelBrick is %this, or %client.
For %player, add %player = %this.player; to the top of your code. I don't really see why %slot would have to equal 4, I would drop that and the %val part. It looks irrelevant to the script anyway.

Okey, I added %player = %this.player; to my code, it doesn't give a console error, it just does nothing.

Okey, I added %player = %this.player; to my code, it doesn't give a console error, it just does nothing.
Change the large if statement to this:
if(%player.getMountedImage(0).getName() $= "AWA1Image" || %player.getMountedImage(0).getName() $= "AWA1GrenadeImage" || %player.getMountedImage(0).getName() $= "AWA1RunningImage")

Thanks man, it works.