Thread: Regarding player saving and various "unwelcome" variables.

Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 31
  1. #21  
    Banned

    Join Date
    Jun 2012
    Posts
    234
    Thanks given
    10
    Thanks received
    150
    Rep Power
    0
    I have the script rewritten for determining if a song is unlocked so I'm aware, but it fits better under the definition of what a bit variable is.

    - - - Updated - - -

    For those of you who MAY want to know the mapping of song ids to their file, since this discussion tapered into it a bit. You can grab it from the CS2 enumerations in the cache.

    https://github.com/Hadyn/mopar/blob/...ng_config.json

    That is for err. 530.
    Reply With Quote  
     

  2. Thankful user:


  3. #22  
    Registered Member

    Join Date
    Jan 2014
    Posts
    376
    Thanks given
    49
    Thanks received
    111
    Rep Power
    106
    That's exactly what I've done on the last server I worked on. In fact, you don't even need external variables to keep track of player information between game cycles; there are generally varps which you can use for these too (the only exception I found was trade, which must use a very old legacy system).

    For systems which work on a timer (such as farming), you can simply save the current time in the player file when you log out, then on the next login you can work out the difference between the last login and the current time and process anything you missed.

    Besides varps, invs, friends/ignores, and stats, the only things you should need in the player file are run energy, current coordinates, name(s) and password, idk data (colours, styles, and gender), exchange offers, clan hash and last friends chat, and the timestamp of the last login.

    Note that client variables (varc, varcstr) shouldn't need to be stored persistently on the server. They should only need to be sent to the client (most values are copies of global server variables anyways)
    Reply With Quote  
     

  4. Thankful user:


  5. #23  
    Regarding player saving and various "unwelcome" variables.



    Scu11's Avatar
    Join Date
    Aug 2007
    Age
    30
    Posts
    16,307
    Thanks given
    7,215
    Thanks received
    12,308
    Rep Power
    5000
    Quote Originally Posted by Scu11 View Post
    I've already done this (made a variable system that wraps the different type of player variables - varp, varbit, varc, varcstr etc)

    an example:

    Code:
    		Variable.stringBuilder("energy_orb").id(173).type(VariableType.VARP).defaultValue("walking").values(
    			0, "walking",
    			1, "running",
    			3, "resting",
    			4, "resting_at_musician"
    		).register();
    
    
    		Variable.booleanBuilder("poisoned").id(102).type(VariableType.VARP).register();
    
    
    		Variable.integerBuilder("life_points").id(7198).type(VariableType.VARBIT).register();


    Then i can do:

    Code:
    player.setVariable("energy_orb", "running");
    
    player.setVariable("poisoned", true);
    
    player.setVariable("life_points", 500);
    etc


    if you need any explanation just ask
    Quote Originally Posted by Velocity View Post
    Gotta admit your sys looks fly af

    Updated thx to velocity for a suggestion that removed the need for a shit ton of values(int key, string value...) methods:

    Code:
    		Variable.stringBuilder("prayer_list").id(1584).type(VariableType.VARP).persist()
    			.defaultValue(0, "normal")
    			.value(1, "curses")
    			.register();
    Last edited by Scu11; 07-29-2015 at 02:58 AM.

    Attached image
    Reply With Quote  
     

  6. Thankful users:


  7. #24  
    Registered Member
    Velocity's Avatar
    Join Date
    Jan 2009
    Age
    28
    Posts
    2,028
    Thanks given
    1,013
    Thanks received
    2,376
    Rep Power
    4112
    Quote Originally Posted by Sundays211 View Post
    That's exactly what I've done on the last server I worked on. In fact, you don't even need external variables to keep track of player information between game cycles; there are generally varps which you can use for these too (the only exception I found was trade, which must use a very old legacy system).

    For systems which work on a timer (such as farming), you can simply save the current time in the player file when you log out, then on the next login you can work out the difference between the last login and the current time and process anything you missed.

    Besides varps, invs, friends/ignores, and stats, the only things you should need in the player file are run energy, current coordinates, name(s) and password, idk data (colours, styles, and gender), exchange offers, clan hash and last friends chat, and the timestamp of the last login.

    Note that client variables (varc, varcstr) shouldn't need to be stored persistently on the server. They should only need to be sent to the client (most values are copies of global server variables anyways)
    It wouldn't even work as varc/varcstr can't be tracked properly; the client changes these where it wants to without any guaranteed hey-we-changed-it packet, thus making it untrackable, where (almost) all varps are altered either only by the server and then letting the client know (e.g. after buttons) or internal but immediately dispatching a message which indicates that the server should act. The sending of varc and varcstr is solely used to hint or instruct at moments but they're mainly used by scripts internally.

    Also idk data has associated varps too, same with skin col and gender (change appearance on makeover mage on rs, notice varps).
    xxxxxxx
    Reply With Quote  
     

  8. Thankful users:


  9. #25  
    WVWVWVWVWVWVWVW

    _jordan's Avatar
    Join Date
    Nov 2012
    Posts
    3,046
    Thanks given
    111
    Thanks received
    1,848
    Rep Power
    5000
    Quote Originally Posted by Scu11 View Post
    I've already done this (made a variable system that wraps the different type of player variables - varp, varbit, varc, varcstr etc)

    an example:

    Code:
    		Variable.stringBuilder("energy_orb").id(173).type(VariableType.VARP).defaultValue("walking").values(
    			0, "walking",
    			1, "running",
    			3, "resting",
    			4, "resting_at_musician"
    		).register();
    
    
    		Variable.booleanBuilder("poisoned").id(102).type(VariableType.VARP).register();
    
    
    		Variable.integerBuilder("life_points").id(7198).type(VariableType.VARBIT).register();


    Then i can do:

    Code:
    player.setVariable("energy_orb", "running");
    
    player.setVariable("poisoned", true);
    
    player.setVariable("life_points", 500);
    etc


    if you need any explanation just ask
    That is actually a really cool idea.
    Attached image
    Attached image
    Reply With Quote  
     

  10. #26  
    Extreme Donator


    Join Date
    Jul 2009
    Age
    27
    Posts
    4,351
    Thanks given
    826
    Thanks received
    1,239
    Rep Power
    1781
    Quote Originally Posted by Scu11 View Post
    Updated thx to velocity for a suggestion that removed the need for a shit ton of values(int key, string value...) methods:

    Code:
    		Variable.stringBuilder("prayer_list").id(1584).type(VariableType.VARP).persist()
    			.defaultValue(0, "normal")
    			.value(1, "curses")
    			.register();
    I'm really interested in seeing more of this system of yours (how it works, etc.)

    Quote Originally Posted by _jordan View Post
    That is actually a really cool idea.
    Why is your signature a Java Logo but .NET code?

    You can find my GitHub here, for what I'm currently working on.
    Reply With Quote  
     

  11. #27  
    Banned
    Join Date
    Jul 2015
    Posts
    71
    Thanks given
    10
    Thanks received
    25
    Rep Power
    0
    Good read, thank you for the information I will definitely try to make good use of it.
    Reply With Quote  
     

  12. Thankful user:


  13. #28  
    Regarding player saving and various "unwelcome" variables.



    Scu11's Avatar
    Join Date
    Aug 2007
    Age
    30
    Posts
    16,307
    Thanks given
    7,215
    Thanks received
    12,308
    Rep Power
    5000
    Quote Originally Posted by Sir Tom View Post
    I'm really interested in seeing more of this system of yours (how it works, etc.)
    its just the builder pattern for the most part lol


    Why is your signature a Java Logo but .NET code?
    i asked the same thing in another thread lol

    Attached image
    Reply With Quote  
     

  14. #29  
    WVWVWVWVWVWVWVW

    _jordan's Avatar
    Join Date
    Nov 2012
    Posts
    3,046
    Thanks given
    111
    Thanks received
    1,848
    Rep Power
    5000
    Quote Originally Posted by Sir Tom View Post
    I'm really interested in seeing more of this system of yours (how it works, etc.)



    Why is your signature a Java Logo but .NET code?
    Quote Originally Posted by Scu11 View Post
    its just the builder pattern for the most part lol




    i asked the same thing in another thread lol
    It's a joke for people to notice lol. I replied with the same thing in another thread
    Attached image
    Attached image
    Reply With Quote  
     

  15. #30  


    Major's Avatar
    Join Date
    Jan 2011
    Posts
    2,997
    Thanks given
    1,293
    Thanks received
    3,556
    Rep Power
    5000
    Quote Originally Posted by Sir Tom View Post
    I'm really interested in seeing more of this system of yours (how it works, etc.)
    Not Scu's code but this is the idea:

    Code:
    import java.util.Map;
    import java.util.HashMap;
    
    import com.google.common.collect.ImmutableMap;
    import com.google.common.base.Preconditions;
    
    public final class Variable<T> {
    
    	public static class Builder<T> {
    
    		private final String name;
    
    		public Builder(String name) {
    			this.name = name;
    		}
    
    		private int id = -1;
    
    		private Type type;
    
    		private Persistence persistence = Persistence.TRANSIENT;
    
    		private Map<Integer, String> values = new HashMap<>();
    
    		private String defaultValue;
    
    		public void id(int id) {
    			this.id = id;
    		}
    
    		public void type(Type type) {
    			this.type = type;
    		}
    
    		public void persist() {
    			persistence = Persistence.PERSISTENT;
    		}
    
    		public void value(int index, String value) {
    			values.put(index, value);
    		}
    
    		public void defaultValue(String defaultValue) {
    			this.defaultValue = defaultValue;
    		}
    
    		public void register() {
    			Preconditions.checkNonNull(type, "Variable.Type must be set before registering.";)
    			return new Variable(id, defaultValue, type, persistence, ImmutableMap.copyOf(values));
    		}
    
    	}
    
    	public enum Persistence {
    
    		PERSISTENT,
    
    		TRANSIENT,
    
    	}
    
    	public enum Type {
    
    		VARBIT,
    
    		VARP,
    
    		/* more here */
    
    	}
    
    	public static Builder<String> stringBuilder(String name) {
    		return new Builder<>(name);
    	}
    
    	public static Builder<Integer> intBuilder(String name) {
    		return new Builder<>(name);
    	}
    
    	private final T defaultValue;
    
    	private final int id;
    
    	private final Persistence persistence;
    
    	private final Type type;
    
    	private final ImmutableMap<Integer, String> values;
    
    	public Variable(int id, T defaultValue, Type type, Persistence persistence,
    			ImmutableMap<Integer, String> values) {
    		this.id = id;
    		this.defaultValue = defaultValue;
    		this.type = type;
    		this.persistence = persistence;
    		this.values = values;
    	}
    
    	public T getDefaultValue() {
    		return defaultValue;
    	}
    
    	public int getId() {
    		return id;
    	}
    
    	public Persistence getPersistence() {
    		return persistence;
    	}
    
    	public Type getType() {
    		return type;
    	}
    
    	public String getValue(int index) {
    		return values.get(index);
    	}
    
    }
    Last edited by Major; 07-30-2015 at 04:36 PM. Reason: Add missing import statements.
    Reply With Quote  
     

  16. Thankful users:


Page 3 of 4 FirstFirst 1234 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [PI] XML Player Saving and Loading
    By Roboyto in forum Snippets
    Replies: 19
    Last Post: 08-19-2013, 01:14 AM
  2. Replies: 4
    Last Post: 03-27-2011, 12:58 AM
  3. Player Saving And Loading
    By xSelseor in forum Snippets
    Replies: 4
    Last Post: 09-01-2010, 10:11 PM
  4. Replies: 6
    Last Post: 08-22-2008, 12:11 AM
  5. Replies: 37
    Last Post: 06-12-2008, 08:14 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •