Raised This Month: $ Target: $400
 0% 

Bool


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 02-20-2006 , 17:38   Bool
Reply With Quote #1

Argh, I've been coding for a while, and took a huge break.
The thing is, I never learned what bool is or how to use it.

I read a short 2 setence explaination on what they are, they hold an option of true or false.

Ok.

Now I have a few questions regarding boolean variables.


1) How do I get the state of the bool variable?

Example:
new bool:coords[3]

From my understanding, it is false my default. Now, how would I go about seeing what the state of it is anyhow, in an "IF()" statement?

This is what I've tried

Code:
if(bool:j1[2] == true) {

2) What is the variable to use in a client_print() function to echo the state of the bool?
Example: client_print(id,print_chat,"State: %s",bool:coords)

I need to know what symbol (%s, %i, etc).


Thanks.
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
Charr
Senior Member
Join Date: Jul 2005
Location: Long Island, New York, U
Old 02-20-2006 , 17:48  
Reply With Quote #2

A bool is similar to a float in that you only have to declare bool: when you create it.

When you use it in a if() its:
Code:
new bool:blah = false; blah = true; if(blah == true) { }

I believe a bool is an interger, but I am not sure.
__________________
Charr is offline
Send a message via AIM to Charr Send a message via MSN to Charr
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 02-20-2006 , 17:51  
Reply With Quote #3

ok, but I'm using it as an array.
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
Charr
Senior Member
Join Date: Jul 2005
Location: Long Island, New York, U
Old 02-20-2006 , 17:55  
Reply With Quote #4

Then it would be
Code:
new bool:blah[2];

And a wya you can check the value of the bool is:
Code:
client_print(x,print_x,"%d",blah[x] ? "true" : "false");
__________________
Charr is offline
Send a message via AIM to Charr Send a message via MSN to Charr
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 02-20-2006 , 18:05  
Reply With Quote #5

Quote:
Originally Posted by Charr
Then it would be
Code:
new bool:blah[2];

And a wya you can check the value of the bool is:
Code:
client_print(x,print_x,"%d",blah[x] ? "true" : "false");
Ok, so how would I go about using that in an IF() statement?

This image below, makes me think that I am doing the true/false wrong in the IF() statements for the bools. Right? Wrong?
Attached Images
File Type: jpg wtf.jpg (21.6 KB, 208 views)
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 02-20-2006 , 18:16  
Reply With Quote #6

A bool is NOT an integer. A bool is a boolean value; true or false, 1 or 0.

You also need to use a strong tag: Bool: if you want to use it like that, otherwise you'll get tag warnings.

Its only similarity to a float is that, in PAWN, it is the size of one cell, and it is declared using a tag.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 02-20-2006 , 18:31  
Reply With Quote #7

Quote:
Originally Posted by Twilight Suzuka
A bool is NOT an integer. A bool is a boolean value; true or false, 1 or 0.

You also need to use a strong tag: Bool: if you want to use it like that, otherwise you'll get tag warnings.

Its only similarity to a float is that, in PAWN, it is the size of one cell, and it is declared using a tag.
So, what I'll have to do is create 2 serparate pairs of variables? Toggles and coord variableS?
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 02-20-2006 , 19:12  
Reply With Quote #8

Yeah.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 02-23-2006 , 06:58  
Reply With Quote #9

In pawn:

In IF statement you can do
Code:
if (myboolvar) // if myboolvar is true
Code:
if (!myboolvar) // if myboolvar is false

In print you can do
Code:
server_print("State: %d", myboolvar) // if myboolvar is true you'll get "State: 1" in other case "State: 0"
VEN is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 02-23-2006 , 07:30  
Reply With Quote #10

Quote:
Originally Posted by VEN
In pawn:

In IF statement you can do
Code:
if (myboolvar) // if myboolvar is true
Code:
if (!myboolvar) // if myboolvar is false

In print you can do
Code:
server_print("State: %d", myboolvar) // if myboolvar is true you'll get "State: 1" in other case "State: 0"
I prefer
Code:
server_print("State:%s" , myboolvar ? "true" : "false")
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Reply



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 20:21.


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