Pawn -> And/or
#1

I've recently been experimenting with the pawn language in consoles, and I require a part of if statement that's like and/or; I've tried "&|" and "&&||" but none seem to work. Any help is appreciated,

Schurman.
Reply
#2

&& is for and
|| is for or
pawn Код:
If(GetPlayerMoney(playerid) > 50 && GetPlayerMoney(playerid) < 100) SendClientMessage(playerid, FFFFFF, "You have more than $50 but less than $100.");
If(GetPlayerMoney(playerid) <50 || GetPlayerMoney(playerid) > 100) SendClientMessage(playerid, FFFFFF, "You either have less than $50 or more than $100.");
Trying to create an 'and' and 'or' at the same time will never return anything.
Reply
#3

Quote:
Originally Posted by Schurman
Посмотреть сообщение
I've recently been experimenting with the pawn language in consoles, and I require a part of if statement that's like and/or; I've tried "&|" and "&&||" but none seem to work. Any help is appreciated,

Schurman.
Wouldnt that do the same as "||"?
Reply
#4

oh, my mistake. Yes DeathOnaStick, you are right.
Reply
#5

Quote:
Originally Posted by nemesis_567
Посмотреть сообщение
oh, my mistake. Yes DeathOnaStick, you are right.
No prob, you're welcome.
Reply
#6

I understood that he was asking what was used to do and and what was used to do or. But trying to use and and or at the same time is kinda pointless. Could you post your piece of code here?
Reply
#7

pawn Код:
forward refreshTimer();
public refreshTimer()
{
    if(minute <= 9 &&|| second <= 9) { printf("The time is %d:0%d:0%d %s", hour, minute, second, timemode); }
    else { printf("The time is %d:%d:%d %s.", hour, minute, second, timemode); }
}
The one above wouldn't work, but it still proves that using and/or isn't worthless.

But I'm guessing it could also work like this:

pawn Код:
forward refreshTimer();
public refreshTimer()
{
    if(minute <= 9 && second <= 9) { printf("The time is %d:0%d:0%d %s", hour, minute, second, timemode); }
    else if(minute <= 9) { printf("The time is %d:0%d:%d %s.", hour, minute, second, timemode); }
    else if(second <= 9) { printf("The time is %d:%d:0%d %s.", hour, minute, second, timemode); }
    else { printf("The time is %d:%d:%d %s.", hour, minute, second, timemode); }
}
--

Quote:
Originally Posted by nemesis_567
Посмотреть сообщение
&& is for and
|| is for or
pawn Код:
If(GetPlayerMoney(playerid) > 50 && GetPlayerMoney(playerid) < 100) SendClientMessage(playerid, FFFFFF, "You have more than $50 but less than $100.");
If(GetPlayerMoney(playerid) <50 || GetPlayerMoney(playerid) > 100) SendClientMessage(playerid, FFFFFF, "You either have less than $50 or more than $100.");
Trying to create an 'and' and 'or' at the same time will never return anything.
That code wouldn't work, as the if statement doesn't have an uppercase letter, also, the color code you have is not hexidemical, white is 0xFFFFFFFF.
Reply
#8

Well, yes, in your case it IS worthless. Because that whole code can be written in a single line.

"The time is %02d:%02d:%02d %s."
The 2 indicates the amount of numbers you'd like to have. The 0 in front of it indicates that it should be padded with 0's.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)