SA-MP Forums Archive
moving gate - 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: moving gate (/showthread.php?tid=297434)



moving gate - Jordiee - 15.11.2011

Ok I wanna make a moving gate but the tutorials i have been looking at are strcmd ones.
I want someone to explain to me how to do it as I want to learn.


this are the coords i want the gate to go to once its opened. So /open it moves to:
Код:
CreateObject(976, 821.5, 1734.4000244141, 4.1999998092651, 0, 358, 284);
and this is when you /close:
Код:
CreateObject(976, 823.29998779297, 1726.3000488281, 4.1999998092651, 0, 358, 284);
NOTE: The gate is already at these coords

and I have already done "new gate1;"


Re: moving gate - IceCube! - 15.11.2011

Right FIRST the gate has to be created and defined an example

pawn Код:
new gate;
 Gate = CreateObject(976, 821.5, 1734.4000244141, 4.1999998092651, 0, 358, 284);
Then you have to move that object under any command header for example in ZCMD
pawn Код:
CMD:Movegate(playerid)
{
      MoveObject(Gate, 976, 823.29998779297, 1726.3000488281, 4.1999998092651, 0, 358, 284);
      return 1;
}
YOu could always make it more complex by doing ranges (
pawn Код:
IsPlayerInRangeOfPoint();
and so on


Re: moving gate - Jordiee - 15.11.2011

Ok thanks, so how would I set this out? and yes InRangePoint would be good.


Re: moving gate - IceCube! - 15.11.2011

An example would be:

pawn Код:
CMD:movegate(playerid)
{
      if(IsPlayerInRangeOfPoint(playerid, Range, X, Y, Z) MoveObject(Gate, X, Y, Z);
      else if(IsPlayerInRangeOfPoint(playerid, Range, X, Y, Z) MoveObject(Gate, X, Y, Z);
      else if(IsPlayerInRangeOfPoint(playerid, Range, X, Y, Z) MoveObject(Gate, X, Y, Z);
       else SendClientMessage(playerid, COLOUR, YOur arnt in range of a movable gate."):
       return 1;
}



Re: moving gate - Jordiee - 16.11.2011

I just want a simple /opengate and it opens the gate for faction id 7 and it will close using /closegate.. that simple. Thanks.


Re: moving gate - Qur - 16.11.2011

Hope it will help.. i really not sure.. but try it.. if I did something wrong.. please someone fix me..

pawn Код:
new gate; // at the start of your script

/* put in public OnGameModeInit() */
gate = CreateObject(976, 821.5, 1734.4000244141, 4.1999998092651, 0, 358, 284);

/* put in public OnPlayerCommandText(playerid, cmdtext[]) */
    if(strcmp(cmd, "/opengate", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pMember] == 7 || PlayerInfo[playerid][pLeader] == 7)
            {
                if(IsPlayerInRangeOfPoint(i, 5.0, 821.5, 1734.4000244141, 4.1999998092651))
                {
                    MoveObject(gate, 823.29998779297, 1726.3000488281, 4.19999980926510, 3.5);
                    return 1;
                }
            }
        }
        return 1;
    }
   
    if(strcmp(cmd, "/closegate", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pMember] == 7 || PlayerInfo[playerid][pLeader] == 7)
            {
                if(IsPlayerInRangeOfPoint(i, 5.0, 823.29998779297, 1726.3000488281, 4.1999998092651))
                {
                    MoveObject(gate, 821.5, 1734.4000244141, 4.1999998092651, 3.5);
                    return 1;
                }
            }
        }
        return 1;
    }



Re: moving gate - Jordiee - 16.11.2011

sorry I use ZCMD.


Re: moving gate - CSSI - 16.11.2011

pawn Код:
if(IsPlayerInRangeOfPoint(i, 5.0, 821.5, 1734.4000244141, 4.1999998092651))
You Haven't defined 'i'


Re: moving gate - Jordiee - 16.11.2011

CreateObject(976, 821.5, 1734.4000244141, 4.1999998092651, 0, 358, 284);
this is the place the gate is at:
823.29998779297, 1726.3000488281, 4.1999998092651
these are the ones I want the gate to move to when you use /opengate


Re: moving gate - Qur - 16.11.2011

Then I suggest you to try understand the script I gave you or whatever people explain and make it the way you want it

and that's right.. didnt defined 'i'.. my bad ;/