Creating a gate
#1

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 ?
Reply
#2

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 );
Reply
#3

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?
Reply
#4

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;
}
Reply
#5

I have fix it thanks anyway
Reply
#6

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

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 .
Reply
#8

Easy

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

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

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)