Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the 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.
Post Reply
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: 25

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

Post Reply