SA-MP Forums Archive
strtobool - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: strtobool (/showthread.php?tid=351633)



strtobool - BaubaS - 16.06.2012

Anyone haves this function (it would convert string to a boolean (true/false) ? Tried to use search, nothing.


Re: strtobool - ViniBorn - 16.06.2012

What are your intentions with this function? Explain better, maybe we can help ...


Re: strtobool - Vince - 16.06.2012

sscanf.


Re: strtobool - Djole1337 - 16.06.2012

Quote:
Originally Posted by Vince
Посмотреть сообщение
sscanf.
Yes ^.


Re: strtobool - BaubaS - 16.06.2012

Quote:
Originally Posted by Vince
Посмотреть сообщение
sscanf.
Example?


Re: strtobool - Vince - 16.06.2012

pawn Код:
if(sscanf(params, "ll", "true false", bool1, bool2))
Note: lowercase L (stands for logical).


Re: strtobool - BaubaS - 16.06.2012

Quote:
Originally Posted by Vince
Посмотреть сообщение
pawn Код:
if(sscanf(params, "ll", "true false", bool1, bool2))
Note: lowercase L (stands for logical).
I need this function a bit in other way.

I've did it like this:

pawn Код:
pData[playerid][HiddenTrailers][i] = strval(szResult);
But I get tag mistach, because statsHiddenTrailers is a bool.


Re: strtobool - AndreT - 16.06.2012

Append !! before it!

I haven't tested, but it should work.
pawn Код:
pData[playerid][HiddenTrailers][i] = !!strval(szResult);
And it is quite damn clever!


Re: strtobool - BaubaS - 16.06.2012

ty u so much :]