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



Creating a gate - Stm - 03.09.2012

I'm trying to make a moving gate and to be high enough so nobody can skip to the other side of the gate. Can anyone help me ?


Re: Creating a gate - detter - 03.09.2012

You 1st create your gate like so
Код:
gate = CreateObject(modelid, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, Float:DrawDistance);
then you use this to move it
Код:
MoveObject(gate, new x, new y, new z,  SPEED );



Re: Creating a gate - Stm - 03.09.2012

Ok, what the hell is wrong with this?
Код:
//On top of the script
new impaund;

//OnGameModeInit
impaund = CreateObject(980, 1620.66, -1862.22, 15.33,   0.00, 0.00, 180.00);

//OnPlayerCommandText
        if(!strcmp(cmdtext, "/open", true))
		{
        if(IsPlayerInRangeOfPoint(playerid, 15.0, 0, 0, 0))
		{
            MoveObject(impaund, 0, 0, 0, 3.0);
            return 1;
        }
    }
        else if(strcmp(cmdtext, "/close", true))
		{
        if(IsPlayerInRangeOfPoint(playerid, 15.0, 0, 0, 0))
		{
            MoveObject(impaund, 1620.66, -1862.22, 15.33, 3.0);
            return 1;
        }
    }
  		return 1;
    }
    return 0;
}
If i type in game /open or close it saying Unknown command ... . What to do?


Re: Creating a gate - detter - 03.09.2012

Add this on top of your script
Код:
new impaund_Open; // it checks if gates is open
then on your "OnPlayerCommandText"
Код:
if (strcmp("/open", cmdtext, true, 10) == 0)
{
      if(impaund_Open == 1) return SendClientMessage(playerid ,SOME COLOR ,"Gate is already open!");
      if(IsPlayerInRangeOfPoint(playerid, 15.0, 1620.66, -1862.22, 15.33) )
      {
          // NEW = position of gates when they are open
          MoveObject(impaund, NEW X postion, NEW Y postion, NEW Z postion, 3.0);
          impaund_Open = 1;
       }
       else return SendClientMessage(playerid ,SOME COLOR ,"You are not near that gate!");
      return 1;
}

else if (strcmp("/close", cmdtext, true, 10) == 0)
{
      if(impaund_Open == 0) return SendClientMessage(playerid ,SOME COLOR ,"Gate is already closed!");
      if(IsPlayerInRangeOfPoint(playerid, 15.0, 1620.66, -1862.22, 15.33) )
      {
          MoveObject(impaund, 1620.66, -1862.22, 15.33, 3.0);
          impaund_Open = 0;
       }
       else return SendClientMessage(playerid ,SOME COLOR ,"You are not near that gate!");
      return 1;
}



Re: Creating a gate - Stm - 03.09.2012

I have fix it thanks anyway


Re: Creating a gate - rBcollo - 03.09.2012

OMG try classical method..

pawn Код:
new gate;
OnGameModeInit

pawn Код:
gate= CreateObject(...);
OnPlayerCommandText

pawn Код:
if(strcmp(cmd, "/opengate", true) == 0)
    {
        if(PlayerToPoint(5.0, playerid, Float:X, Float:Y, Float:Z))
        {
            MoveObject(gate, Float:X, Float:Y, Float:Z, TIME, 0, 0, 0);
            SetTimer("GateClose", 10000, 0);
            return 1;
        }
    }
pawn Код:
forward GateClose();
public GateClose()
{
    MoveObject(gate, Float:X, Float:Y, Float:Z, TIME, Float:rX, Float:rY, Float:rZ);
    return 1;
}



Re: Creating a gate - Stm - 03.09.2012

Can someone tell me how to play a sound when the gate is opening or closing.The one that is in Singleplayer, when garage opens .


Re: Creating a gate - detter - 03.09.2012

Easy

This is func.
https://sampwiki.blast.hk/wiki/PlayerPlaySound

This is list of all sounds
https://sampwiki.blast.hk/wiki/SoundID


Re: Creating a gate - Stm - 03.09.2012

Thanks