MrIslomaniac Posted July 10, 2010 Share Posted July 10, 2010 Why doesn't this work? if (atoi(GetEntityKey(Entity,"Value1","NULL")) >= atoi(GetEntityKey(entity,"Value2","NULL"))){ Left side contains 30, right side 20, but it doesn't work -.- Any idea? Thanks Quote Link to comment Share on other sites More sharing options...
Laurens Posted July 10, 2010 Share Posted July 10, 2010 What's not working precisely? The conversion from string to int? Is GetEntityKey returning NULL? A little more info would be nice! Cheers! Quote Link to comment Share on other sites More sharing options...
MrIslomaniac Posted July 10, 2010 Author Share Posted July 10, 2010 no that works correctly, atoi(GetEntityKey(Entity,"Value1","NULL")) returns 30 and atoi(GetEntityKey(Entity,"Value2","NULL")) returns 20 but this if is not working if (atoi(GetEntityKey(Entity,"Value1","NULL")) >= atoi(GetEntityKey(entity,"Value2","NULL"))){ return 1 } else return 0 always returns 1 even if left side is 0 and right side is 30 ... another example that does not work: 0 >= 0 Quote Link to comment Share on other sites More sharing options...
Mumbles Posted July 11, 2010 Share Posted July 11, 2010 another example that does not work: 0 >= 0 Well, that should evaluate to true (return 1)... 0 is after all, equal to 0. Secondly, is that code copied/pasted? Your second atoi statement has a lowercase 'e' on the entity, which could cause it to bring back a zero... In which case, only a negative number on the LHS can cause an evaluation of false Quote LE Version: 2.50 (Eventually) Link to comment Share on other sites More sharing options...
MrIslomaniac Posted July 11, 2010 Author Share Posted July 11, 2010 No, just wrong typing, sorry =( if (atoi(GetEntityKey(entity,"Value1","NULL")) >= (atoi(GetEntityKey(entity,"Value2","NULL")))){ printf("LOLOLOL\n"); } Sometimes it works, sometimes it does not ... Examples: 1 >= 58 well as i said sometimes it doesn't work with any number, sometimes it works perfectly... //EDIT found a way to get it working, when i store atoi(GetEntityKey(entity,"Value2","NULL")) in an int variable right before i do the if statement, it works =) thanks for your help Dustin Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.