moving objects in a certain radius - 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: moving objects in a certain radius (
/showthread.php?tid=271488)
moving objects in a certain radius -
slymatt - 24.07.2011
i have a command to move a gate:
Код:
CMD:gopen(playerid, params[])
{
if(INI_Open(getINI(playerid)))
{
PlayerInfo[playerid][Faction] = INI_ReadInt("Faction");
PlayerInfo[playerid][Factionrank] = INI_ReadInt("Factionrank");
//LSPDFACTION
if(PlayerInfo[playerid][Faction] == LSPD)
{
if(PlayerInfo[playerid][Factionrank] > 0)//Any rank
{
if(!isnull(params))
{
return SendClientMessage(playerid,SYellow,"Usage: /gate.");
}
else
{
SendClientMessage(playerid,SYellow,"The Lspd Garage gate is now opening.");
return MoveObject(lspdgaragegate, 1596.90, -1637.94, 16.00, 4.0);
}
}
return SendClientMessage(playerid,SYellow,"You must be atlest rank 1 LSPD to use this.");
}//RANK 1 END
else
{
return SendClientMessage(playerid,SYellow,"You must be LSPD to use that command.");
}
}
return 0;
}
how can i modify that to only move in a certain radius?
Re: moving objects in a certain radius -
Prumpuz - 24.07.2011
You mean the player must be in a certain radius to move the gate? That is, if they are not close enough to the gate, it won't move. If so, then look into IsPlayerInRangeOfPoint function:
https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
And for the code, it should work like this:
pawn Код:
CMD:gopen(playerid, params[])
{
if(INI_Open(getINI(playerid))) {
PlayerInfo[playerid][Faction] = INI_ReadInt("Faction");
PlayerInfo[playerid][Factionrank] = INI_ReadInt("Factionrank");
//LSPDFACTION
if(PlayerInfo[playerid][Faction] == LSPD) {
//Any rank
if(PlayerInfo[playerid][Factionrank] > 0) {
if(!isnull(params)) {
return SendClientMessage(playerid,SYellow,"Usage: /gate.");
}
else {
new Float:x, Float:y, Float:z;
GetObjectPos(lspdgaragegate, x, y, z);
if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) return SendClientMessage(playerid, COLOR_RED, "Your'e not close enough to the gate.");
SendClientMessage(playerid,SYellow,"The Lspd Garage gate is now opening.");
return MoveObject(lspdgaragegate, 1596.90, -1637.94, 16.00, 4.0);
}
}
return SendClientMessage(playerid,SYellow,"You must be atlest rank 1 LSPD to use this.");
} //RANK 1 END
else {
return SendClientMessage(playerid,SYellow,"You must be LSPD to use that command.");
}
}
return 0;
}
The range is set to 5.0, that can be changed to what suits you the most.
Re: moving objects in a certain radius -
slymatt - 24.07.2011
worked thanks alot