Linker Split 0 Posted July 9, 2008 Ok, let me explain you what i want to achieve: I want that when my character is near for example a bush, then the engine recognizes it is the bush lks_bush_leaf3_big.p3d and execut the second part of the script. Now I'm stuck at this simple string identity, cause I want to compare the string lks_bush_leaf3_big.p3d and the one the engine recognizes through the line _r_obj = str "_obj" if I put the famous trial line hint format ["%1",_r_obj], it works, the hint appears: lks_bush_leaf3_big.p3d but when coming to the identity, it doesn't work. why? <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ;my unit _Character = _this select 0 #START ;find the nearest object in order (passed array which elements are: 0 = player, 1 = nearest object) _near_obj = nearestObjects [_Character,[],3] ;select the array select 1, so the real object _obj = _near_obj select 1 :convert the object into a string _r_obj = str "_obj" ;identity which doesn't work ? _r_obj == "LKS_bush_leaf3_big.p3d" : _Character setDammage 1 ~1 goto "START" Share this post Link to post Share on other sites
sparky 0 Posted July 9, 2008 you say _r_obj = str "_obj" look closely and you wwill realise that you are saying arma to convert into a string something that is insde "" that means to convert the string _obj into a string that's why it doesn't work. try it without the "" _r_obj = str _obj Share this post Link to post Share on other sites
Linker Split 0 Posted July 9, 2008 yeah, sorry, I'm tired, i forgot to tell you i tried also without quotes.. .anyway, even without quotes, it gives me this hint: but still it is not working. This whole thing is bugging me Share this post Link to post Share on other sites
Master85 1 Posted July 9, 2008 look at the picture  There is a number in front of the name which you have to cut off.  Share this post Link to post Share on other sites
Linker Split 0 Posted July 9, 2008 look at the picture There is a number in front of the name which you have to cut off. so you think that the engine is passing the whole string with the number and the : instead of the only name? Share this post Link to post Share on other sites
Master85 1 Posted July 9, 2008 sure (you get a string like the one in the picture) normally I would use "typeof" but because the bushes and trees (not editor placed) are classless that's not possible. Share this post Link to post Share on other sites
Linker Split 0 Posted July 9, 2008 sure (you get a string like the one in the picture)normally I would use "typeof" but because the bushes and trees (not editor placed) are classless that's not possible. so hmm.... how to cut the numbers down? do you have any idea? Share this post Link to post Share on other sites
Master85 1 Posted July 9, 2008 different ideas: 1) use "toArray", find the space (find 32) and rebuild the string by using a loop through the array from (find 32) to (count array)-1 and then toString or 2) toString((toArray (str _obj)) - toArray "0123456789: ") Â (or better the unicodes directly) but here all numbers and : and spaces in the name are gone (perhaps I say nonsense and there is an easier way (which I don't know) to do this ) Share this post Link to post Share on other sites
Linker Split 0 Posted July 9, 2008 different ideas:1) use "toArray", find the space (find 32) and rebuild the string by using a loop through the array from (find 32) to (count array)-1 and then toString or 2) toString((toArray (str _obj)) - toArray "0123456789: ") (or better the unicodes directly) but here all numbers and : and spaces in the name are gone (perhaps I say nonsense and there is an easier way (which I don't know) to do this ) Ok m8 downloaded, tomorrow I'll try them and see what can be done thank you for your attention Linker Split Share this post Link to post Share on other sites
benreeper 0 Posted July 10, 2008 Comparing strings is case sensitive. Set them all to upper case before you compare them. --Ben Share this post Link to post Share on other sites
t_d 47 Posted July 10, 2008 "==" isnt case sensitive. checking with "in" is. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"blabla" == "BlABLa" //is true "blabla" in ["BlABLa","BLABLA"] //is false Share this post Link to post Share on other sites
benreeper 0 Posted July 12, 2008 Gotcha. Thanks. --Ben Share this post Link to post Share on other sites