temporary variable?

Discussion in 'Plugin Development' started by patey, Aug 10, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    patey

    In the plugin I'm making each user has a metadata tag for "global" set to off on join, this is used later to determine whether the player should receive garbled chat or clear chat in the chat events, but there's a command to turn global on for everyone to do announcements and such.

    I was wondering if there's a way I can set a variable so that when players join it does something like
    ' if (globalsetting.equals("on"){ utils.setmetadata(player,"global,"on") '
    and then when running the command to turn global on for everyone it could be changed to on or off so when users login in the middle of announcements the can see everything clearly.

    *~edit, my browser wont allow me to use the popup editor tody for some reason~*

    I should specify - I just need to know how to set it as a variable to use between the playerjoin event and the command, and I forgot to mention I would prefer if it can be off by default in case the server crashes or restarts before setting it back to off.

    I know how to do the checks, metadata, etc.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  2. Offline

    Necrodoom

    I'm not exactly sure what you want.
    You have a global variable, and a local variable for each player. You also have a command to toggle all local variables to on. What should happen exactly to local variable when what happens?
     
  3. Offline

    patey

    I have a metadata tag on each player called global, which using a command can change it for all online players, and on player join the tag is set to off by default. but when a player joins I'd like to determine whether it should be on or off by checking a variable that is by default set to "off" whenever the server starts and the command that changes the tag for all online players would change this variable to "on" or "off".
     
  4. Offline

    Necrodoom

    patey so basically, when a player joins, you want to check the global variable, which is toggled by the command, to see if he can view login message or not, if yes, toggle it on for login message then toggle it off?
     
  5. Offline

    patey

    close, its a toggle of whether the user can see clear or garbled chat.
    when a user joins the metadata tag on them that is checked during chat event is set to whatever the "globalChat" variable says it should be, then if say a mod needs to announce something he'll use the command /global all on and that "globalChat" variable is set to "on" along with the metadata tag of all online users. if the server is closed without using the command /global all off I'd like that "globalChat" variable to go back to off.

    *edit wont work today for some reason* ^ that is how I'd like it to work.

    currently on join the user's meta data tag os just set to off, any users that login after the /global all on command is used don't get global turned on. the command only changes all online users' metadata tags

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  6. Offline

    Necrodoom

    patey globalchat variable will not persist if you shutdown your server, unless you save it to config, and load it when server restarts. All data saved in the plugin is destroyed when plugin goes off.
     
Thread Status:
Not open for further replies.

Share This Page