SA-MP Forums Archive
Double IFs in one command problem - 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: Double IFs in one command problem (/showthread.php?tid=328282)



Double IFs in one command problem - Deathh - 24.03.2012

I want to show players a dialog, but NOT if they have less than one hour playtime.

How do i define two IFs in one?

Example:

pawn Код:
if(IsPlayerInRangeOfPoint(playerid,COORDZ))
        {
            ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_LIST, "DIALOG Stuff here");
        }
That's my command, But i want to include this too:
pawn Код:
if(PlayerInfo[playerid][pHourz] < 1)
        {
            SendClientMessage(playerid, COLOR-HERE, "  Text here.");
            return 1;
        }
Basically, if they are at place and have one hour play time it shows.

If less than 1 hour playing time: YOU CANT BUY

If they arent at the place, they get a message

how do i include two IFs in one?

something like as in INRANGEBLABLA && HASTIME BLABLA

+rep for best answer


Re: Double IFs in one command problem - Kaczmi - 24.03.2012

pawn Код:
new a,b,bool:c;
if(!c && a == 1||
c && b == 0 ||
!c && a == 0)
This?


Re: Double IFs in one command problem - Gamer_Z - 24.03.2012

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        if(!IsPlayerInRangeOfPoint(playerid,COORDZ))
        {
            SendClientMessage(playerid,-1,"You are not at the COORDZ");
            return 1;
        }
        if(PlayerInfo[playerid][pHourz] < 1)
        {
            SendClientMessage(playerid, COLOR-HERE, "  Text here.");
            return 1;
        }
        ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_LIST, "DIALOG Stuff here");
        return 1;
    }
    return 0;
}
try like that.


Re: Double IFs in one command problem - Deathh - 24.03.2012

Quote:
Originally Posted by Gamer_Z
Посмотреть сообщение
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        if(!IsPlayerInRangeOfPoint(playerid,COORDZ))
        {
            SendClientMessage(playerid,-1,"You are not at the COORDZ");
            return 1;
        }
        if(PlayerInfo[playerid][pHourz] < 1)
        {
            SendClientMessage(playerid, COLOR-HERE, "  Text here.");
            return 1;
        }
        ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_LIST, "DIALOG Stuff here");
        return 1;
    }
    return 0;
}
try like that.
exactly how i want it, but now i get 1million errrs + pawn crash.


Re: Double IFs in one command problem - Blunt - 24.03.2012

Here you go.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        if(!IsPlayerInRangeOfPoint(playerid,COORDZ))
        {
            if(PlayerInfo[playerid][pHourz] < 1)
            {
                ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_LIST, "DIALOG Stuff here");
            }
            else SendClientMessage(playerid, -1, "You do not have an hours playing time");
        }
        else SendClientMessage(playerid,-1,"You are not at the COORDZ");
        return 1;
   }
}
This would activate the function, -IF- the player is inside the specific coordinations and has 1 "Hourz".


Re: Double IFs in one command problem - Deathh - 24.03.2012

Quote:
Originally Posted by Blunt
Посмотреть сообщение
Here you go.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        if(!IsPlayerInRangeOfPoint(playerid,COORDZ))
        {
            if(PlayerInfo[playerid][pHourz] < 1)
            {
                ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_LIST, "DIALOG Stuff here");
            }
            else SendClientMessage(playerid, -1, "You do not have an hours playing time");
        }
        else SendClientMessage(playerid,-1,"You are not at the COORDZ");
        return 1;
   }
}
This would activate the function, -IF- the player is inside the specific coordinations and has 1 "Hourz".
exactly as i want it, but it just says i don't have 1 hour now. the "phourz" was just an example of my shit btw.


Re: Double IFs in one command problem - Gamer_Z - 24.03.2012

Quote:
Originally Posted by Deathh
Посмотреть сообщение
exactly how i want it, but now i get 1million errrs + pawn crash.
and what are those +1millsion erorrs?


Re: Double IFs in one command problem - The DeLuca - 25.03.2012

Код:
if(IsPlayerInRangeOfPoint(playerid,COORDZ) && PlayerInfo[playerid][pHourz] < 1)
{
	ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_LIST, "DIALOG Stuff here");
}
You mean this?


Re: Double IFs in one command problem - Steven82 - 25.03.2012

Quote:
Originally Posted by The DeLuca
Посмотреть сообщение
Код:
if(IsPlayerInRangeOfPoint(playerid,COORDZ) && PlayerInfo[playerid][pHourz] < 1)
{
	ShowPlayerDialog(playerid, DIALOGID, DIALOG_STYLE_LIST, "DIALOG Stuff here");
}
You mean this?
Yes i believe that is infact what he needs.

Quote:
Originally Posted by Kaczmi
Посмотреть сообщение
pawn Код:
new a,b,bool:c;
if(!c && a == 1||
c && b == 0 ||
!c && a == 0)
This?
Seriously? This is [sarcasm]REALLY...REALLY HELPFUL![/sarcasm] -_-