Comparing array values
Posted: Mon Feb 14, 2011 7:12 pm
Hi,
Can someone point me in the direction of how to properly code the following situation. Preferably in the "right" or "best" practice.
More or less, I want to compare each value from 2 separate arrays, if the value is present in both, do this, if not do that. I have been looking at methods to do this so and have usually ended up with a nested foreach. I haven't found a lot in the scripting tutorials regarding "if in array".
Context: It is for a command script that powers up certain skill-set. Eg. powering up all warrior type skills. At the same time I want it to remove any skills that are not within the array of warrior skills. I could just do a blanket 'set all skills to 0' but that doesn't seem very professional or right to me to have a players skills set to 0 then to 100 straight after. It should just set it to 100, while removing irrelevant skills. The less blue spam on the screen the better.
Any opinions, direction or advice?
Thanks.
Can someone point me in the direction of how to properly code the following situation. Preferably in the "right" or "best" practice.
More or less, I want to compare each value from 2 separate arrays, if the value is present in both, do this, if not do that. I have been looking at methods to do this so and have usually ended up with a nested foreach. I haven't found a lot in the scripting tutorials regarding "if in array".
Context: It is for a command script that powers up certain skill-set. Eg. powering up all warrior type skills. At the same time I want it to remove any skills that are not within the array of warrior skills. I could just do a blanket 'set all skills to 0' but that doesn't seem very professional or right to me to have a players skills set to 0 then to 100 straight after. It should just set it to 100, while removing irrelevant skills. The less blue spam on the screen the better.
Any opinions, direction or advice?
Thanks.