24.12.2010, 13:01
(
Последний раз редактировалось DeathOnaStick; 24.12.2010 в 13:39.
Причина: Added sollution
)
Hey. One simple question:
Is there an easy way to add boolean variables into a string, like:
'%boolean' should be a pseudo placeholder for boolean variables. Now here is my question: Is there a placeholder that does something similar? And if yes, what is its' name/character?
If not, is there an easy way of adding true/false to a string, without using a mass of if-statements?
#Edit#:
Alright, I made a sollution for this on my own now:
It works like strcat, just with a boolean as second value, instead of an string. maxlength is optional.
If there is still another way, please let me know.
Thank you.
Is there an easy way to add boolean variables into a string, like:
pawn Код:
new string[25], bool:TrueOrFalse=true;
format(string, sizeof(string), "The statement is %boolean", TrueOrFalse);
If not, is there an easy way of adding true/false to a string, without using a mass of if-statements?
#Edit#:
Alright, I made a sollution for this on my own now:
pawn Код:
strbool(string[], bool:var, maxlength=sizeof(string))
{
switch(var)
{
case true: return strcat(string, "true", maxlength);
case false: return strcat(string, "false", maxlength);
}
return -1;
}
If there is still another way, please let me know.
Thank you.