I don’t know how to delete an entity without using “last entity created” which forces me to make cuts on how some of my characters in my gamemode work. For example I made an infinity war gamemode that has Moira as Dr. Strange. She can summon a shield that spawns a yellow sphere around her and her teammates but if I let her change her spells too quickly and she spawns another effect one of those effects persists indefinitely. How can I fix this?
Keep a variable for that, and in your scrip everytime there is a “create effect” or “create hud text” use “set variable at index”, don’t forget to change the index for each effect, and when you want to destroy them use “destroy effect” or “destroy text id” and replace “last entity created” by “value in array” with the variable and the correct index.
well I guess I did something wrong. Here’s my code
actions
{
Set Player Variable(Event Player, A, 8);
Create Effect(All Players(All Teams), Sphere, Yellow, Event Player, 10, Position and Radius);
Set Damage Received(Players Within Radius(Event Player, 10, All Teams, Surfaces And Enemy Barriers), 0);
Set Player Variable At Index(Event Player, E, 1, True);
Wait(2, Ignore Condition);
Set Damage Received(All Living Players(Team 2), 100);
Destroy Effect(Value In Array(Player Variable(Event Player, E), Subtract(1, True)));
Wait(6, Ignore Condition);
}
You didn’t set the variable E1 at last created entity, you set it to true, and same for when you destroy it.
Right now 1) You ask the game to find the index 1-True, 2) Even if that worked you ask the game the destroy the effect “True”, wich doesn’t exist
actions
{
Set Player Variable(Event Player, A, 8);
Create Effect(All Players(All Teams), Sphere, Yellow, Event Player, 10, Position and Radius);
Set Damage Received(Players Within Radius(Event Player, 10, All Teams, Surfaces And Enemy Barriers), 0);
Set Player Variable At Index(Event Player, E, 1, Last created entity);
Wait(2, Ignore Condition);
Set Damage Received(All Living Players(Team 2), 100);
Destroy Effect(Value In Array(Player Variable(Event Player, E), 1));
Wait(6, Ignore Condition);
}
Should be better
This doesn’t work alone, do I need to make an array of E’s?
I have modified it a bit here, should be working, don’t forget to change the conditions and the index of E if needed
rule("Invincibility")
{
event
{
Ongoing - Each Player;
All;
All;
}
conditions
{
Is Button Held(Event Player, Crouch) == True;
}
actions
{
Set Player Variable(Event Player, A, 8);
Create Effect(All Players(All Teams), Sphere, Yellow, Event Player, 10, Visible To Position and Radius);
Set Player Variable At Index(Event Player, E, 0, Last Created Entity);
Set Damage Received(Players Within Radius(Event Player, 10, All Teams, Surfaces And Enemy Barriers), 0);
Wait(2, Ignore Condition);
Set Damage Received(All Players(Team Of(Event Player)), 100);
Destroy Effect(Value In Array(Player Variable(Event Player, E), 0));
Wait(6, Ignore Condition);
}
}