Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
DynamiteKaitorn

If statement being ignored and going straight to the else statement

Question

Spoiler

 

script 10 (void)
{
    if (CheckActorInventory (0, "SapphireGemmy") >= 3)
    {
        Floor_LowerByValue (8, 16, 127);
    }

    else
    {
        HudMessage (s:"Sorry Dynamite, you need more sapphire gems."; HUDMSG_TYPEON, 1,  CR_GREEN, 0.5, 0.35 , 1873 * 25);
    }
}

 

 

This is a script I am working on so far. All it does is check whether the player (aka Dynamite) has collected at least 3 gems. In total they can find 5 (not counting secrets) in the first "hub".

 

The else statement works fine but for some reason I can't seem to get the IF statement to work...

 

Any ideas?

Share this post


Link to post

1 answer to this question

Recommended Posts

  • 0

Your script is not working because the "checkactorinventory" function does not contemplate a 0 as tag of the activator.

If you want your script to check the inventory of the player (or everything that activates it) you have tu use the function "checkinventory". A fixed version of your code follows (be sure to have a backup file because this is untested)

Spoiler

script 10 (void)
{
    if (CheckInventory ("SapphireGemmy") >= 3)
    {
        Floor_LowerByValue (8, 16, 127);
    }

    else
    {
        HudMessage (s:"Sorry Dynamite, you need more sapphire gems."; HUDMSG_TYPEON, 1,  CR_GREEN, 0.5, 0.35 , 1873 * 25);
    }
}

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×