Solved Problem with add 1 to {variable}

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

WorldMoney

Member
Mar 29, 2020
14
0
0
23
Hello, i have a problem with my Script. I have a german Script because im german and here's a problem. The add 1 to {variable} doesent work. Here's the Skript:

Code:
options:

        #Hier kannst du alles ändern
    SPIELMODUSNAME: &e&lAmpelrennen
    
        #Messages:
    
    KEINERECHTE: &cSorry du hast dafür keine Rechte!
    
    JOINMESSAGE: &6Du bist dem Spiel beigetreten
    
    LOBBYSETSPAWNMESSAGE: &6Der Lobby Spawnpunkt wurde erfolgreich gesetzt.
    
    ZIELSETSPAWNMESSAGE: &6Der Ziel Spawnpunkt wurde erfolgreich gesetzt.
    
    STARTSETSPAWNMESSAGE: &6Der Start Spawnpunkt wurde erfolgreich gesetzt.
    
    LEAVESETSPAWNMESSAGE: &6Du bist aus dem Spiel gegangen.
    
    LEAVEMESSAGE: &6Du bist aus dem Spiel gegangen.
    
    BEREITSIMSPIELMESSAGE: &6Du bist bereits im Spiel!
    
    INKEINSPIELERRORMESSAGE: &6Du bist momentan in keinen Spiel!
    
    #Hier darfst du nichts ändern!
    
command /ampelrennen [<text>] [<text>] [<string>]:
    trigger:
        if arg 1 is not set:
            send "-------------------------" to player
            send "&4&lCommands             " to player
            send "&6&l/ampelrennen <join,leave,admin,setspawn>" to player
            send "-------------------------" to player
        if arg 1 is "admin":
            if player has permission "ampel.admin":
                send "------------------------------------" to player
                send "&4Admin &lCommands " to player
                send "&6&l/ampelrennen setspawn <start,finish,lobby,leavepunkt>" to player
                send "&6&l/ampelrennen start" to player
                send "&6&l/ampelrennen stop" to player
                send "------------------------------------"
            else:
                send "{@KEINERECHTE}"
        if arg 1 is "setspawn":
            if arg 2 is not set:
                send "{@SPIELMODUSNAME} &6Bitte setze eine Syntax! /ampelrennen setspawn <start,finish,lobby,leavepunkt>" to player
            if player has permission "ampel.admin":
                if arg 2 is "start":
                    set {spawn.start} to location of player
                    send "{@SPIELMODUSNAME} {@STARTSETSPAWNMESSAGE}" to player
                if arg 2 is "finish":
                    set {spawn.finish} to location of player
                    send "{@SPIELMODUSNAME} {@ZIELSETSPAWNMESSAGE}" to player
                if arg 2 is "lobby":
                    set {spawn.lobby} to location of player
                    send "{@SPIELMODUSNAME} {@LOBBYSETSPAWNMESSAGE}" to player
                    send "{@SPIELMODUSNAME} &6Man wird nach dem Spiel immer wieder zu diesem Spawnpunkt teleportiert." to player
                if arg 2 is "leavepunkt":
                    set {spawn.leave} to location of player
                    send "{@SPIELMODUSNAME} {@LEAVESETSPAWNMESSAGE}" to player
                    send "{@SPIELMODUSNAME} &6Man wird, wenn man mit /ampelrennen leave aus dem Spiel geht, zu diesem Spawnpunkt teleportiert." to player
            else:
                send "{@KEINERECHTE}" to player
        if arg 1 is "join":
            if {join.%player%} is "0":
                set {join.%player%} to "1"
                teleport player to {spawn.lobby}
                add 1 to {count.player.ampelrennen}
                send "{@JOINMESSAGE}" to player
            else if {join.%player%} is "1":
                send "{@BEREITSIMSPIELMESSAGE}" to player
        if arg 1 is "leave":
            if {join.%player%} is "1":
                remove 1 from {count.player.ampelrennen}
                set {join.%player%} to "0"
                teleport player to {spawn.leave}
                send "{@LEAVEMESSAGE}" to player
            else if {join.%player%} is "0":
                send "{@INKEINSPIELERRORMESSAGE}"



