function player::getNumItems(%player)
{
%data = %player.getDatablock();
%toolCount = 0;
for(%i = 0; %i < %data.maxItems; %i++) //Loop through player's tools
{
if(isObject(%player.tool[%i])) //We have a tool
{
%toolCount++; //Add 1 to the tool count
}
}
return %toolCount; //Return the final value
}
== is a boolean comparison meaning equals to. It is true the numbers on both sides of it are equal. != is the opposite. && means and. For example:
if(%X == 0 && %Y == 5)
Would only be true if %x is zero and %y is five.
|| is the same thing, but it means or. For example:
if(%X == 0 || %Y != 5)
Would be true if %x is zero OR %y is not five.