Using variables from function return

  • 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 community!

    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!

Status
Not open for further replies.

Black_Eyes

Member
Mar 4, 2017
19
3
0
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_language.skript:
function NoPerm(perm: text, p: player) :: text:
   {_p} does not have permission {_perm}:
       set {_message} to "you don't have permission %{_perm}%"
       message coloured {_message} to {_p}
       return {_message}

command /tp [<player>]:
   aliases: /tele, /tp2p, /teleport
   trigger:
       NoPerm("essentials.tp", sender)
      {_message} is set:
           stop
      teleport player to arg 1
It doesn't work, of wourse, but I don't know why^^
 
Last edited:
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_language.skript:
if NoPerm("essentials.tp", sender) is set:
Or:
code_language.skript:
set {_message} to NoPerm("essentials.tp", sender)
If {_message} is set:
Will work.
 
Status
Not open for further replies.