Same command, different jobs
#1

Код:
		if(strcmp("/lift", cmdtext, true) == 0)
		{
    if(IsPlayerInRangeOfPoint(playerid, 50, -2464.9296875,1522.9167480469,27.570457458496))
    {
      MoveObject(boatlift,-2464.9296875,1522.9167480469,27.570457458496, 2.0);
      SetTimer("gate1",35000,false);
      return 1;
		}
		else
		{
		SendClientMessage(playerid, COLOR_BLUE, "You Are Not Close Enough To The Lift(San Fierro Freight Boat)");
    return 1;
    }
How could i make that so that if you do /lift again, it will take the object back to where it was?
Reply
#2

You could make a new variable at the beginning:
Код:
new lift = 0;
Код:
		if(strcmp("/lift", cmdtext, true) == 0)
		{
    if(lift == 0) // Checks if lift is 0, If it's 0 moves to the rest If then to the code.. If it's 1, It goes directly to the else
    {
    if(IsPlayerInRangeOfPoint(playerid, 50, -2464.9296875,1522.9167480469,27.570457458496))
    {
      MoveObject(boatlift,-2464.9296875,1522.9167480469,27.570457458496, 2.0);
      SetTimer("gate1",35000,false);
      lift = 1; // Changing lift to 1
      return 1;
		}
		else
		{
		SendClientMessage(playerid, COLOR_BLUE, "You Are Not Close Enough To The Lift(San Fierro Freight Boat)");
    else
    {
       //Make the object move back to it's old position and change lift to 0
       lift = 0;
       return 1;
    }
}
Reply
#3

Indent your code properly.
pawn Код:
if(strcmp("/lift", cmdtext, true) == 0)
{
    if(lift == 0) // Checks if lift is 0, If it's 0 moves to the rest If then to the code..
        {
            if(IsPlayerInRangeOfPoint(playerid, 50, -2464.9296875,1522.9167480469,27.570457458496))
            {
                MoveObject(boatlift,-2464.9296875,1522.9167480469,27.570457458496, 2.0);
                SetTimer("gate1",35000,false);
                lift = 1; // Changing lift to 1
                return 1;
        } else {
            SendClientMessage(playerid, COLOR_BLUE, "You Are Not Close Enough To The Lift(San Fierro Freight Boat)");
            } else {
       //Make the object move back to it's old position and change lift to 0
       lift = 0;
       return 1;
    }
}
Reply
#4

ok, i got this now:

Код:
		if(strcmp("/lift", cmdtext, true) == 0)
		{
		if(lift == 0) // Checks if lift is 0, If it's 0 moves to the rest If then to the code..
    	{
		if(IsPlayerInRangeOfPoint(playerid, 50, -2464.9296875,1522.9167480469,27.570457458496))
		{
		MoveObject(boatlift,-2464.9296875,1522.9167480469,27.570457458496, 2.0);
		lift = 1; // Changing lift to 1
		return 1;
		} else {
		SendClientMessage(playerid, COLOR_BLUE, "You Are Not Close Enough To The Lift(San Fierro Freight Boat)");
		} else {
		if(lift == 1)MoveObject(boatlift, -2464.9296875,1522.9167480459,6.1990437507629,2);
  	lift = 0;
  	return 1;
    }
But the second: } else {
gives me this error:
invalid expression, assumed zero
Reply
#5

pawn Код:
if(strcmp("/lift", cmdtext, true) == 0)
    {
        if(IsPlayerInRangeOfPoint(playerid, 50, -2464.9296875,1522.9167480469,27.570457458496))
        {
            if(lift == 0)
            {
                MoveObject(boatlift,-2464.9296875,1522.9167480469,27.570457458496, 2.0);
                lift = 1;
            }
            else if(lift == 1)
            {
                MoveObject(boatlift, -2464.9296875,1522.9167480459,6.1990437507629, 2.0);
                lift = 0;
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_BLUE, "You Are Not Close Enough To The Lift(San Fierro Freight Boat)");
        }
        return 1;
    }
Reply
#6

MoveObject(boatlift,-2464.9296875,1522.9167480469,27.570457458496, 2.0);
and
MoveObject(boatlift, -2464.9296875,1522.9167480459,6.1990437507629, 2.0);
i think that's different!
Reply
#7

bump a solved topic, nice one... and of course its different, i dont want /lift to do something and /lift to do the same thing again, im not stupid.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)