Bool or int ?
#6

Quote:
Originally Posted by Oxygenated
Посмотреть сообщение
Bool usually works with if or else commands if you set bool="true" the given command will work for the player but if you set bool="false" the command may refuse to work for the player. Int refers to an integral value,setting int value to work as a bool maybe a very bad idea as it is not a good way of scripting nor it works in most of the cases and gives errors.
---------------
Hope it helps!
---------------
Not true (regarding errors), a bool in PAWN is just a cell being 0 or 1 (to be precise any other value than 0). If you stick to this concept there is nothing wrong with using an int instead. There will be no errors with it either.

pawn Код:
new x = true;
Is technically the exact same thing as
pawn Код:
new bool:x = true;
or
pawn Код:
new bool:x = 1; // Will give a compiler warning, but works as expected (no error!)
or even
pawn Код:
new x = bool:1;
You can of course argue about good ways of scripting. It becomes clear that the variable is used to tell that something is either TRUE or FALSE, or ON/OFF. But that's pretty much it, if you know what you are doing and name Variables according to their use you can know this without using the bool tag.

PS: I'm not arguing for or against using the bool tag, but it's wrong to say there would be any errors or technical problems in using an integer as a boolean in PAWN. There can only be problems if you misinterpret the use of the variable.
Reply


Messages In This Thread
Bool or int ? - by pelican1 - 18.05.2017, 15:48
Re: Bool or int ? - by iLearner - 18.05.2017, 15:55
Re: Bool or int ? - by Aly - 18.05.2017, 16:01
Re: Bool or int ? - by Oxygenated - 18.05.2017, 17:08
Re: Bool or int ? - by Vince - 18.05.2017, 17:23
Re: Bool or int ? - by NaS - 18.05.2017, 17:31

Forum Jump:


Users browsing this thread: 1 Guest(s)