SphereCommunity

Full Version: strcmpi issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Looking at world gembits with spawn groups attached.

This:

if !(strcmpi(*<more1>*,*spawn*))

Never returns true while:

if (strcmpi(*<more1>*,*spawn*))

returns true even when it's not.

<more1> contains "spawn_<dungeonname><lvl>"
So with the wildcards it should technically return true if the word spawn appears under more1.
So why doesn't it?
try:
Code:
if (<serv.spawn.<more1>>) //true if it's a [spawn x] block
  //code
else
  //code
endif
The value in MORE1 is numeric... you cant compare a string to a numeric result.
And yet returns a string on t_spawn_char gembits
Think of it like a defname which maps a name to a number... Things like spawn_orcs will resolve to a number of some sort... but spawn_* cannot be looked up.
I thought I told you this before... you can't use a wild card with strcmpi!
Have a look at this page http://wiki.sphere.torfo.org/index.php/I..._Functions

what you need is strmatch or strregex.
Strmatch also doesn't function on it
IF (STRMATCH("*spawn*","<more1>")) should be what you are looking for.
well if <more1> is giving you some hex like number, why not resolve it?
Code:
if (strmatch(*spawn*,<serv.spawn.<more1>.defname>))
It never was giving a number...
Ben's method resolved it anyway
Reference URL's