Jump to content
MakeWebGames

Someone help me with using an ARRAY system here


Recommended Posts

Posted

The way I want this to work is if a user matches ANY of the 3 race settings they can use it. If they Don't match, it denies them.

I am not sure how to get this to work like that

 

if($ir['race'] != $r['item_race'] OR $ir['race'] != $r['item_race2'] OR $ir['race'] != $r['item_race3'])

{

print "The selected item is not able to be used by your race.";

$h->endpage();

exit;

}

Any help would be appreciated, i'm thinking using arrays, but not sure how i'd set that up properly.

Posted

Tried that, $r is set.

 

I want an IF type function, i.e if their race matches ANY of the 3 they can use

so if their race is 3. and item_race=2, item_race2=2, item_race3=3

THey can use

but if it's not in those 3, they cant.....make sense? :P

Posted

RE: Someone help me with using an ARRAY system here

 

if($ir['race'] != $r['item_race'] && $ir['race'] != $r['item_race2'] AND $ir['race'] != $r['item_race3'])
{
//if you race isn't item_race, item_race2, and item_race3 then you shouldn't be here
print "The selected item is not able to be used by your race.";
$h->endpage();
exit;
}
Posted

Problem i'm having Seany

Is that it only has to match ONE of the 3.

So if($ir['race'] != $r['item_race'] BUT It matches item_race2 or item_race 3. They can use the item

If $IR race doesnt match ANY of the 3 they cant :P

Posted
Problem i'm having Seany

Is that it only has to match ONE of the 3.

So if($ir['race'] != $r['item_race'] BUT It matches item_race2 or item_race 3. They can use the item

If $IR race doesnt match ANY of the 3 they cant :P

That's what my code does... If it doesn't match any ONE of the three, it throws the error inside the if control statement.

Posted

Hm seems like i've tried that way

because it's saying if the race doesnt match ALL 3. At least that's what I was reading >,<

 

Perhaps I'm reading it wrong, i'll give it a go :p

Posted

And that did work and after going over it and reading it a bit better I see why.

All 3 have to be != for that to work

Gotcha >< I was thinking about it wrong, god sometimes i sware.

=P

Thanks man +1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...