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: Gate (
/showthread.php?tid=441443)
Gate -
lramos15 - 02.06.2013
Im trying to do a gate command that if you are near the gate it can tell what gate you want to open and open it. Can you help me I only have this right now.
pawn Код:
CMD:gate(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] == 8055)
{
MoveObject(impoundgate,-1209.48816, -1071.85449, 123.64065,1.5);
}
else return SendClientMessage(playerid, COLOR_RED, "You are not the owner of this server.");
return 1;
}
Re: Gate -
DarkShade705 - 02.06.2013
Did you created an object before doing the CMD?
Use this link it will help you
Re: Gate -
Richie© - 02.06.2013
If you want the CMD to only work near the gate, use;
IsPlayerInRangeOfPoint
Re: Gate -
lramos15 - 02.06.2013
Yes I did I want many gates and if Im near the gates it can tell what gate I want open
Re: Gate -
Richie© - 03.06.2013
Yes, and for that you use IsPlayerInRangeOfPoint.
pawn Код:
CMD:gate(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] == 8055)
{
if(IsPlayerInRangeOfPoint(playerid, 15.0, -1209.48816, -1071.85449, 123.64065)) // Is Player within 15 meters of this gate?
{
MoveObject(impoundgate,-1209.48816, -1071.85449, 123.64065,1.5); // if so, move the gate.
}
if(IsPlayerInRangeOfPoint(playerid, 15.0, /*X,Y,Z Cords for another gate*/)) // Continue with other gates.
{
//Move another gate here.
}
}
else return SendClientMessage(playerid, COLOR_RED, "You are not the owner of this server.");
return 1;
}
Re: Gate -
lramos15 - 03.06.2013
How do I get the gate to move back up with the same /gate command
Re: Gate -
Richie© - 03.06.2013
You can use variables for that.
pawn Код:
new bool:MyGateIsOpen; // This var will tell us if gate is open or not
//If your gate is closed by default, set this in OnGameModeInit; MyGateIsOpen = false;
CMD:gate(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] == 8055)
{
if(IsPlayerInRangeOfPoint(playerid, 15.0, -1209.48816, -1071.85449, 123.64065)) // Is Player within 15 meters of this gate?
{
if(MyGateIsOpen == false) // The gate is closed
{
MoveObject(impoundgate,-1209.48816, -1071.85449, 123.64065,1.5); // Open the gate
MyGateIsOpen = true;
}
else // Else the gate is open and we want it to close now
{
MoveObject(impoundgate,/*Move the gate back to closed position*/,1.5); // Close the gate
MyGateIsOpen = false;
}
}
if(IsPlayerInRangeOfPoint(playerid, 15.0, /*X,Y,Z Cords for another gate*/)) // Continue with other gates.
{
//Move another gate here.
}
}
else return SendClientMessage(playerid, COLOR_RED, "You are not the owner of this server.");
return 1;
}