PVar question
#1

Hey. I've got a question over here about PVar variables. I've got script over here, that displays ur current variable in dialog. For example if variable [PlayerAdmin] is equal to 0, it says "You've got no administrator rights", and if it's equal to 1, it says "You've got administrator rights". The question is - if my variable has has int 2,3,4,5 and so on, how do I print it on dialog?
Current code (it's just an example):
Код:
GetPVarInt(playerid, "PlayerAdminLevel") ? (""grey"Unavailable") : (""green"Available"));
if I insert one more colon and rewrite one more choice, compiling throws me few errors.
Example I was talking about:
Код:
GetPVarInt(playerid, "PlayerAdminLevel") ? (""grey"Unavailable") : (""green"Available") : (""white"3rd choice));
Is there any choice I can insert more choices to represent them in dialog?

Soz for my english. I'm bad
Reply
#2

PHP код:
switch(GetPVarInt(playerid"PlayerAdminLevel"))
{
 case 
0format(string,sizeof(string),"Unavailable"); 
 case 
1format(string,sizeof(string),"Available"); 
 case 
2format(string,sizeof(string),"3rd choice"); 
default: 
format(string,sizeof(string),"Undefined");

Reply
#3

Although it's possible to use another ternary operation, I recommend you utilize switch.

Quote:
Originally Posted by czerwony03
Посмотреть сообщение
PHP код:
switch(GetPVarInt(playerid"PlayerAdminLevel"))
{
 case 
0format(string,sizeof(string),"Unavailable"); break;
 case 
1format(string,sizeof(string),"Available"); break;
 case 
2format(string,sizeof(string),"3rd choice"); break;
default: 
format(string,sizeof(string),"Undefined"); break;

Using break inside a switch statement will give you an error, unless it's inside a loop.

Quote:

error 024: "break" or "continue" is out of context

Reply
#4

Quote:
Originally Posted by zPain
Посмотреть сообщение
Although it's possible to use another ternary operation, I recommend you utilize switch.



Using break inside a switch statement will give you an error, unless it's inside a loop.
Yes, you are right.

Too much PHP (php requires break; before next case ;d)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)