Horn key to open 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: Horn key to open gate (
/showthread.php?tid=614409)
Horn key to open gate -
jimdo - 08.08.2016
How to make Horn Button to open the gate?
Re: Horn key to open gate -
Micko123 - 08.08.2016
Just make like this
if is player near the gate and if he press H move that object
Re: Horn key to open gate -
Ahmed21 - 08.08.2016
PHP код:
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;
}
Re: Horn key to open gate -
Viggo - 08.08.2016
Quote:
Originally Posted by Ahmed21
PHP код:
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;
}
|
Wow thank you.
Re: Horn key to open gate -
jimdo - 08.08.2016
Thanks mate.
Re: Horn key to open gate -
Ahmed21 - 08.08.2016
And if the gate is a dynamic object, then replace the "MoveObject" with "MoveDynamicObject".