Solved Cannot get this to work at all.

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

BrettPlayMC

Supporter
Jan 26, 2017
715
53
28
SkUnity Street
Skript Version (do not put latest): Skript 2.2 (dev36)
Skript Author: Bensku
Minecraft Version: 1.8.8
---
Full Code:
code_language.skript:
function updateCheckerCmd(p: player):
    set {dversion} to "2.1" #parsed as a number
    set {_dv} to line 1 from url "https://api.spigotmc.org/legacy/update.php?resource=25750/"
#    set {_dv} to "%{_dver::1}%" #parsed as a number
    set {dversion} to {dversion} parsed as a number
    set {_dv} to {_dv} parsed as a number
    wait 1 tick
    broadcast "%{_dv}%"
    if {dversion} > {_dv}:
        send "&8[&9&lDISCORD&8] &7Either you're running a beta version or you changed the version number! (&8v&a%{dversion}%&7)" to {_p}
    else if {_dv} = {dversion}:
        send "&8[&9&lDISCORD&8] &7You are currently running the latest version of &a&lDiscord &8v&a%{dversion}%&7." to {_p}
    else if {dversion} < {_dv}:
        send "&8[&9&lDISCORD&8] &7An update is available! (&a%{dversion}% &7-> &a%{_dv}%&7)" to {_p}
        send "&8[&9&lDISCORD&8] &7Download it here: &fhttp://bit.ly/2wsW3IB" to {_p}
    else:
        send "no" to {_p}

Addons using (including versions):
SkRayFall 1.9.10, skUtilities 0.9.2, Vixio 1.1.5

Troubleshooting:

Have you tried searching the docs? Yes
Have you tried searching the forums? No
What other methods have you tried to fix it? I have attempted to reorganize and use different methods such as math (minusing one variable from another then seeing if the outcome is above or below zero) but to no avail to get all 3 working.
 
code_language.skript:
function updateCheckerCmd(p: player):
    set {dversion} to "2.1"
    set {_dv} to line 1 from url "https://api.spigotmc.org/legacy/update.php?resource=25750/"
    set {_v1} to {dversion}
    set {_v2} to {_dv}
    replace all "." in {_v1} with ""
    replace all "." in {_v2} with ""
    wait 1 tick
    if {_v1} parsed as number > {_v2} parsed as number:
        send "&8[&9&lDISCORD&8] &7Either you're running a beta version or you changed the version number! (&8v&a%{dversion}%&7)" to {_p}
    else if {_v1} parsed as number = {_v2} parsed as number:
        send "&8[&9&lDISCORD&8] &7You are currently running the latest version of &a&lDiscord &8v&a%{dversion}%&7." to {_p}
    else if {_v1} parsed as number < {_v2} parsed as number:
        send "&8[&9&lDISCORD&8] &7An update is available! (&a%{dversion}% &7-> &a%{_dv}%&7)" to {_p}
        send "&8[&9&lDISCORD&8] &7Download it here: &fhttp://bit.ly/2wsW3IB" to {_p}
    else:
        send "no" to {_p}
 
Last edited:
  • Like
Reactions: ShaneBee
code_language.skript:
function updateCheckerCmd(p: player):
    set {dversion} to "2.1"
    set {_dv} to line 1 from url "https://api.spigotmc.org/legacy/update.php?resource=25750/"
    set {_v1} to {dversion}
    set {_v2} to {_dv}
    replace all "." in {_v1} with ""
    replace all "." in {_v2} with ""
    wait 1 tick
    broadcast "%{_dv}% %{dversion}% | %{_v1}% %{_v2}%"
    if {_v1} parsed as number > {_v2} parsed as number:
        send "&8[&9&lDISCORD&8] &7Either you're running a beta version or you changed the version number! (&8v&a%{dversion}%&7)" to {_p}
    else if {_v1} parsed as number = {_v2} parsed as number:
        send "&8[&9&lDISCORD&8] &7You are currently running the latest version of &a&lDiscord &8v&a%{dversion}%&7." to {_p}
    else if {_v1} parsed as number < {_v2} parsed as number:
        send "&8[&9&lDISCORD&8] &7An update is available! (&a%{dversion}% &7-> &a%{_dv}%&7)" to {_p}
        send "&8[&9&lDISCORD&8] &7Download it here: &fhttp://bit.ly/2wsW3IB" to {_p}
    else:
        send "no" to {_p}
so glad you figured this out. I racked my brain on this for a while now and just couldn't get it.. Good job
 
