Isplayerinrangeofpoint - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Isplayerinrangeofpoint (
/showthread.php?tid=198806)
Isplayerinrangeofpoint -
LegendNissanGTR - 13.12.2010
Hi,is it possible that isplayerinrangeofpoint then the gate automaticly open and it giveplayermoney -$15?
Re: Isplayerinrangeofpoint -
CrucixTM - 13.12.2010
Of course it is
Re: Isplayerinrangeofpoint -
LegendNissanGTR - 13.12.2010
Cool.thanks for the help
Re: Isplayerinrangeofpoint -
LegendNissanGTR - 13.12.2010
How can i make it?
Re: Isplayerinrangeofpoint -
blackwave - 13.12.2010
Quote:
Originally Posted by LegendNissanGTR
How can i make it?
|
pawn Код:
public OnPlayerStateChange(playerid, oldstate, newstate)
{
if(IsPlayerInRangeOfPoint(playerid, distance, x, y, z)) // distance from x,y,z
{
MoveObject(objectid, x, y, z); // x, y, z where the gate will be moved to
GivePlayerMoney(playerid, -115);
}
return 1;
}
Re: Isplayerinrangeofpoint -
Scenario - 13.12.2010
Quote:
Originally Posted by blackwave
pawn Код:
public OnPlayerStateChange(playerid, oldstate, newstate) { if(IsPlayerInRangeOfPoint(playerid, distance, x, y, z)) // distance from x,y,z { MoveObject(objectid, x, y, z); // x, y, z where the gate will be moved to GivePlayerMoney(playerid, -115); } return 1; }
|
Wrong.
Your state doesn't change while driving (as far as I'm concerned). You would be better off using a timer to open/close the gate automatically when a player is in a certain range of it. Something like this would be appropriate:
pawn Код:
public OnGameModeInit()
{
SetTimer("AutoGate", 3000, 1);
return 1;
}
forward AutoGate();
public AutoGate()
{
foreach(Player, i) // Using "foreach" we're going to loop through the online players.
{
if(IsPlayerInRangeOfPoint(i, 20.0, GateX, GateY, GateZ)) // We need to check if the any of the players are in-range of the gate.
{
MoveObject(OBJECT_ID, GateOpenX, GateOpenY, GateOpenZ, 2.0); // If they are in-range, let's open it.
SetTimer("AutoGateClose", 3000, 1);
break; // Stop the loop - we found the player.
}
}
return 1;
}
forward AutoGateClose();
public AutoGateClose()
{
MoveObject(OBJECT_ID, GateCloseX, GateCloseY, GateCloseZ, 2.0);
return 1;
}
Re: Isplayerinrangeofpoint -
LegendNissanGTR - 13.12.2010
Cool thanks guys =) =) =) <3
Re: Isplayerinrangeofpoint -
LegendNissanGTR - 13.12.2010
RealCop228 so i dont need to CreateObject(987,bla,bla,bla under ongamemodeinit? for the gate to be build closed?
Re: Isplayerinrangeofpoint -
Sergei - 13.12.2010
@LegendNissanGTR, if you want gate, you need to create it. Isn't it obvious?
Re: Isplayerinrangeofpoint -
LegendNissanGTR - 13.12.2010
oh yah lol thanks