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.

I forgot how to read a website in skript

Discussion in 'Skript' started by Deleted member, Jun 16, 2017.

Thread Status:
Not open for further replies.
  1. I remember a few months ago I used a method to read html from a site, and set it to a variable in game. But I can't remember what it is, can anyone help?
     
  2. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,168
    Likes Received:
    172
  3. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,168
    Likes Received:
    172
    That's not what I used to use, but I will try it. Thank you.
    --- Double Post Merged, Jun 16, 2017, Original Post Date: Jun 16, 2017 ---
    Could you maybe explain, how to copy the text from https://api.namemc.com/server/mc.duffcraft.net/likes?profile=19e8913f-e6db-430d-9c92-d86c3ec0a68d to a variable? If not, that's fine. If you do, thanks :emoji_grinning:!
     
  4. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,168
    Likes Received:
    172
    Code (Skript):
    1. send request to "https://api.namemc.com/server/mc.duffcraft.net/likes?profile=%UUID OF PLAYER%"
    2. set {_body} to the last received http web response's body
    3. wait 1 tick
    4. map the json of {_body} to variable {_isittrueorfalse::*}
    5. loop {_isittrueorfalse::*}:
    6.   if loop-value = true:
    7.     set {_itstrue} to true
    8. if {_itstrue} is set:
    9.   #dostuff (you checked and it's true, now implement what you want to do with it.)
     
  5. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,168
    Likes Received:
    172
    you don't have to map it on a variable such as it is a plain text response, not a JSON one. so, from the start to the {_body} variable it is fine.
     
  6. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,168
    Likes Received:
    172
    Well, in this case, yes, but I'm explaining to him how to use both reqn and skript-json.
     
    • Like Like x 1
  7. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,168
    Likes Received:
    172
    I've tested it, it doesn't seem to work. I added an "else if" and it says no every time.


    Code (Skript):
    1. command /test:
    2.     trigger:
    3.         send request to "https://api.namemc.com/server/mc.duffcraft.net/likes?profile=%player's uuid%"
    4.         set {_body} to the last received http web response's body
    5.         wait 1 tick
    6.         map the json of {_body} to variable {_isittrueorfalse::*}
    7.         broadcast "&e%{_isittrueorfalse::*}%"
    8.         loop {_isittrueorfalse::*}:
    9.             if loop-value is "true":
    10.                 set {_itstrue} to true
    11.         if {_itstrue} is set:
    12.             broadcast "Yes"
    13.             stop
    14.         broadcast "no"
    15.        
    --- Double Post Merged, Jun 16, 2017, Original Post Date: Jun 16, 2017 ---
    Thank you both for your help. Looks like the _body variable is all I need.
     
  8. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,168
    Likes Received:
    172
    Code (Skript):
    1. command /test:
    2.     trigger:
    3.         send request to "https://api.namemc.com/server/mc.duffcraft.net/likes?profile=%player's uuid%"
    4.         set {_body} to the last received http web response's body
    5.         broadcast "%{_body}%"
    6.        
    Do this first.
     
  9. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,168
    Likes Received:
    172
    Okay so {_body} works, but after that it does nothing. So after the broadcast it does nothing.
    --- Double Post Merged, Jun 16, 2017, Original Post Date: Jun 16, 2017 ---
    I've done some testing, it doesn't loop like its supposed to
     
  10. ShaneBee

    Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,168
    Likes Received:
    172
    Now just use {_body} to check if it's true.
     
Thread Status:
Not open for further replies.
Loading...