Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Yankee on Jun 12, 2017, 12:11 PM

Title: Create Explosion With Players
Post by: Yankee on Jun 12, 2017, 12:11 PM
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 )
Title: Re: Create Explosion With Players
Post by: NicusorN5 on Jun 12, 2017, 07:18 PM
for(local i = 0 ; i < 100; i++)
{
 try
 {
  CreateExplosion(0,1,FindPlayer(i).Pos,-1,true) //not tested
 }
catch(e)
 {
 }
}
Title: Re: Create Explosion With Players
Post by: EK.IceFlake on Jun 12, 2017, 07:26 PM
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
    }
}
Title: Re: Create Explosion With Players
Post by: 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
    }
}
Title: Re: Create Explosion With Players
Post by: KAKAN on Jun 13, 2017, 07:09 AM
i is not defined.
He wants to create an explosion for each player, not 100 explosions for one player. So, a loop is needed
Title: Re: Create Explosion With Players
Post by: aXXo on Jun 14, 2017, 09:20 PM
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.
Title: Re: Create Explosion With Players
Post by: kennedyarz on Jun 14, 2017, 11:59 PM
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);
}
}
}