code_language.skript:
function updateCheckerCmd(p: player):
    set {dversion} to "2.1"
    set {_dv} to line 1 from url "https://api.spigotmc.org/legacy/update.php?resource=25750/"
    set {_v1} to {dversion}
    set {_v2} to {_dv}
    replace all "." in {_v1} with ""
    replace all "." in {_v2} with ""
    wait 1 tick
    if {_v1} parsed as number > {_v2} parsed as number:
        send "&8[&9&lDISCORD&8] &7Either you're running a beta version or you changed the version number! (&8v&a%{dversion}%&7)" to {_p}
    else if {_v1} parsed as number = {_v2} parsed as number:
        send "&8[&9&lDISCORD&8] &7You are currently running the latest version of &a&lDiscord &8v&a%{dversion}%&7." to {_p}
    else if {_v1} parsed as number < {_v2} parsed as number:
        send "&8[&9&lDISCORD&8] &7An update is available! (&a%{dversion}% &7-> &a%{_dv}%&7)" to {_p}
        send "&8[&9&lDISCORD&8] &7Download it here: &fhttp://bit.ly/2wsW3IB" to {_p}
    else:
        send "no" to {_p}
O damn you're a legend.

The only problem I have found is that when you set {dversion} to a version higher than 2.2.5, it still says an update is needed.
 
code_language.skript:
function updateCheckerCmd(p: player):
    set {dversion} to "3.0"
    set {_dv} to line 1 from url "https://api.spigotmc.org/legacy/update.php?resource=25750/"
    set {_v1} to {dversion}
    set {_v2} to {_dv}
    if length of {_v1} is 3:
        set {_v1} to "%{_v1}%.0.0"
    else if length of {_v1} is 5:
        set {_v1} to "%{_v1}%.0"
    if length of {_v2} is 3:
        set {_v2} to "%{_v2}%.0.0"
    else if length of {_v2} is 5:
        set {_v2} to "%{_v2}%.0"
    replace all "." in {_v1} with ""
    replace all "." in {_v2} with ""
    wait 1 tick
    broadcast "%{_dv}% %{dversion}% | %{_v1}% %{_v2}%"
    if {_v1} parsed as number > {_v2} parsed as number:
        send "&8[&9&lDISCORD&8] &7Either you're running a beta version or you changed the version number! (&8v&a%{dversion}%&7)" to {_p}
    else if {_v1} parsed as number = {_v2} parsed as number:
        send "&8[&9&lDISCORD&8] &7You are currently running the latest version of &a&lDiscord &8v&a%{dversion}%&7." to {_p}
    else if {_v1} parsed as number < {_v2} parsed as number:
        send "&8[&9&lDISCORD&8] &7An update is available! (&a%{dversion}% &7-> &a%{_dv}%&7)" to {_p}
        send "&8[&9&lDISCORD&8] &7Download it here: &fhttp://bit.ly/2wsW3IB" to {_p}
    else:
        send "no" to {_p}
 
code_language.skript:
function updateCheckerCmd(p: player):
    set {dversion} to "3.0"
    set {_dv} to line 1 from url "https://api.spigotmc.org/legacy/update.php?resource=25750/"
    set {_v1} to {dversion}
    set {_v2} to {_dv}
    if length of {_v1} is 3:
        set {_v1} to "%{_v1}%.0.0"
    else if length of {_v1} is 5:
        set {_v1} to "%{_v1}%.0"
    if length of {_v2} is 3:
        set {_v2} to "%{_v2}%.0.0"
    else if length of {_v2} is 5:
        set {_v2} to "%{_v2}%.0"
    replace all "." in {_v1} with ""
    replace all "." in {_v2} with ""
    wait 1 tick
    broadcast "%{_dv}% %{dversion}% | %{_v1}% %{_v2}%"
    if {_v1} parsed as number > {_v2} parsed as number:
        send "&8[&9&lDISCORD&8] &7Either you're running a beta version or you changed the version number! (&8v&a%{dversion}%&7)" to {_p}
    else if {_v1} parsed as number = {_v2} parsed as number:
        send "&8[&9&lDISCORD&8] &7You are currently running the latest version of &a&lDiscord &8v&a%{dversion}%&7." to {_p}
    else if {_v1} parsed as number < {_v2} parsed as number:
        send "&8[&9&lDISCORD&8] &7An update is available! (&a%{dversion}% &7-> &a%{_dv}%&7)" to {_p}
        send "&8[&9&lDISCORD&8] &7Download it here: &fhttp://bit.ly/2wsW3IB" to {_p}
    else:
        send "no" to {_p}