right click on sign:
    if line 1 is "join":
        if line 2 is "join ampelrennen":
            execute player command "ampelrennen join"




on join:
    if {join.%player%} is not set:
        set {join.%player%} to "0"

on quit:
    if {join.%player%} is "1":
        teleport player to {spawn.leave}
        remove 1 from {count.player.ampelrennen}
        set {join.%player%} to "0"
            

            #STRINGS TEST
            
command /spawnstart:
    trigger:
        teleport player to {spawn.start}

command /spawnfinish:
    trigger:
        teleport player to {spawn.finish}

command /spawnlobby:
    trigger:
        teleport player to {spawn.lobby}
        
command /countplayers:
    trigger:
        send "%{count.player.ampelrennen}%"
        
command /joinplayer:
    trigger:
        send "%{join.%player%}%" to player
        
            #WERBUNG
            
on load:
    send "---------------------------" to console
    send "Dieses Plugin wurde von WorldMoney gecodet!" to console
    send "Dieses Plugin befindet sich in der BETA!" to console
    send "---------------------------" to console

On "add 1 to {count.player.ampelrennen}" has a problem. If i make the Cmd /ampelrennen join in Minecraft, then all works but if i test with /countplayers how many Players are in the Game, then theres 0 Player. Can any one help ?
 
Hello, i have a problem with my Script. I have a german Script because im german and here's a problem. The add 1 to {variable} doesent work. Here's the Skript:

Code:
options:

        #Hier kannst du alles ändern
    SPIELMODUSNAME: &e&lAmpelrennen
   
        #Messages:
   
    KEINERECHTE: &cSorry du hast dafür keine Rechte!
   
    JOINMESSAGE: &6Du bist dem Spiel beigetreten
   
    LOBBYSETSPAWNMESSAGE: &6Der Lobby Spawnpunkt wurde erfolgreich gesetzt.
   
    ZIELSETSPAWNMESSAGE: &6Der Ziel Spawnpunkt wurde erfolgreich gesetzt.
   
    STARTSETSPAWNMESSAGE: &6Der Start Spawnpunkt wurde erfolgreich gesetzt.
   
    LEAVESETSPAWNMESSAGE: &6Du bist aus dem Spiel gegangen.
   
    LEAVEMESSAGE: &6Du bist aus dem Spiel gegangen.
   
    BEREITSIMSPIELMESSAGE: &6Du bist bereits im Spiel!
   
    INKEINSPIELERRORMESSAGE: &6Du bist momentan in keinen Spiel!
   
    #Hier darfst du nichts ändern!
   
