08.08.2016, 07:00
How to make Horn Button to open the gate?
OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
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:GatePosX, Float:GatePosY, Float:GatePosZ;
GetObjectPos(GateObjectID, GatePosX, GatePosY, GatePosZ); //Replace the GateObjectID with your gate object id.
if(IsPlayerInRangeOfPoint(playerid, 5.0, GatePosX, GatePosY, GatePosZ)) //If the player is near the gate.
{
MoveObject(GateObjectID, NewPosX, NewPosY, NewPosZ, 5.0, NewPosRotationX, NewPosRotationY, NewPosRotationZ);
//5.0 = Moving Speed
}
}
}
return 1;
}
PHP код:
|