Jump to content

Simple C++ question


MrIslomaniac
 Share

Recommended Posts

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

Link to comment
Share on other sites

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

LE Version: 2.50 (Eventually)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...