Amazing! Thanks so much! Been trying to get it to work for hours. xD
 
No problem..
[doublepost=1529059660,1529008762][/doublepost]@BrettPlayMC I could not sleep because i have knowen that code which i posted is not working properly when version type is like "x.xx".. so i made new one.. this should work better but it doesnt support versions like "x-devxx" or "x-alphax".. just versions with more numbers and its for 4 builds:
Major, Minor, Build and Revision... here is your code:

code_language.skript:
command /test:
    trigger:
        updateCheckerCmd(player)
     
function updateCheckerCmd(p: player):
    set {dversion} to "2.2.5"
    set {_dv} to line 1 from url "https://api.spigotmc.org/legacy/update.php?resource=25750/"
    set {_v1::*} to split "%{dversion}%" by "."
    set {_v2::*} to split "%{_dv}%" by "."
    loop {_v1::*}:
        if "%loop-index% " is "1 ":
            set {_v1.major} to loop-value parsed as number
        if "%loop-index% " is "2 ":
            set {_v1.minor} to loop-value parsed as number
        if "%loop-index% " is "3 ":
            set {_v1.build} to loop-value parsed as number
        if "%loop-index% " is "4 ":
            set {_v1.revision} to loop-value parsed as number
    loop {_v2::*}:
        if "%loop-index% " is "1 ":
            set {_v2.major} to loop-value parsed as number
        if "%loop-index% " is "2 ":
            set {_v2.minor} to loop-value parsed as number
        if "%loop-index% " is "3 ":
            set {_v2.build} to loop-value parsed as number
        if "%loop-index% " is "4 ":
            set {_v2.revision} to loop-value parsed as number
 
    if {_v1.revision} > {_v2.revision}:
        set {_check.revision} to "beta"
    else if {_v1.revision} = {_v2.revision}:
        set {_check.revision} to "ok"
    else if {_v1.revision} < {_v2.revision}:
        set {_check.revision} to "old"
     
    if {_v1.build} > {_v2.build}:
        set {_check.build} to "beta"
    else if {_v1.build} = {_v2.build}:
        set {_check.build} to "ok"
    else if {_v1.build} < {_v2.build}:
        set {_check.build} to "old"
     
    if {_v1.minor} > {_v2.minor}:
        set {_check.minor} to "beta"
    else if {_v1.minor} = {_v2.minor}:
        set {_check.minor} to "ok"
    else if {_v1.minor} < {_v2.minor}:
        set {_check.minor} to "old"
 
    if {_v1.major} > {_v2.major}:
        set {_check.major} to "beta"
    else if {_v1.major} = {_v2.major}:
        set {_check.major} to "ok"
    else if {_v1.major} < {_v2.major}:
        set {_check.major} to "old"
 
    if {_check.major} is "beta":
        set {_check.global} to "beta"
    else if {_check.major} is "old":
        set {_check.global} to "old"
    else if {_check.major} is "ok":
        set {_check.global} to "ok"
        if {_check.minor} is "beta":
            set {_check.global} to "beta"
        else if {_check.minor} is "old":
            set {_check.global} to "old"
        else if {_check.minor} is "ok":
            set {_check.global} to "ok"
            if {_check.build} is "beta":
                set {_check.global} to "beta"
            else if {_check.build} is "old":
                set {_check.global} to "old"
            else if {_check.build} is "ok":
                set {_check.global} to "ok"
                if {_check.revision} is "beta":
                    set {_check.global} to "beta"
                else if {_check.revision} is "old":
                    set {_check.global} to "old"
                else if {_check.revision} is "ok":
                    set {_check.global} to "ok"
 
    if {_check.global} is "beta":
        send "&8[&9&lDISCORD&8] &7Either you're running a beta version or you changed the version number! (&8v&a%{dversion}%&7)" to {_p}
    else if {_check.global} is "ok":
        send "&8[&9&lDISCORD&8] &7You are currently running the latest version of &a&lDiscord &8v&a%{dversion}%&7." to {_p}
    else if {_check.global} is "old":
        send "&8[&9&lDISCORD&8] &7An update is available! (&a%{dversion}% &7-> &a%{_dv}%&7)" to {_p}
        send "&8[&9&lDISCORD&8] &7Download it here: &fhttp://bit.ly/2wsW3IB" to {_p}
    else:
        send "no" to {_p}
 
Last edited:
Status
Not open for further replies.