How to circle players? (Players in a circle) - 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: How to circle players? (Players in a circle) (
/showthread.php?tid=470318)
Deleted. -
iFiras - 17.10.2013
Deleted.
Deleted. -
iFiras - 17.10.2013
Deleted.
Re: How to circle players? (Players in a circle) -
DanishHaq - 17.10.2013
Make random spawn positions near the rock in that interior, then when the player teleports there, set him to one of those positions.
Re: How to circle players? (Players in a circle) -
kingofdemons - 17.10.2013
Well you will have to use SetPlayerPos some maths and loops.
I'll try this later if I have the time.
Re: How to circle players? (Players in a circle) -
RajatPawar - 17.10.2013
pawn Code:
new counter = 0, perangle = 0, players[MAX_PLAYERS]; foreach( new i: Player ) { new Float:x, Float:y, Float:z; GetPlayerPos( playerid, x, y, z); if(IsPlayerInRangeOfPoint( i, RANGE, x, y, z)) {counter++; players[i] = 1;} } if( counter != 0 ) { perangle = 360/counter; } new Float: fangle; GetPlayerFacingAngle( playerid, fangle ); for( new m = 0; m <MAX_PLAYERS; m++ ) { new temp = 0; if( players[m] == 1 ) { temp =+ 1; SetPlayerPos( m, x + RANGE * floatcos( fangle + temp*perangle, degrees ), y + RANGE*floatsin(fangle + temp*perangle, degrees), z ); ...
Can someone check if this is the right way to go? I did it on a piece of paper and typed this on mobile. The indent would kill a programmer!
Deleted. -
iFiras - 21.10.2013
Deleted.
Re: How to circle players? (Players in a circle) -
-Prodigy- - 21.10.2013
This function will get all players and place them in a circle around whoever used the function:
pawn Code:
// function by snoob
stock GetAllHere(playerid)
{
new Float:Dpos[4];
GetPlayerPos(playerid, Dpos[0], Dpos[1], Dpos[2]);
new Dtotal;
for (new i = 0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i)) Dtotal++;
new Float:Dangle = floatdiv(360.0, Dtotal);
new Dtick;
new Dint = GetPlayerInterior(playerid);
for (new i = 0; i<MAX_PLAYERS; i++)
{
if(i == playerid) continue;
if(IsPlayerConnected(i))
{
TogglePlayerControllable(i, false);
new Float:opp = (Dtick) ? (-Dpos[3]) : (Dpos[3]);
SetPlayerPos(i,
Dpos[0]+4.5*floatsin(opp,degrees),
Dpos[1]+4.5*floatcos(opp,degrees),
Dpos[2]);
SetPlayerInterior(playerid, Dint);
SetPlayerFacingAngle(i, floatsub(360.0, Dangle));
SetPlayerCameraPos(i,
Dpos[0]+7.5*floatsin(opp,degrees),
Dpos[1]+7.5*floatcos(opp,degrees),
Dpos[2]+5);
SetPlayerCameraLookAt(i, Dpos[0], Dpos[1], Dpos[2]);
Dpos[3] += Dangle;
if(Dtick) Dtick = 0;
else Dtick++;
}
}
return 1;
}
//Usage:
CMD:getall(playerid, params[])
{
GetAllHere(playerid);
return 1;
}