[Help] Combining this together.
#1

I am trying to combine the two below functions... How can I do that?

Full script: Click here.

Both Parts:

I need to combine this...

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if((newkeys & KEY_ANALOG_RIGHT) && !(oldkeys & KEY_ANALOG_RIGHT))
    {
        if(IsPlayerInRangeOfPoint(playerid, 200, 3459.901611, -683.968445, 1.892129))
            {
              if(IsPlayerLuxAdmin(playerid))
                {
                    if(GateOpened == false)
                    {
                        MoveObject (gate1,3459.955566, -679.748474, 1.874337,2);
                        MoveObject (gate2,3459.746826, -693.807861, 1.874337,2);
                        SendClientMessage(playerid, 0x00ff00ff, "[Security System]: Access Granted! Have a nice day!");
                        GateOpened = true;
                        return 1;
                    }
                        else if(GateOpened == true)
                    {
                        MoveObject (gate1,3459.901611, -683.968445, 1.892129,2);
                        MoveObject (gate2,3459.791260, -689.405701, 1.892129,2);
                        GateOpened = false;
                        return 1;
                    }
                }
            }
        }
    return 1;
}
and this...

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if((newkeys & KEY_ANALOG_RIGHT) && !(oldkeys & KEY_ANALOG_RIGHT))
{
    if(IsPlayerLuxAdmin(playerid))
    {
        if(IsPlayerInRangeOfPoint(playerid, 200, 2287.92, 617.19, 12.00))
        {
            if(GateOpened == false)
            {
                MoveObject(admingate, 2287.92, 617.19, 6.00, 2);
                SendClientMessage(playerid, COLOR_GREEN, "[Security System]: Access Granted! Have a nice day!");
                GateOpened = true;
            }
            else if(GateOpened == true)
            {
                MoveObject (admingate, 2287.92, 617.19, 12.00, 2);
                GateOpened = false;
            }
        }
        else return 0;
    }
    else
    {
    }
    return 1;
}
return 1;
}
together.

Anyone know how to do this? Thanks in advance.

Credits to: "[SAP]Sidhu", "Babul", and "[ĦŁ₣]ЉǾǖŦĦЗŁΛẄ".
Reply
#2

https://sampwiki.blast.hk/wiki/Keywords:Statements#else
Reply
#3

create one more variable "AdminGateOpened", then it should work:
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if((newkeys & KEY_ANALOG_RIGHT) && !(oldkeys & KEY_ANALOG_RIGHT))
	{
		if(IsPlayerLuxAdmin(playerid))
		{
			if(IsPlayerInRangeOfPoint(playerid, 200, 3459.901611, -683.968445, 1.892129))
			{
				if(GateOpened == false)
				{
					MoveObject (gate1,3459.955566, -679.748474, 1.874337,2);
					MoveObject (gate2,3459.746826, -693.807861, 1.874337,2);
					SendClientMessage(playerid, 0x00ff00ff, "[Security System]: Access Granted! Have a nice day!");
					GateOpened = true;
					return 1;
				}
				else if(GateOpened == true)
				{
					MoveObject (gate1,3459.901611, -683.968445, 1.892129,2);
	  				MoveObject (gate2,3459.791260, -689.405701, 1.892129,2);
					GateOpened = false;
					return 1;
				}
			}
			else if(IsPlayerInRangeOfPoint(playerid, 200, 2287.92, 617.19, 12.00))
			{
				if(AdminGateOpened == false)
				{
					MoveObject(admingate, 2287.92, 617.19, 6.00, 2);
					SendClientMessage(playerid, COLOR_GREEN, "[Security System]: Access Granted! Have a nice day!");
					AdminGateOpened = true;
					return 1;
				}
				else if(AdminGateOpened == true)
				{
					MoveObject (admingate, 2287.92, 617.19, 12.00, 2);
					AdminGateOpened = false;
					return 1;
				}
 			}
		}
	}
	return 1;
}
Reply
#4

Ahh. Thanks Babul.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)