UDK - Type mismatch in 'If' for MyInventory functil

731 Views Asked by At

I am having trouble getting a pawn class to compile. The error is Type mismatch in 'If' in the line: if( MyInventory[inc] == int (x) );

CODE: [CODE]class BSAPawn extends UTPawn;

var() array MyInventory;

function bool HasItem(int x) { local int len; local int inc; len = MyInventory.Length;

for(inc = 0; inc < len; inc++)
{
   if( MyInventory[inc] = int x );
        return true;
}
return false;

}[/CODE]

Does anyone know how to sort this out? Tom

1

There are 1 best solutions below

0
On

You're assigning a value = instead of doing a comparison ==

it should look like..

for(inc = 0; inc < len; inc++)
{
   if( MyInventory[inc] == x )
        return true;
}
return false;

Plus why are you using int x instead of simply x