Instead of 1 or 0; how to make it say yes or no -
BleverCastard - 09.12.2012
I want to know how to make something say yes or no instead of 1 or 0..
Please help?
Re: Instead of 1 or 0; how to make it say yes or no -
rockerman - 09.12.2012
what you want to say can u please explain
Re: Instead of 1 or 0; how to make it say yes or no -
tyler12 - 09.12.2012
if(something == 1) somekindofstring = "Yes";
else if(something == 0) somekindofstring = "No";
Re: Instead of 1 or 0; how to make it say yes or no -
BleverCastard - 09.12.2012
Quote:
Originally Posted by tyler12
if(something == 1) somekindofstring = "Yes";
else if(something == 0) somekindofstring = "No";
|
Lolwut?
Can you explain more :/
Re: Instead of 1 or 0; how to make it say yes or no -
Konstantinos - 09.12.2012
The only way is what tyler posted.
You set a variable to 0/1 and if it's 1, you set the string to 'yes', otherwise to 'no'. For example, on saving..
if he is registed (that means 1), then save it on the file as 'yes' (string) instead of 1. When you load, if the text is 'yes', set the variable to 1, otherwise 0.
Re: Instead of 1 or 0; how to make it say yes or no -
tyler12 - 09.12.2012
Quote:
Originally Posted by [MP]Ditch
Lolwut?
Can you explain more :/
|
pawn Код:
new SomeIntger, YesOrNoString[24],string[124];; // The variable ( 1 / 0 ) and the YesOrNoString where Yes / No is stored
if(SomeIntger == 1) // If the variable is 1
{
YesOrNoString = "Yes"; // Set the YesOrNoString to Yes.
}
else if(SomeIntger == 0) // The variable is 0
{
YesOrNoString = "No"; // Set the YesOrNoString to No.
}
format(string,sizeof(string),"The answer is: %s",YesOrNoString); //We say Yes / No
Re: Instead of 1 or 0; how to make it say yes or no -
iTorran - 09.12.2012
You can also do it this way
pawn Код:
new yourinteger = 1, yourstring[10];
format(yourstring, sizeof yourstring, "%s", yourinteger ? ("Yes") : ("No"));
print(yourstring); //Outputs "Yes"
http://forum.sa-mp.com/showpost.php?...7&postcount=73
Re: Instead of 1 or 0; how to make it say yes or no -
BleverCastard - 09.12.2012
Quote:
Originally Posted by tyler12
pawn Код:
new SomeIntger, YesOrNoString[24],string[124];; // The variable ( 1 / 0 ) and the YesOrNoString where Yes / No is stored
if(SomeIntger == 1) // If the variable is 1 { YesOrNoString = "Yes"; // Set the YesOrNoString to Yes. } else if(SomeIntger == 0) // The variable is 0 { YesOrNoString = "No"; // Set the YesOrNoString to No. }
format(string,sizeof(string),"The answer is: %s",YesOrNoString); //We say Yes / No
|
So how would I do this for VIP in /stats?
Re: Instead of 1 or 0; how to make it say yes or no -
tyler12 - 09.12.2012
if(pInfo[playerid][VIP] == 1) return String = "Yes"
else if(pInfo[playerid][VIP] == 0) return String = "No"
Or you can do it the way iTorran said.
Re: Instead of 1 or 0; how to make it say yes or no -
Konstantinos - 09.12.2012
Quote:
Originally Posted by [MP]Ditch
So how would I do this for VIP in /stats?
|
pawn Код:
// /stats command
new
Yes_No[ 5 ],
string[ 128 ];
;
if( IsPlayerVip[ playerid ] ) format( Yes_No, 5, "Yes" );
else format( Yes_No, 5, "No" );
format( string, 128, "VIP: %s ...", Yes_No );
ShowPlayerDialog( ... ); or SendClientMessage( ... );