Thread: Points for all Players

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 Points for all Players 
    Donator
    nonononooooooo's Avatar
    Join Date
    Nov 2012
    Posts
    370
    Thanks given
    13
    Thanks received
    4
    Rep Power
    20
    So i'm trying to work on an hourly point system, example being every hour all online players receive 100 points. I have one already using process, but I'm trying to convert it to my clocked events system, the problem is every hour it distributes 100 points * the number of players online.

    Code:
    for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                if (PlayerHandler.players[i] != null) {
                    Client c2 = (Client) PlayerHandler.players[i];
    				c2.sendMessage("<img=2><col="+color+">[Server]:"+data);
    				c2.SkillPoints += 100;
    			}
    		}
    is the code.

    Contact Me (Discord) @ Phantasye#0001
    Reply With Quote  
     

  2. #2  
    oof


    Join Date
    Aug 2012
    Posts
    3,150
    Thanks given
    2,847
    Thanks received
    857
    Rep Power
    2260
    uhh try this
    Code:
     EventManager.getSingleton().addEvent(new Event() {
                 public void execute(EventContainer c) {
                   for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                if (PlayerHandler.players[i] != null) {
                    Client c2 = (Client) PlayerHandler.players[i];
    				c2.sendMessage("<img=2><col="+color+">[Server]:"+data);
    				c2.SkillPoints += 100;
    			}
    		}
                 }
             }, 3600000);//Milliseconds per sent event
    Reply With Quote  
     

  3. #3  
    Donator
    nonononooooooo's Avatar
    Join Date
    Nov 2012
    Posts
    370
    Thanks given
    13
    Thanks received
    4
    Rep Power
    20
    That didn't help, but it appears there's more bugs, in addition to what I mentioned before, it also seems to set every online players points to however many the most recently logged in player has. I don't think it's in the event itself as the event just checks the time, and then implements the following method if it's the right time
    Code:
    public static void globalPoints(int color,String data){
    		for (int i = 0; i < Config.MAX_PLAYERS; i++) {
                if (PlayerHandler.players[i] != null) {
    				Client c2 = (Client) PlayerHandler.players[i];
    				if(c2 != null) {				
    					c2.sendMessage("<img=2><col="+color+">[Server]:"+data);
    					c2.SkillPoints += 100;
    				}
    			}
    		}
    	}
    So I'm assuming the problem to both of my problems is in this method, but I don't know what it could be, any help is appreciated.

    Contact Me (Discord) @ Phantasye#0001
    Reply With Quote  
     

  4. #4  
    Banned

    Join Date
    Dec 2011
    Posts
    967
    Thanks given
    234
    Thanks received
    208
    Rep Power
    0
    How about this

    Code:
    for (Player p : PlayerHandler.players) {
    Client c = (Client)p;
    if (c != null)
    c.skillingspoints +=100;
    }
    Same can be done by

    Code:
    for (int x =0; x < PlayerHandler.players.length;x++) {
    if (PlayerHandler.players[x] != null) {
    Client c = (Client)PlayerHandler.players[x];
    c.skillingpoints+=100;
    c.sendMessage("bla");
    }
    }
    Reply With Quote  
     

  5. #5  
    Donator
    nonononooooooo's Avatar
    Join Date
    Nov 2012
    Posts
    370
    Thanks given
    13
    Thanks received
    4
    Rep Power
    20
    Same result, got any other ideas? I still need this.

    Contact Me (Discord) @ Phantasye#0001
    Reply With Quote  
     

  6. #6  
    Banned

    Join Date
    Dec 2011
    Posts
    967
    Thanks given
    234
    Thanks received
    208
    Rep Power
    0
    Quote Originally Posted by phantasye View Post
    Same result, got any other ideas? I still need this.
    Is skillingpoints static?
    Reply With Quote  
     

  7. Thankful user:


  8. #7  
    Extreme Donator Points for all Players Market Banned



    Join Date
    Dec 2010
    Age
    25
    Posts
    6,060
    Thanks given
    1,692
    Thanks received
    1,238
    Rep Power
    1765
    ^ That is the only reason I think it is doing that.
    Reply With Quote  
     

  9. #8  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,092
    Thanks given
    2,402
    Thanks received
    2,823
    Rep Power
    4550
    You need to take into consideration that if a player has just logged in, and it's been 59 minutes since last check, that they will receive a reward for login in for 1 minute and being lucky enough to be on time. To fix this, create a way to track a players session time. So everytime they logout/login the timer is reset. Create a static event that checks every minute or so, if the player has been online for 60 minutes.
    Reply With Quote  
     

  10. #9  
    Donator
    nonononooooooo's Avatar
    Join Date
    Nov 2012
    Posts
    370
    Thanks given
    13
    Thanks received
    4
    Rep Power
    20
    Oh it is, thanks lol

    Contact Me (Discord) @ Phantasye#0001
    Reply With Quote  
     

  11. #10  
    Donator
    nonononooooooo's Avatar
    Join Date
    Nov 2012
    Posts
    370
    Thanks given
    13
    Thanks received
    4
    Rep Power
    20
    Quote Originally Posted by icandoit View Post
    Is skillingpoints static?
    Oh it is, thanks

    Contact Me (Discord) @ Phantasye#0001
    Reply With Quote  
     

Page 1 of 2 12 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. Replies: 2
    Last Post: 10-13-2008, 08:24 AM
  2. [503] Chatbox text, working for all players
    By Cascade in forum Tutorials
    Replies: 42
    Last Post: 08-24-2008, 09:54 AM
  3. How to sit on a chair, for all players
    By holy dang it in forum Tutorials
    Replies: 21
    Last Post: 06-05-2008, 05:10 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
  •