Check player has not got an inventory item...

Started by barefoot, Wed 09/02/2011 11:07:10

Previous topic - Next topic

barefoot

Hi

I'm in the middle of doing some scripting and I've come across this:

What would be a script for ' if player has NOT got an inventory item..'

I have other conditions set off by a region as well so it will need to fit in with other bits in the script..

I have used another way but maybe you have a better way?


cheers

barefoot
.




I May Not Be Perfect but I Have A Big Heart ..

Calin Leafshade

you can use the ! operator to negate any boolean expression.

so if (!player.HasInventory(iKey)) checks if player does NOT have iKey.

barefoot

I May Not Be Perfect but I Have A Big Heart ..

Ryan Timothy B

It's probably better to get used to using the ! operator, but in case it's troubling for you, this would be exactly the same:

if (player.HasInventory(iKey) == false)

barefoot

I May Not Be Perfect but I Have A Big Heart ..

Knox

or if you really want to complicate your life you could do this:

Code: ags

if (!(player.HasInventory(iKey) == true))


...hehe
--All that is necessary for evil to triumph is for good men to do nothing.

Khris

Or, without using !, there's
  if (player.InventoryQuantity[iKey] == 0)

Knox

and if you want a nose-bleed:
Code: ags

if (!(!(player.HasInventory(iKey) == true)) != true)*












*dont try this at home
--All that is necessary for evil to triumph is for good men to do nothing.

monkey0506

#8
Code: ags
if (player.HasInventory(iKey) ^ true)


Which is an extremely misleading usage of the XOR operator. :)

Code: ags
if ((player.HasInventory(iKey)) ^ (((true) && (false)) ^ ((true) || (false))))


Do I win? :=

barefoot

Nosebleed and nausea... ::)

great... cheers guys...   :=

barefoot
I May Not Be Perfect but I Have A Big Heart ..


Knox

QuoteI'm glad I didn't participate..
sure sure!!  ;)
--All that is necessary for evil to triumph is for good men to do nothing.

SMF spam blocked by CleanTalk