1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using variables from function return

Discussion in 'Skript' started by Black_Eyes, Apr 22, 2017.

Thread Status:
Not open for further replies.
  1. Black_Eyes

    Black_Eyes Member

    Joined:
    Mar 4, 2017
    Messages:
    20
    Likes Received:
    3
    I would like to stop the skript if a permission is negative, but I don't know how to check a value from a function return :emoji_frowning:
    Her's the code, the real code is more complicated, but I let only the important things, to let you understand it. That's why you could thing that I don't have to use functions for that
    Code (Skript):
    1. function NoPerm(perm: text, p: player) :: text:
    2.    {_p} does not have permission {_perm}:
    3.        set {_message} to "you don't have permission %{_perm}%"
    4.        message coloured {_message} to {_p}
    5.        return {_message}
    6.  
    7. command /tp [<player>]:
    8.    aliases: /tele, /tp2p, /teleport
    9.    trigger:
    10.        NoPerm("essentials.tp", sender)
    11.       {_message} is set:
    12.            stop
    13.       teleport player to arg 1
    It doesn't work, of wourse, but I don't know why^^
     
    #1 Black_Eyes, Apr 22, 2017
    Last edited: Apr 22, 2017
  2. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,172
    Likes Received:
    190
    I already helped him on the Skript-chat Discord but I'll write the solution here anyways.

    You just have to save the returned value of the function in a variable or check it directly:
    Code (Skript):
    1. if NoPerm("essentials.tp", sender) is set:
    Or:
    Code (Skript):
    1. set {_message} to NoPerm("essentials.tp", sender)
    2. If {_message} is set:
    Will work.
     
Thread Status:
Not open for further replies.
Loading...