I forgot how to read a website in skript

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

Status
Not open for further replies.
D

Deleted member

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?
 
code_language.skript:
send request to "https://api.namemc.com/server/mc.duffcraft.net/likes?profile=%UUID OF PLAYER%"
set {_body} to the last received http web response's body
wait 1 tick
map the json of {_body} to variable {_isittrueorfalse::*}
loop {_isittrueorfalse::*}:
  if loop-value = true:
    set {_itstrue} to true
if {_itstrue} is set:
  #dostuff (you checked and it's true, now implement what you want to do with it.)
 
code_language.skript:
send request to "https://api.namemc.com/server/mc.duffcraft.net/likes?profile=%UUID OF PLAYER%"
set {_body} to the last received http web response's body
wait 1 tick
map the json of {_body} to variable {_isittrueorfalse::*}
loop {_isittrueorfalse::*}:
  if loop-value = true:
    set {_itstrue} to true
if {_itstrue} is set:
  #dostuff (you checked and it's true, now implement what you want to do with it.)
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.
 
code_language.skript:
send request to "https://api.namemc.com/server/mc.duffcraft.net/likes?profile=%UUID OF PLAYER%"
set {_body} to the last received http web response's body
wait 1 tick
map the json of {_body} to variable {_isittrueorfalse::*}
loop {_isittrueorfalse::*}:
  if loop-value = true:
    set {_itstrue} to true
if {_itstrue} is set:
  #dostuff (you checked and it's true, now implement what you want to do with it.)
I've tested it, it doesn't seem to work. I added an "else if" and it says no every time.


code_language.skript:
command /test:
    trigger:
        send request to "https://api.namemc.com/server/mc.duffcraft.net/likes?profile=%player's uuid%"
        set {_body} to the last received http web response's body
        wait 1 tick
        map the json of {_body} to variable {_isittrueorfalse::*}
        broadcast "&e%{_isittrueorfalse::*}%"
        loop {_isittrueorfalse::*}:
            if loop-value is "true":
                set {_itstrue} to true
        if {_itstrue} is set:
            broadcast "Yes"
            stop
        broadcast "no"
[doublepost=1497650784,1497650656][/doublepost]
Well, in this case, yes, but I'm explaining to him how to use both reqn and skript-json.
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.
Thank you both for your help. Looks like the _body variable is all I need.
 
code_language.skript:
command /test:
    trigger:
        send request to "https://api.namemc.com/server/mc.duffcraft.net/likes?profile=%player's uuid%"
        set {_body} to the last received http web response's body
        broadcast "%{_body}%"

Do this first.
 
code_language.skript:
command /test:
    trigger:
        send request to "https://api.namemc.com/server/mc.duffcraft.net/likes?profile=%player's uuid%"
        set {_body} to the last received http web response's body
        broadcast "%{_body}%"

Do this first.
Okay so {_body} works, but after that it does nothing. So after the broadcast it does nothing.
[doublepost=1497652237,1497651880][/doublepost]
code_language.skript:
command /test:
    trigger:
        send request to "https://api.namemc.com/server/mc.duffcraft.net/likes?profile=%player's uuid%"
        set {_body} to the last received http web response's body
        broadcast "%{_body}%"

Do this first.
I've done some testing, it doesn't loop like its supposed to
 
Status
Not open for further replies.