Horn key to open gate
#1

How to make Horn Button to open the gate?
Reply
#2

Just make like this
if is player near the gate and if he press H move that object
Reply
#3

PHP код:
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
      if((
newkeys KEY_CTRL_BACK) && !(oldkeys KEY_CTRL_BACK))  //If the player uses the horn "clicks H"
      
{
              new 
pState GetPlayerState(playerid);
              if(
IsPlayerInAnyVehicle(playerid) && pState == PLAYER_STATE_DRIVER//If the player is driving a car
              
{
                      new 
Float:GatePosXFloat:GatePosYFloat:GatePosZ;
                      
GetObjectPos(GateObjectIDGatePosXGatePosYGatePosZ); //Replace the GateObjectID with your gate object id.
                      
if(IsPlayerInRangeOfPoint(playerid5.0GatePosXGatePosYGatePosZ)) //If the player is near the gate.
                      
{
                             
MoveObject(GateObjectIDNewPosXNewPosYNewPosZ5.0NewPosRotationXNewPosRotationYNewPosRotationZ);
                             
//5.0 = Moving Speed
                      
}
               }
       }
       return 
1;

Reply
#4

Quote:
Originally Posted by Ahmed21
Посмотреть сообщение
PHP код:
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
      if((
newkeys KEY_CTRL_BACK) && !(oldkeys KEY_CTRL_BACK))  //If the player uses the horn "clicks H"
      
{
              new 
pState GetPlayerState(playerid);
              if(
IsPlayerInAnyVehicle(playerid) && pState == PLAYER_STATE_DRIVER//If the player is driving a car
              
{
                      new 
Float:GatePosXFloat:GatePosYFloat:GatePosZ;
                      
GetObjectPos(GateObjectIDGatePosXGatePosYGatePosZ); //Replace the GateObjectID with your gate object id.
                      
if(IsPlayerInRangeOfPoint(playerid5.0GatePosXGatePosYGatePosZ)) //If the player is near the gate.
                      
{
                             
MoveObject(GateObjectIDNewPosXNewPosYNewPosZ5.0NewPosRotationXNewPosRotationYNewPosRotationZ);
                             
//5.0 = Moving Speed
                      
}
               }
       }
       return 
1;

Wow thank you.
Reply
#5

Thanks mate.
Reply
#6

And if the gate is a dynamic object, then replace the "MoveObject" with "MoveDynamicObject".
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)