entity.string1, How the hell

Posted By: Nidhogg

entity.string1, How the hell - 09/26/08 23:52

Does entity.string1 work with c-script..

I have a simple code
Code:
string Unit_Type;
function AI_Fight()
str_cpy(Unit_Type,my.string1)
if(Unit_Type == "guard")
{
do_something;
}

It does NOT work, even tried my.string2

AI just stands there looking stupid at me.. grin
Posted By: testDummy

Re: entity.string1, How the hell - 09/27/08 04:39

'I' believe, in C-Script, string objects are NOT usually compared in that manner.
functions used for string comparison: str_cmp, str_cmpi, str_cmpni

Posted By: log2

Re: entity.string1, How the hell - 09/27/08 04:58

yea testDummy is correct, you can't use string1 == string2, you actually have to use str_cmpi in you if statement

Code:
string Unit_Type;
function AI_Fight()
str_cpy(Unit_Type,my.string1)
if(str_cmpi(Unit_Type, "guard"))
{
do_something;
}


That's also case insensitive, aka GUARD would work just as well as guard, if you don't want that, change str_cmpi, to str_cmp
Posted By: Nidhogg

Re: entity.string1, How the hell - 09/27/08 06:22

Many thanks, It's works now..
© 2024 lite-C Forums