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.

Solved Problem with add 1 to {variable}

Discussion in 'Skript' started by WorldMoney, Mar 29, 2020.

Tags:
Thread Status:
Not open for further replies.
  1. WorldMoney

    WorldMoney Member

    Joined:
    Mar 29, 2020
    Messages:
    14
    Likes Received:
    0
    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 (Text):
    1. options:
    2.  
    3.         #Hier kannst du alles ändern
    4.     SPIELMODUSNAME: &e&lAmpelrennen
    5.    
    6.         #Messages:
    7.    
    8.     KEINERECHTE: &cSorry du hast dafür keine Rechte!
    9.    
    10.     JOINMESSAGE: &6Du bist dem Spiel beigetreten
    11.    
    12.     LOBBYSETSPAWNMESSAGE: &6Der Lobby Spawnpunkt wurde erfolgreich gesetzt.
    13.    
    14.     ZIELSETSPAWNMESSAGE: &6Der Ziel Spawnpunkt wurde erfolgreich gesetzt.
    15.    
    16.     STARTSETSPAWNMESSAGE: &6Der Start Spawnpunkt wurde erfolgreich gesetzt.
    17.    
    18.     LEAVESETSPAWNMESSAGE: &6Du bist aus dem Spiel gegangen.
    19.    
    20.     LEAVEMESSAGE: &6Du bist aus dem Spiel gegangen.
    21.    
    22.     BEREITSIMSPIELMESSAGE: &6Du bist bereits im Spiel!
    23.    
    24.     INKEINSPIELERRORMESSAGE: &6Du bist momentan in keinen Spiel!
    25.    
    26.     #Hier darfst du nichts ändern!
    27.    
    28. command /ampelrennen [<text>] [<text>] [<string>]:
    29.     trigger:
    30.         if arg 1 is not set:
    31.             send "-------------------------" to player
    32.             send "&4&lCommands             " to player
    33.             send "&6&l/ampelrennen <join,leave,admin,setspawn>" to player
    34.             send "-------------------------" to player
    35.         if arg 1 is "admin":
    36.             if player has permission "ampel.admin":
    37.                 send "------------------------------------" to player
    38.                 send "&4Admin &lCommands " to player
    39.                 send "&6&l/ampelrennen setspawn <start,finish,lobby,leavepunkt>" to player
    40.                 send "&6&l/ampelrennen start" to player
    41.                 send "&6&l/ampelrennen stop" to player
    42.                 send "------------------------------------"
    43.             else:
    44.                 send "{@KEINERECHTE}"
    45.         if arg 1 is "setspawn":
    46.             if arg 2 is not set:
    47.                 send "{@SPIELMODUSNAME} &6Bitte setze eine Syntax! /ampelrennen setspawn <start,finish,lobby,leavepunkt>" to player
    48.             if player has permission "ampel.admin":
    49.                 if arg 2 is "start":
    50.                     set {spawn.start} to location of player
    51.                     send "{@SPIELMODUSNAME} {@STARTSETSPAWNMESSAGE}" to player
    52.                 if arg 2 is "finish":
    53.                     set {spawn.finish} to location of player
    54.                     send "{@SPIELMODUSNAME} {@ZIELSETSPAWNMESSAGE}" to player
    55.                 if arg 2 is "lobby":
    56.                     set {spawn.lobby} to location of player
    57.                     send "{@SPIELMODUSNAME} {@LOBBYSETSPAWNMESSAGE}" to player
    58.                     send "{@SPIELMODUSNAME} &6Man wird nach dem Spiel immer wieder zu diesem Spawnpunkt teleportiert." to player
    59.                 if arg 2 is "leavepunkt":
    60.                     set {spawn.leave} to location of player
    61.                     send "{@SPIELMODUSNAME} {@LEAVESETSPAWNMESSAGE}" to player
    62.                     send "{@SPIELMODUSNAME} &6Man wird, wenn man mit /ampelrennen leave aus dem Spiel geht, zu diesem Spawnpunkt teleportiert." to player
    63.             else:
    64.                 send "{@KEINERECHTE}" to player
    65.         if arg 1 is "join":
    66.             if {join.%player%} is "0":
    67.                 set {join.%player%} to "1"
    68.                 teleport player to {spawn.lobby}
    69.                 add 1 to {count.player.ampelrennen}
    70.                 send "{@JOINMESSAGE}" to player
    71.             else if {join.%player%} is "1":
    72.                 send "{@BEREITSIMSPIELMESSAGE}" to player
    73.         if arg 1 is "leave":
    74.             if {join.%player%} is "1":
    75.                 remove 1 from {count.player.ampelrennen}
    76.                 set {join.%player%} to "0"
    77.                 teleport player to {spawn.leave}
    78.                 send "{@LEAVEMESSAGE}" to player
    79.             else if {join.%player%} is "0":
    80.                 send "{@INKEINSPIELERRORMESSAGE}"
    81.  
    82.  
    83.  
    84. right click on sign:
    85.     if line 1 is "join":
    86.         if line 2 is "join ampelrennen":
    87.             execute player command "ampelrennen join"
    88.  
    89.  
    90.  
    91.  
    92. on join:
    93.     if {join.%player%} is not set:
    94.         set {join.%player%} to "0"
    95.  
    96. on quit:
    97.     if {join.%player%} is "1":
    98.         teleport player to {spawn.leave}
    99.         remove 1 from {count.player.ampelrennen}
    100.         set {join.%player%} to "0"
    101.            
    102.  
    103.             #STRINGS TEST
    104.            
    105. command /spawnstart:
    106.     trigger:
    107.         teleport player to {spawn.start}
    108.  
    109. command /spawnfinish:
    110.     trigger:
    111.         teleport player to {spawn.finish}
    112.  
    113. command /spawnlobby:
    114.     trigger:
    115.         teleport player to {spawn.lobby}
    116.        
    117. command /countplayers:
    118.     trigger:
    119.         send "%{count.player.ampelrennen}%"
    120.        
    121. command /joinplayer:
    122.     trigger:
    123.         send "%{join.%player%}%" to player
    124.        
    125.             #WERBUNG
    126.            
    127. on load:
    128.     send "---------------------------" to console
    129.     send "Dieses Plugin wurde von WorldMoney gecodet!" to console
    130.     send "Dieses Plugin befindet sich in der BETA!" to console
    131.     send "---------------------------" to console
    132.    
    133.  
    134.    
    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 ?
     
  2. TPGamesNL

    Supporter Addon Developer Dev Programme

    Joined:
    Jan 20, 2018
    Messages:
    1,501
    Likes Received:
    107
    Medals:
    Show the code where you set the variable.
     
  3. WorldMoney

    WorldMoney Member

    Joined:
    Mar 29, 2020
    Messages:
    14
    Likes Received:
    0
    Code (Text):
    1.         if arg 1 is "join":
    2.             if {join.%player%} is "0":
    3.                 set {join.%player%} to "1"
    4.                 teleport player to {spawn.lobby}
    5.                 add 1 to {count.player.ampelrennen}
    6.                 send "{@JOINMESSAGE}" to player
    7.             else if {join.%player%} is "1":
    8.                 send "{@BEREITSIMSPIELMESSAGE}" to player
    --- Double Post Merged, Mar 29, 2020, Original Post Date: Mar 29, 2020 ---
    The Variable is {count.player.ampelrennen}
     
  4. TPGamesNL

    Supporter Addon Developer Dev Programme

    Joined:
    Jan 20, 2018
    Messages:
    1,501
    Likes Received:
    107
    Medals:
    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 ...)
     
  5. WorldMoney

    WorldMoney Member

    Joined:
    Mar 29, 2020
    Messages:
    14
    Likes Received:
    0
    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
     
  6. TPGamesNL

    Supporter Addon Developer Dev Programme

    Joined:
    Jan 20, 2018
    Messages:
    1,501
    Likes Received:
    107
    Medals:
    Try to delete it once, and see if it works after that.
     
  7. WorldMoney

    WorldMoney Member

    Joined:
    Mar 29, 2020
    Messages:
    14
    Likes Received:
    0
    omg thanks TPGamesNL
    --- Double Post Merged, Mar 29, 2020, Original Post Date: Mar 29, 2020 ---
    It works thank you :emoji_grinning:
     
    • Friendly Friendly x 1
Thread Status:
Not open for further replies.

Share This Page

Loading...