Create Explosion With Players

Started by Yankee, Jun 12, 2017, 12:11 PM

Previous topic - Next topic

Yankee

Hi guys,it is a very simple question.How I change this code ?I want to explode players with this code like /playerid player.Pos buuum :)

CreateExplosion( world, type, pos, playerCaused, onGround )

NicusorN5

for(local i = 0 ; i < 100; i++)
{
 try
 {
  CreateExplosion(0,1,FindPlayer(i).Pos,-1,true) //not tested
 }
catch(e)
 {
 }
}

EK.IceFlake

Try? What?

for (local i = 0; i < 100; ++i)
{
    local player = FindPlayer(i);
    if (player != null)
    {
        CreateExplosion(0, 1, player.Pos, -1, true); // not tested
    }
}

ysc3839

Quote from: EK.IceFlake on Jun 12, 2017, 07:26 PMTry? What?

for (local i = 0; i < 100; ++i)
{
    local player = FindPlayer(i);
    if (player != null)
    {
        CreateExplosion(0, 1, player.Pos, -1, true); // not tested
    }
}
Move 'FindPlayer' out of the 'for'. This code will find player for 100 times, which slows down the server.
local player = FindPlayer(i);
if (player != null)
{
    for (local i = 0; i < 100; ++i)
    {
        CreateExplosion(0, 1, player.Pos, -1, true); // not tested
    }
}

KAKAN

i is not defined.
He wants to create an explosion for each player, not 100 explosions for one player. So, a loop is needed
oh no

aXXo

Quote from: ysc3839 on Jun 13, 2017, 01:10 AM
Quote from: EK.IceFlake on Jun 12, 2017, 07:26 PMTry? What?

for (local i = 0; i < 100; ++i)
{
    local player = FindPlayer(i);
    if (player != null)
    {
        CreateExplosion(0, 1, player.Pos, -1, true); // not tested
    }
}
Move 'FindPlayer' out of the 'for'. This code will find player for 100 times, which slows down the server.
local player = FindPlayer(i);
if (player != null)
{
    for (local i = 0; i < 100; ++i)
    {
        CreateExplosion(0, 1, player.Pos, -1, true); // not tested
    }
}
Why would he want to blow every player on the server? <omit islam joke>
He's obviously asking for multiple explosion at a player's loc.

kennedyarz

#6
else if (cmd == "plox")
{
if (!text) MessagePlayer("[#FF3636] Error - Correct syntax - /" + cmd + " <Name/ID>' !", player);
else
{
local plr = FindPlayer(text);
if (!plr) MessagePlayer("[#FF3636] Error - player no exist!", player);
else
{
 CreateExplosion(plr.World, 1, plr.Pos, -1, true);
}
}
}