Boolian variables
#5

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
if you convert true to a number it will be 1
if you convert false to a number it will be 0

if you convert an integer to boolean everything not 0 will be true and 0 will be false

If you save an boolean it will save it was 1 or 0
And than if you load the number you will get 1 or 0
Just put a bool: before it to convert it back again

pawn Код:
LocInfo[id][AvailableTeleport] = bool: strval(Argument[7]);
or the better methode, we know that argument[7] is only 1 or 0, we could do

pawn Код:
LocInfo[id][AvailableTeleport] = (Argument[7][0] == '1');
or like that, I think thats the easiest check from all

pawn Код:
LocInfo[id][AvailableTeleport] = bool: Argument[7][0];
Okay,thank you very much
But how will it solve my errors? If I do 0 and 1 I get warnings and if I do true/false it will cause troubles reading from the file.

Quote:
Originally Posted by Sergei
Посмотреть сообщение
LocInfo[strlen(tmp)][AvailableTeleport] = false;
LocInfo[strlen(tmp)][AvailableTeleport] = true;

LocInfo[id][AvailableTeleport] = !!strval(Argument[7]);

And it's called boolean.
I know I can also use true and false,But I'm afraid it will cause troubles while it uploads&saves the variable in the file.

Quote:
Originally Posted by Raimis_R
Посмотреть сообщение
And not
pawn Код:
Bool:AvailableTeleport
But
pawn Код:
bool:AvailableTeleport
Thank you for noticing that
Reply


Messages In This Thread
Boolian variables - by nuriel8833 - 02.06.2011, 12:10
AW: Boolian variables - by Nero_3D - 02.06.2011, 12:39
Re: Boolian variables - by Sergei - 02.06.2011, 13:05
Re: Boolian variables - by Raimis_R - 02.06.2011, 13:30
Re: Boolian variables - by nuriel8833 - 02.06.2011, 13:36
Re: Boolian variables - by nuriel8833 - 03.06.2011, 09:12
Re: Boolian variables - by nuriel8833 - 04.06.2011, 12:18
AW: Boolian variables - by Nero_3D - 04.06.2011, 13:49
Re: Boolian variables - by Sergei - 04.06.2011, 16:49

Forum Jump:


Users browsing this thread: 1 Guest(s)