command /ampelrennen [<text>] [<text>] [<string>]:
    trigger:
        if arg 1 is not set:
            send "-------------------------" to player
            send "&4&lCommands             " to player
            send "&6&l/ampelrennen <join,leave,admin,setspawn>" to player
            send "-------------------------" to player
        if arg 1 is "admin":
            if player has permission "ampel.admin":
                send "------------------------------------" to player
                send "&4Admin &lCommands " to player
                send "&6&l/ampelrennen setspawn <start,finish,lobby,leavepunkt>" to player
                send "&6&l/ampelrennen start" to player
                send "&6&l/ampelrennen stop" to player
                send "------------------------------------"
            else:
                send "{@KEINERECHTE}"
        if arg 1 is "setspawn":
            if arg 2 is not set:
                send "{@SPIELMODUSNAME} &6Bitte setze eine Syntax! /ampelrennen setspawn <start,finish,lobby,leavepunkt>" to player
            if player has permission "ampel.admin":
                if arg 2 is "start":
                    set {spawn.start} to location of player
                    send "{@SPIELMODUSNAME} {@STARTSETSPAWNMESSAGE}" to player
                if arg 2 is "finish":
                    set {spawn.finish} to location of player
                    send "{@SPIELMODUSNAME} {@ZIELSETSPAWNMESSAGE}" to player
                if arg 2 is "lobby":
                    set {spawn.lobby} to location of player
                    send "{@SPIELMODUSNAME} {@LOBBYSETSPAWNMESSAGE}" to player
                    send "{@SPIELMODUSNAME} &6Man wird nach dem Spiel immer wieder zu diesem Spawnpunkt teleportiert." to player
                if arg 2 is "leavepunkt":
                    set {spawn.leave} to location of player
                    send "{@SPIELMODUSNAME} {@LEAVESETSPAWNMESSAGE}" to player
                    send "{@SPIELMODUSNAME} &6Man wird, wenn man mit /ampelrennen leave aus dem Spiel geht, zu diesem Spawnpunkt teleportiert." to player
            else:
                send "{@KEINERECHTE}" to player
        if arg 1 is "join":
            if {join.%player%} is "0":
                set {join.%player%} to "1"
                teleport player to {spawn.lobby}
                add 1 to {count.player.ampelrennen}
                send "{@JOINMESSAGE}" to player
            else if {join.%player%} is "1":
                send "{@BEREITSIMSPIELMESSAGE}" to player
        if arg 1 is "leave":
            if {join.%player%} is "1":
                remove 1 from {count.player.ampelrennen}
                set {join.%player%} to "0"
                teleport player to {spawn.leave}
                send "{@LEAVEMESSAGE}" to player
            else if {join.%player%} is "0":
                send "{@INKEINSPIELERRORMESSAGE}"



right click on sign:
    if line 1 is "join":
        if line 2 is "join ampelrennen":
            execute player command "ampelrennen join"




on join:
    if {join.%player%} is not set:
        set {join.%player%} to "0"

on quit:
    if {join.%player%} is "1":
        teleport player to {spawn.leave}
        remove 1 from {count.player.ampelrennen}
        set {join.%player%} to "0"
           

            #STRINGS TEST
           
command /spawnstart:
    trigger:
        teleport player to {spawn.start}

command /spawnfinish:
    trigger:
        teleport player to {spawn.finish}

command /spawnlobby:
    trigger:
        teleport player to {spawn.lobby}
       
command /countplayers:
    trigger:
        send "%{count.player.ampelrennen}%"
       
command /joinplayer:
    trigger:
        send "%{join.%player%}%" to player
       
            #WERBUNG
           
on load:
    send "---------------------------" to console
    send "Dieses Plugin wurde von WorldMoney gecodet!" to console
    send "Dieses Plugin befindet sich in der BETA!" to console
    send "---------------------------" to console

On "add 1 to {count.player.ampelrennen}" has a problem. If i make the Cmd /ampelrennen join in Minecraft, then all works but if i test with /countplayers how many Players are in the Game, then theres 0 Player. Can any one help ?
Show the code where you set the variable.
 
Code:
        if arg 1 is "join":
            if {join.%player%} is "0":
                set {join.%player%} to "1"
                teleport player to {spawn.lobby}
                add 1 to {count.player.ampelrennen}
                send "{@JOINMESSAGE}" to player
            else if {join.%player%} is "1":
                send "{@BEREITSIMSPIELMESSAGE}" to player
[doublepost=1585474072,1585474017][/doublepost]The Variable is {count.player.ampelrennen}
 
Code:
        if arg 1 is "join":
            if {join.%player%} is "0":
                set {join.%player%} to "1"
                teleport player to {spawn.lobby}
                add 1 to {count.player.ampelrennen}
                send "{@JOINMESSAGE}" to player
            else if {join.%player%} is "1":
                send "{@BEREITSIMSPIELMESSAGE}" to player
[doublepost=1585474072,1585474017][/doublepost]The Variable is {count.player.ampelrennen}
In that code, the variable {count.player.ampelrennen} is not set, only added to. Do you have code where you set the variable (set {count.player.ampelrennen} to ...)
 
It doesn't have to be set. This is the number of players currently in the game. If i set it, it cannot count the number of players
 
It doesn't have to be set. This is the number of players currently in the game. If i set it, it cannot count the number of players
Try to delete it once, and see if it works after that.
 
Status
Not open for further replies.