Stop a function from running its next code if variable is true

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

TACStudios

Member
Apr 21, 2025
10
0
1
This may sounds straight forward but it isnt. I have a function that runs to play a round of a game out, however I want to immediately stop that function from running any further code if there is only 1 player left. I dont want to add "if"'s to like EVERY line of code (considering there are "wait" lines and that so time would still have to pass before a check is ran)Are there ANY ways of doings this, or maybe something I can change the function to to allow for this
 
would it work to nest everything into other functions which then have tests for if the game has started?
like
Code:
command /startpvs:
    permission: op
    trigger:
        if {pvsGameStarted} is true:
            startPvSpleef()
local function startPvSpleef():
    if {pvsGameStarted} is false:
        send "&cGame hasn't started yet!" to all players
        stop
    else:
        #logic stuff that i dont feel like doing at 2 am
 
would it work to nest everything into other functions which then have tests for if the game has started?
Yes and no, it would work but isn’t the effect I was going for since with this, the code would have to wait for one of (frankly too long) wait for lines to finish before doing another check, whereas I want to end the game as soon as the game started Variable is false
 
so just do
Code:
on server tick start:
    if {pvsGameStarted} is false:
        stop
    else:
        #other stuff