12.11.2015, 14:20
Hello guys is it possible getting all connected players position and then creating explosion for each player? if so how i can do that i know the explosion part just need someone to teach me getting everyones X Y Z
for(new i = 0; i < MAX_PLAYERS; i++) //loop
{
if(IsPlayerConnected(i)) //Check if is Player Connected
{
new Float:x, Float:y, Float:z; //variables
// Use GetPlayerPos, passing the 3 float variables we just created
GetPlayerPos(playerid, x, y, z);
CreateExplosion(x, y, z, 12, 10.0); //Create explosion on x, y, z cords
}
return 1;
}
COMMAND:explode(playerid, params[])
{
new bombid;
new fstr[200];
if (PlayerInfo[playerid][admin variable] < 0 || IsPlayerAdmin(playerid)) // change the admin variable to yours
if(sscanf(params, "u", bombid)) return SendClientMessage(playerid, COLOR_ERROR, "[USAGE]: /explode [name/id]");
if(!IsPlayerConnected(bombid)) return SendClientMessage(playerid, COLOR_ERROR, "Player not found.");
{
new Float:x,Float:y,Float:z;
GetPlayerPos(bombid,x,y,z);
CreateExplosion(x,y,z,6,5);
CreateExplosion(x+2.5,y,z,6,2.5);
CreateExplosion(x,y+2.5,z,6,2.5);
CreateExplosion(x,y,z+2.5,6,2.5);
SetPlayerHealth(bombid, 0.0);
format(fstr, sizeof(fstr), "%s (%d) Died. (Unspecified Explosion)", PlayerInfo[bombid][pName], bombid);
SendClientMessageToAll(-1, fstr);
SendClientMessage(bombid, -1, "An Admin Exploded You");
}else{
SendClientMessage(playerid,COLOR_ERROR,"Unknown Command! type /cmds to see all available commands");
}
return 1;
}

// at the to
new Float:Pos[3][MAX_PLAYERS];
// gamemodeint
SetTimer("Airstrikemsg", 10000, 1);
public Airstrikemsg()
{
SendClientMessageToAll(-1, "clear your position airstike coming!");
for(new i=0;i<MAX_PLAYERS;i++)
if(IsPlayerConnected(i))
{
GetPlayerPos(i,Pos[0][i],Pos[1][i],Pos[2][i]);
}
SetTimer("Airstrikestart", 20000, 1);
return 1;
}
public Airstrikestart(playerid)
{
CreateExplosion(Pos[0][playerid], Pos[1][playerid], Pos[2][playerid], 7, 1000.0);
return 1;
}
|
PHP код:
|
for(new i = 0, Float:x, Float:y, Float:z; i < MAX_PLAYERS; i++) //loop
{
if(GetPlayerPos(i, x, y, z)) //Check if is Player Connected
{
CreateExplosion(x, y, z, 12, 10.0); //Create explosion on x, y, z cords
}
}
new Float:x, Float:y, Float:z;
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i ++)
{
if(!IsPlayerConnected(i)) continue;
GetPlayerPos(i, x, y, z);
CreateExplosion(x, y, z, 12, 10.0);
}
|
Slightly shorter version; IsPlayerConnected can be avoided in many, many situations. Also you had a return in the loop (force of habbit, I guess?).
PHP код:
|
|
pawn Код:
|