Raised This Month: $ Target: $400
 0% 

==, >, <, !=, what else?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-15-2020 , 11:19   ==, >, <, !=, what else?
Reply With Quote #1

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
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
alferd
Veteran Member
Join Date: Dec 2019
Location: Iran is Always Eternal
Old 06-15-2020 , 11:54   Re: ==, >, <, !=, what else?
Reply With Quote #2

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 }

Last edited by alferd; 06-15-2020 at 11:55.
alferd is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-15-2020 , 12:02   Re: ==, >, <, !=, what else?
Reply With Quote #3

Quote:
Originally Posted by alferd View Post
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
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-15-2020 , 11:58   Re: ==, >, <, !=, what else?
Reply With Quote #4

You can do if(cLevel > 10 && cLeveL < 20).
For the "signs" part of your question, I'm not sure what you are asking.
__________________
HamletEagle is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-15-2020 , 12:01   Re: ==, >, <, !=, what else?
Reply With Quote #5

I didn't know how to call them, but everything like equal, not equal, operators, and everything you know that is similar
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-15-2020 , 12:05   Re: ==, >, <, !=, what else?
Reply With Quote #6

Quote:
Originally Posted by supertrio17 View Post
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.
__________________
HamletEagle is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 06-15-2020 , 12:10   Re: ==, >, <, !=, what else?
Reply With Quote #7

That guide you sent me is golden, thanks
__________________
Contact! || Discord:
Mr_Boopsy_#2066
supertrio17 is offline
shauli
Member
Join Date: Jun 2018
Old 06-15-2020 , 13:54   Re: ==, >, <, !=, what else?
Reply With Quote #8

Quote:
Originally Posted by HamletEagle View Post
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.

Last edited by shauli; 06-15-2020 at 13:55.
shauli is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-15-2020 , 15:31   Re: ==, >, <, !=, what else?
Reply With Quote #9

Quote:
Originally Posted by shauli View Post
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 ...
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 06-16-2020 , 07:26   Re: ==, >, <, !=, what else?
Reply With Quote #10

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) }
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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