Thread: Player killing help

Results 1 to 6 of 6
  1. #1 Player killing help 
    Registered Member
    Join Date
    Dec 2011
    Posts
    21
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    Basically I've been searching all over to find a good playerkilling system that if you kiill someone it gives you pk points. However my server isn't recognising o.lastKilled because it has never been added. I've added a code to my playerkilling.java and client.java and for some reason I receive this annoying error... The code made by Core


    This is the code for playerkilling.java

    Code:
    package server.model.players;
    
    public class PlayerKilling {
    
    	private Client c;
    	
    	/**
    	* Constructor class
    	*/
    	
    	public PlayerKilling(Client Client) {
    		this.c = Client;
    	}
    
    /**
     * @author Core
     * Handles adding and removing hosts to the players array list.
     */
    public class PlayerKilling {
    	
    	/**
    	 * Adds the host of the killed player.
    	 *@param client Player that saves the host.
    	 *@param host	Host address of the killed player.
    	 *@return True if the host is added to the players array.
    	 */
    
    	public static boolean addHostToList(Client client, String host) {
    		if(client != null) {
    			return client.lastKilledPlayers.add(host);
    		}
    		return false;
    	}
    	
    	/**
    	 * Checks if the host is already on the players array.
    	 * @param client Player that is adding the killed players host.
    	 * @param host Host address of the killed player.
    	 * @return True if the host is on the players array.
    	 */
    	
    	public static boolean hostOnList(Client client, String host) {
    		if(client != null) {
    			if(client.lastKilledPlayers.lastIndexOf(host) >= KILL_WAIT_MAX) {
    				removeHostFromList(client, host);
    				return false;
    			}
    			return client.lastKilledPlayers.contains(host);
    		}
    		return false;
    	}
    	
    	/**
    	 * Removes the host from the players array.
    	 * @param client Player that is removing the host.
    	 * @param host Host that is being removed.
    	 * @return True if host is successfully removed.
    	 */
    	
    	public static boolean removeHostFromList(Client client, String host) {
    		if(client != null) {
    			return client.lastKilledPlayers.remove(host);
    		}
    		return false;
    	}
    	
    	/*
    	 * Amount of kills you have to wait before the host is deleted.
    	 */
    	
    	public static final int KILL_WAIT_MAX = 3;
    
    }
    	
    	/**
    	* How many people you have to kill before getting points again
    	* for killing the same person.
    	*/
    	
    	public final int NEEDED_KILLS = 10;
    	
    	/**
    	* First the method checks if the array list contains the person
    	* and if it doesn't then add there name but if it does then
    	* return the method false.
    	*/
    	
    	public boolean addPlayer(String i) {
    		if(!c.killedPlayers.contains(i)) {
    			c.killedPlayers.add(i);
    			return true;
    		}
    		return false;
    	}
    	
    	/**
    	* Checking if the array list contains the player and if
    	* the person has killed 20 or more people since that person.
    	*/
    	
    	public void checkForPlayer(String i) {
    		if(c.killedPlayers.contains(i) && c.killedPlayers.indexOf(i) >= NEEDED_KILLS) {
    			c.killedPlayers.remove(i);
    		}
    	}
    
    }
    This is the error I receive.

    Code:
    src\server\model\players\PlayerKilling.java:19: server.model.players.PlayerKilli
    ng is already defined in server.model.players
    public class PlayerKilling {
           ^
    src\server\model\players\PlayerKilling.java:28: inner classes cannot have static
     declarations
            public static boolean addHostToList(Client client, String host) {
                                  ^
    src\server\model\players\PlayerKilling.java:42: inner classes cannot have static
     declarations
            public static boolean hostOnList(Client client, String host) {
                                  ^
    src\server\model\players\PlayerKilling.java:60: inner classes cannot have static
     declarations
            public static boolean removeHostFromList(Client client, String host) {
                                  ^
    4 errors
    Press any key to continue . . .
    I don't quite get what it means by static declaration error...

    Can someone please help me?
    Reply With Quote  
     

  2. #2  
    Donator

    Join Date
    Jun 2009
    Posts
    290
    Thanks given
    5
    Thanks received
    22
    Rep Power
    37
    You have two "public class PlayerKilling {".

    Remove the top public class PlayerKilling {


    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Dec 2011
    Posts
    21
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    Uhm If I do that it gives me 10 errors?

    Code:
    src\server\model\players\PlayerKilling.java:4: class, interface, or enum expecte
    d
            private Client c;
                    ^
    src\server\model\players\PlayerKilling.java:10: class, interface, or enum expect
    ed
            public PlayerKilling(Client Client) {
                   ^
    src\server\model\players\PlayerKilling.java:12: class, interface, or enum expect
    ed
            }
            ^
    src\server\model\players\PlayerKilling.java:79: class, interface, or enum expect
    ed
            public final int NEEDED_KILLS = 10;
                         ^
    src\server\model\players\PlayerKilling.java:87: class, interface, or enum expect
    ed
            public boolean addPlayer(String i) {
                   ^
    src\server\model\players\PlayerKilling.java:90: class, interface, or enum expect
    ed
                            return true;
                            ^
    src\server\model\players\PlayerKilling.java:91: class, interface, or enum expect
    ed
                    }
                    ^
    src\server\model\players\PlayerKilling.java:93: class, interface, or enum expect
    ed
            }
            ^
    src\server\model\players\PlayerKilling.java:100: class, interface, or enum expec
    ted
            public void checkForPlayer(String i) {
                   ^
    src\server\model\players\PlayerKilling.java:103: class, interface, or enum expec
    ted
                    }
                    ^
    10 errors
    Press any key to continue . . .
    Bumped..
    Last edited by Austin_; 02-25-2012 at 04:55 PM.
    Reply With Quote  
     

  4. #4  
    Registered Member
    thim slug's Avatar
    Join Date
    Nov 2010
    Age
    28
    Posts
    4,132
    Thanks given
    1,077
    Thanks received
    1,137
    Rep Power
    5000
    Code:
    package server.model.players;
    
    /**
     * @author Core
     * Handles adding and removing hosts to the players array list.
     */
    
    public class PlayerKilling {
    
    	private Client c;
    	
    	/**
    	* Constructor class
    	*/
    	
    	public PlayerKilling(Client Client) {
    		this.c = Client;
    	}
    	
    	/**
    	 * Adds the host of the killed player.
    	 *@param client Player that saves the host.
    	 *@param host	Host address of the killed player.
    	 *@return True if the host is added to the players array.
    	 */
    
    	public static boolean addHostToList(Client client, String host) {
    		if(client != null) {
    			return client.lastKilledPlayers.add(host);
    		}
    		return false;
    	}
    	
    	/**
    	 * Checks if the host is already on the players array.
    	 * @param client Player that is adding the killed players host.
    	 * @param host Host address of the killed player.
    	 * @return True if the host is on the players array.
    	 */
    	
    	public static boolean hostOnList(Client client, String host) {
    		if(client != null) {
    			if(client.lastKilledPlayers.lastIndexOf(host) >= KILL_WAIT_MAX) {
    				removeHostFromList(client, host);
    				return false;
    			}
    			return client.lastKilledPlayers.contains(host);
    		}
    		return false;
    	}
    	
    	/**
    	 * Removes the host from the players array.
    	 * @param client Player that is removing the host.
    	 * @param host Host that is being removed.
    	 * @return True if host is successfully removed.
    	 */
    	
    	public static boolean removeHostFromList(Client client, String host) {
    		if(client != null) {
    			return client.lastKilledPlayers.remove(host);
    		}
    		return false;
    	}
    	
    	/*
    	 * Amount of kills you have to wait before the host is deleted.
    	 */
    	
    	public static final int KILL_WAIT_MAX = 3;
    
    	
    	/**
    	* How many people you have to kill before getting points again
    	* for killing the same person.
    	*/
    	
    	public final int NEEDED_KILLS = 10;
    	
    	/**
    	* First the method checks if the array list contains the person
    	* and if it doesn't then add there name but if it does then
    	* return the method false.
    	*/
    	
    	public boolean addPlayer(String i) {
    		if(!c.killedPlayers.contains(i)) {
    			c.killedPlayers.add(i);
    			return true;
    		}
    		return false;
    	}
    	
    	/**
    	* Checking if the array list contains the player and if
    	* the person has killed 20 or more people since that person.
    	*/
    	
    	public void checkForPlayer(String i) {
    		if(c.killedPlayers.contains(i) && c.killedPlayers.indexOf(i) >= NEEDED_KILLS) {
    			c.killedPlayers.remove(i);
    		}
    	}
    }
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Dec 2011
    Posts
    21
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    Should I add that code in?
    Reply With Quote  
     

  6. #6  
    I'm Baack...


    Join Date
    Mar 2011
    Posts
    1,663
    Thanks given
    281
    Thanks received
    202
    Rep Power
    324
    Replace yours with that
    I'm back
    Reply With Quote  
     


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. Dementhium Player Killing
    By `Basher in forum Help
    Replies: 5
    Last Post: 08-28-2011, 08:37 AM
  2. Replies: 5
    Last Post: 08-08-2009, 02:41 PM
  3. Safe Player Killing
    By Bridget7298 in forum Tutorials
    Replies: 13
    Last Post: 05-01-2008, 07:28 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
  •