I want to make a run with stamina

rule(“run”)
{
event
{
Ongoing - Each Player;
All;
All;
}

condition
{
	Is Button Held(Event Player, Button(ABILITY 1)) == True;
	Is Moving(Event Player) == True;
	Event Player.AA > 0;
}

action
{ 
	Set Move Speed(Event Player, 150);
	Wait(1, Ignore Condition);
		Small Message(Event Player, Custom String("ㅇㅅㅇ{0}", Hero Icon String(Hero Of(Event Player))));	
		Wait(3, Ignore Condition);
	    Event Player.AA -= 20.000;
	    Wait(2, Ignore Condition);
		Loop If Condition Is True;
}

}
rule(“run stop”)
{
event
{
Ongoing - Each Player;
All;
All;
}

condition
{
	Is Button Held(Event Player, Button(ABILITY 1)) != True;
}

action
{ 
	Set Move Speed(Event Player, 100);
}

}
rule(“Event Player.AA=stamina hungry”)
{
event
{
Ongoing - Each Player;
All;
All;
}

condition
{
	Is Button Held(Event Player, Button(ABILITY 1)) == True;
	Is Moving(Event Player) == True;
	Event Player.AA < 0;
}

action
{  
    Set Move Speed(Event Player, 100);
	Start Damage Over Time(Event Player, Null, 10, 5);
    Small Message(Event Player, Custom String("ㅠㅠ...{0}", Hero Icon String(Hero Of(Event Player))));
	Wait(1, Ignore Condition);
}

}

The server is overloaded. I’m a beginner at a workshop. Tell me what’s wrong.

I’m not sure what’s causing your server to overload, but there’s likely an infinite loop happening somewhere. I’ve rewritten your code to make smooth decrease in stamina using the “chase variable” function. I also added functionality to make your stamina increase after a certain amount of time not used, very similar to how Pharah’s booster works. Feel free to remove that if that’s not how you want to implement it. This should not overload the server. If you need help or if the code doesn’t work, feel free to let me know. You also have to change {RATE} to a value that you like. This value determines how fast stamina depletes and regens, so you should play around with it until you get a value you like. I think a value of 100 would deplete all the stamina in one second, so that’s a good reference point for you.

rule("run")
{
    event
    {
        Ongoing - Each Player;
        All;
        All;
    }

    conditions
    {
        Is Button Held(Event Player, Button(Ability 1)) == true;
        Is Moving(Event Player) == True;
        Event Player.AA > 0;
    }

    actions
    {
        Set Move Speed(Event Player, 150);
        Stop Chasing Player Variable(Event Player, AA);
        Chase Player Variable At Rate(Event Player, AA, 0, {RATE}, Destination and Rate);
    }
}

rule("run stop")
{
    event
    {
        Ongoing - Each Player;
        All;
        All;
    }

    conditions
    {
        (Is Button Held(Event Player, Button(Ability 1)) != true) || (Is Moving(Event Player) != true) == true;
    }

    actions
    {
        Set Move Speed(Event Player, 100);
        Stop Chasing Player Variable(Event Player, AA);

        Wait(5, Abort When False);
        Chase Player Variable At Rate(Event Player, AA, 100, {RATE}, Destination and Rate);
    }
}

rule("stamina hungry")
{
    event
    {
        Ongoing - Each Player;
        All;
        All;
    }

    conditions
    {
        Is Button Held(Event Player, Button(Ability 1)) == true;
        Is Moving(Event Player) == True;
        Event Player.AA < 0;
    }

    actions
    {
        Set Move Speed(Event Player, 100);
        Stop Chasing Player Variable(Event Player, AA);
        Start Damage Over Time(Event Player, Null, 10, 5);
    }
}
1 Like

Can I ask you another question?

Yeah, of course. What else do you need help with?

If I’m making a king, how do I reset the global variable when the king left match?
The king possible for only one person.

Global.President = 1;

1 = king exists
0 = king does not exist

Player Left Match; I tried this and it didn’t work.
help me plz ㅠ.ㅠ

One thing you could do is: instead of setting Global.President to true/false, you can set it equal to the Player of whoever the king is (like Global.President = Event Player), and then you can have a rule which checks when player leaves a match and you should be able to check if Event Player == Global.President (Event Player should be whoever just left the match)