AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   ==, >, <, !=, what else? (https://forums.alliedmods.net/showthread.php?t=325280)

supertrio17 06-15-2020 11:19

==, >, <, !=, what else?
 
Hey, so I am making a plugin where I need to get levels from users, and I have to make a menu when they hit level 10, and another one when they hit level 20, but when they hit level 10 and die while they have that menu opened, they can't do it anymore. So I need to check every time they spawn if they choosed something from that menu. So I did that with global variables and nVault, but now when I must check for level, I have something Like this
PHP Code:

if( cLevel 10 

but how can I make this to be bigger than 10 and smaller than 20, I know that I can do
PHP Code:

if( cLevel 10 )
     if( 
cLevel <20

But is there any other way. And I'm interested in other "signs", so can anyone who knows all of them share it :)

alferd 06-15-2020 11:54

Re: ==, >, <, !=, what else?
 
I didn't read your post well,
But I think you want this code

Code:
if( cLevel == 10 )   { // for level 10 } else if( cLevel == 20 ) { // for level 20 }

HamletEagle 06-15-2020 11:58

Re: ==, >, <, !=, what else?
 
You can do if(cLevel > 10 && cLeveL < 20).
For the "signs" part of your question, I'm not sure what you are asking.

supertrio17 06-15-2020 12:01

Re: ==, >, <, !=, what else?
 
I didn't know how to call them, but everything like equal, not equal, operators, and everything you know that is similar

supertrio17 06-15-2020 12:02

Re: ==, >, <, !=, what else?
 
Quote:

Originally Posted by alferd (Post 2705848)
I didn't read your post well,
But I think you want this code

Code:
if( cLevel == 10 )   { // for level 10 } else if( cLevel == 20 ) { // for level 20 }

No, I want If a player has bigger value than 10, but smaller than 20, and everything bigger than 20

HamletEagle 06-15-2020 12:05

Re: ==, >, <, !=, what else?
 
Quote:

Originally Posted by supertrio17 (Post 2705852)
I didn't know how to call them, but everything like equal, not equal, operators, and everything you know that is similar

This is a very vague question.
What do you want to compare? Numbers? Then you just listed the operators yourself.
Do you want to use bitwise operators? Cool, read a tutorial about bits(not only from this forum but any tutorial about bits).
Etc...

Go to the pawn language guide pdf I linked in the other topic, page 105. You'll get a nice list.

supertrio17 06-15-2020 12:10

Re: ==, >, <, !=, what else?
 
That guide you sent me is golden, thanks :)

shauli 06-15-2020 13:54

Re: ==, >, <, !=, what else?
 
Quote:

Originally Posted by HamletEagle (Post 2705850)
You can do if(cLevel > 10 && cLeveL < 20).

Same as HamletEagle said, but just wanted to add that
PHP Code:

if(10 cLevel 20

will also work in Pawn, but won't work in most programming languages.

Natsheh 06-15-2020 15:31

Re: ==, >, <, !=, what else?
 
Quote:

Originally Posted by shauli (Post 2705866)
Same as HamletEagle said, but just wanted to add that
PHP Code:

if(10 cLevel 20

will also work in Pawn, but won't work in most programming languages.

it depends on how smart the compiler is ...

OciXCrom 06-16-2020 07:26

Re: ==, >, <, !=, what else?
 
Using ranges with "switch" is also possible:

Code:
switch(cLevel) {     case 0 .. 9: // levels 1 to 10     case 10 .. 20: // levels 10 to 20     case 21 .. 29: // levels 21 to 29     case 30: // level 30     default: // everything else not included here (likely above 30) }


All times are GMT -4. The time now is 17:11.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.