This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk

Forum rules

Any possible way to make a function on a script run once?

Here you can find answered ScriptAPI topics.
Forum rules
By using the forum you agree to the following rules.
Locked
User avatar
Ol1vver
Superfighter
Superfighter
Posts: 69
Joined: Mon Nov 19, 2018 4:55 pm
SFD Account: olv
SFD Alias: olv
Started SFD: PreAlpha 1.6.4
Gender:

Any possible way to make a function on a script run once?

Post by Ol1vver » Tue Jan 01, 2019 5:02 pm

Hello,
I have a script that checks for the player's actions.
I want to make every action run only once, but instead it runs twice or more. (depends on what time you set to the timertrigger as we all know)
Something like this:

Code: Select all

public void CheckPlayers(TriggerArgs args)
{
	foreach(IPlayer ply in Game.GetPlayers())
	{
		if(ply.IsWalking && ply.IsBlocking(RunOnce1))
		{
			ply.Gib();
		}
		if(ply.IsIdle)
		{
			RunOnce1.Reset();
		}
	}
}
Basically something like script sleeping.

If you didn't understand something, PM me or reply to this post.
0 x

User avatar
pillers
Meatbag
Posts: 7
Joined: Sun Dec 02, 2018 10:11 am
Title: Deluxe Superfighter
Age: 27

Post by pillers » Wed Jan 23, 2019 11:58 am

Don't use a TimerTrigger instead use a DoOnce Trigger. It looks something like this and can be found under the Markers Drop down menu.

Image

set your Script Method to CheckPlayers and it should runs only once
0 x

Code: Select all

while true

Locked