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 )
for(local i = 0 ; i < 100; i++)
{
try
{
CreateExplosion(0,1,FindPlayer(i).Pos,-1,true) //not tested
}
catch(e)
{
}
}
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
}
}
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
}
}
i is not defined.
He wants to create an explosion for each player, not 100 explosions for one player. So, a loop is needed
Quote from: ysc3839 on Jun 13, 2017, 01:10 AMQuote 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.
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);
}
}
}