SA-MP Forums Archive
Same command, different jobs - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Same command, different jobs (/showthread.php?tid=135968)



Same command, different jobs - cozza123456 - 22.03.2010

Код:
		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?



Re: Same command, different jobs - ACERS - 22.03.2010

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;
    }
}



Re: Same command, different jobs - jameskmonger - 22.03.2010

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;
    }
}



Re: Same command, different jobs - cozza123456 - 22.03.2010

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


Re: Same command, different jobs - MadeMan - 22.03.2010

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;
    }



Re: Same command, different jobs - 147rafa147 - 28.03.2010

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!


Re: Same command, different jobs - cozza123456 - 28.03.2010

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.