Results 1 to 6 of 6

Thread: Help with ints

  1. #1
    Join Date
    Mar 2010
    Posts
    14
    Rep Power
    0

    Default Help with ints

    Well, I did previously as for help on making Slayer (Runescape Skill). I had a few errors that occured from not having the main method, and I can't belive I forgot that -.-

    Now I have a problem with these:

    Java Code:
    /tmp/jc_30206/Slayer.java:13: illegal start of expression
    	public int slayerLevelNeeded = 0;
    	^
    /tmp/jc_30206/Slayer.java:14: illegal start of expression
    	public int slayerExpGiven = 0;
    	^
    /tmp/jc_30206/Slayer.java:15: illegal start of expression
    	public int taskID = 0;
    	^
    /tmp/jc_30206/Slayer.java:16: illegal start of expression
    	public int taskAmount = 0;
    	^
    4 errors
    From this:

    Java Code:
    public class Slayer{
    /*
    * A near 100% perfect Slayer replica of Runescape Slayer
    * Made by Insomniac Riot, A.K.A. Helix
    */
    
    	public int taskID, taskAmount, slayerExpGiven, slayerLevelNeeded;
    
    	public static void main (String[] args){
    
    		client c = (client) server.playerHandler.players[a];
    
    		public int slayerLevelNeeded = 0;
    		public int slayerExpGiven = 0;
    		public int taskID = 0;
    		public int taskAmount = 0;
    
    		if (c.combatLevel >= 3 && c.combatLevel <= 50) {
    			c.taskID = randomLowTask();
    			c.taskAmount = 10 + (misc.random(240));
    			c.talk2("Your task is to kill "+c.taskAmount+" "+c.GetNpcName(c.taskID)+"s.", "Hurry to get another task.", 1597);
    		}
    		if (c.combatLevel >= 51 && c.combatLevel <= 100) {
    			c.taskID = randomMediumTask();
    			c.taskAmount = 10 + (misc.random(240));
    			c.talk2("Your task is to kill "+c.taskAmount+" "+c.GetNpcName(c.taskID)+"s.", "Hurry to get another task.", 1597);
    		}
    		if (c.combatLevel >= 101) {
    			c.taskID = randomHighTask();
    			c.taskAmount = 10 + (misc.random(240));
    			c.talk2("Your task is to kill "+c.taskAmount+" "+c.GetNpcName(c.taskID)+"s.", "Hurry to get another task.", 1597);
    		}
    
    		if(c.taskID > 0 && c.taskAmount == 0){
    			c.addSkillXP(c.taskID * 20, 18);
    			c.taskID = -1;
    			c.taskAmount = -1;
    			c.sM("You completed your assignment, so you recieve Slayer Experience.");
    			c.sM("You can talk with a Slayer Master or use an Enchanted Gem to gain another Task.");
    		}
    
    		returnSlayerName("Jellies");
    		returnSlayerName("Gargoyle");
    		returnSlayerName("Turoth");
    		returnSlayerName("Infernal Mage");
    		returnSlayerName("Crawling Hand");
    		returnSlayerName("Rockslug");
    		returnSlayerName("Cockatrice");
    		returnSlayerName("Cave Crawler");
    		returnSlayerName("Bloodveld");
    		returnSlayerName("Aberrant Specter");
    		returnSlayerName("Kurask");
    		returnSlayerName("Goblin");
    		returnSlayerName("Bear");
    		returnSlayerName("Zombie");
    		returnSlayerName("Cow");
    		returnSlayerName("Ghost");
    		returnSlayerName("Pyrefiend");
    
    		if (server.npcHandler.npcs[attacknpc].npcType == slayerNpcId) {
    			if(c.taskID == slayerNpcId && c.taskAmount > 0){
    				if (c.playerLevel[18] < slayerLevelNeeded) {
    					c.sM("You must have atleast "+slayerLevelNeeded+" Slayer to attack this monster.");
    					c.ResetAttackNPC();
    				}
    			c.addSkillXP(slayerExpGiven, 18);
    			c.taskAmount -= 1;
    			}
    		}
    
    		switch (slayerNpcId){
    			case 105: // Bear
    				slayerExpGiven = 26;
    			break;
    			case 106: // Bear
    				slayerExpGiven = 25;
    			break;
    			case 100:
    			case 1769:
    			case 1770:
    			case 1771:
    			case 1772:
    			case 1773:
    			case 1774:
    			case 1775:
    			case 1776: // Goblin
    				slayerExpGiven = 5;
    			break;
    			case 101: // Goblin
    				slayerExpGiven = 14;
    			break;
    			case 102: // Goblin
    				slayerExpGiven = 16;
    			break;
    			case 299:
    			case 444:
    			case 445:
    			case 298: // Goblin
    				slayerExpGiven = 13;
    			break;
    			case 419:
    			case 73: // Zombie
    				slayerExpGiven = 22;
    			break;
    			case 75:
    			case 74:
    			case 751: // Zombie
    				slayerExpGiven = 30;
    			break;
    			case 76: // Zombie
    				slayerExpGiven = 31;
    			break;
    			case 420: // Zombie
    				slayerExpGiven = 36;
    			break;
    			case 421: // Zombie
    				slayerExpGiven = 57;
    			break;
    			case 422: // Zombie
    				slayerExpGiven = 90;
    			break;
    			case 423: // Zombie
    				slayerExpGiven = 130;
    			break;
    			case 424: // Zombie
    				slayerExpGiven = 160;
    			break;
    			case 412: // Bat
    				slayerExpGiven = 8;
    			break;
    			case 81: // Cow
    				slayerExpGiven = 15;
    			break;
    			case 397: // Cow
    				slayerExpGiven = 8;
    			break;
    			case 104:
    			case 491:
    			case 749:
    			case 103: // Ghost
    				slayerExpGiven = 25;
    			break;
    			case 1549: // Ghost
    				slayerExpGiven = 31;
    			break;
    			case 941: // Green Dragon
    				slayerExpGiven = 200;
    			break;
    			case 82: // Lesser Demon
    				slayerExpGiven = 200;
    			break;
    			case 83: // Greater Demon
    				slayerExpGiven = 200;
    			break;
    			case 84: // Black Demon
    				slayerExpGiven = 800;
    			break;
    			case 2745: // Jad
    				slayerExpGiven = 2500;
    			break;
    			case 1600:
    			case 1601:
    			case 1602:
    			case 1603:// Cave Crawler
    				slayerExpGiven = 22;
    				slayerLevelNeeded = 10;
    			break;
    			case 1604:
    			case 1605:
    			case 1606:
    			case 1607: // Aberrant Specter
    				slayerExpGiven = 90;
    				slayerLevelNeeded = 60;
    			break;
    			case 1608:
    			case 1609: // Kurask
    				slayerExpGiven = 97;
    				slayerLevelNeeded = 70;
    			break;
    			case 1618:
    			case 1619: // Bloodveld
    				slayerExpGiven = 97;
    				slayerLevelNeeded = 50;
    			break;
    			case 1620:
    			case 1621: // Cockatrice
    				slayerExpGiven = 37;
    				slayerLevelNeeded = 25;
    			break;
    			case 1622:
    			case 1623: // Rockslug
    				slayerExpGiven = 27;
    				slayerLevelNeeded = 20;
    			break;
    			case 1625: // Smokedevil
    				slayerExpGiven = 105;
    				slayerLevelNeeded = 10;
    			break;
    			case 1616: // Basilisk
    				slayerExpGiven = 75;
    				slayerLevelNeeded = 40;
    			break;
    			case 1637:
    			case 1638:
    			case 1639:
    			case 1640:
    			case 1641:
    			case 1642: // Jellies
    				slayerExpGiven = 75;
    				slayerLevelNeeded = 52;
    			break;
    			case 1648:
    			case 1649:
    			case 1650:
    			case 1651:
    			case 1652: // Crawling Hand
    				slayerExpGiven = 16;
    				slayerLevelNeeded = 5;
    			break;
    			case 1653:
    			case 1654:
    			case 1655:
    			case 1656:
    			case 1657: // Crawling Hand
    				slayerExpGiven = 19;
    				slayerLevelNeeded = 5;
    			break;
    			case 1643:
    			case 1644:
    			case 1645:
    			case 1646:
    			case 1647: // Infernal Mage
    				slayerExpGiven = 60;
    				slayerLevelNeeded = 45;
    			break;
    			case 1626: // Turoth
    				slayerExpGiven = 120;
    				slayerLevelNeeded = 55;
    			break;
    			case 1627:
    			case 1631:
    			case 1632: // Turoth
    				slayerExpGiven = 81;
    				slayerLevelNeeded = 55;
    			break;
    			case 1628: // Turoth
    				slayerExpGiven = 79;
    				slayerLevelNeeded = 55;
    			break;
    			case 1629: // Turoth
    				slayerExpGiven = 77;
    				slayerLevelNeeded = 55;
    			break;
    			case 1630: // Turoth
    				slayerExpGiven = 76;
    				slayerLevelNeeded = 55;
    			break;
    			case 1624: // Dustdevil
    				slayerExpGiven = 105;
    				slayerLevelNeeded = 65;
    			break;
    			case 1613: // Nechryael
    				slayerExpGiven = 210;
    				slayerLevelNeeded = 70;
    			break;
    			case 1633:
    			case 1634:
    			case 1635:
    			case 1636: // Pyrefiend
    				slayerExpGiven = 45;
    				slayerLevelNeeded = 30;
    			break;
    			case 1611: // Gargoyle
    				slayerExpGiven = 105;
    				slayerLevelNeeded = 75;
    			break;
    			case 1610: // Gargoyle
    				slayerExpGiven = 155;
    				slayerLevelNeeded = 75;
    			break;
    			case 1615: // Abyssal Demon
    				slayerExpGiven = 250;
    				slayerLevelNeeded = 85;
    			break;
    			case 2783: // Dark Beast
    				slayerExpGiven = 300;
    				slayerLevelNeeded = 90;
    			break;
    			default:
    				slayerExpGiven = 0;
    				slayerLevelNeeded = 1;
    			break;
    		}
    	}
    }

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,525
    Blog Entries
    7
    Rep Power
    20

    Default

    You're trying to define local variables at that position (inside a method body). Local variables can never be public. Get rid of that keyword.

    kind regards,

    Jos

  3. #3
    Join Date
    Mar 2010
    Posts
    14
    Rep Power
    0

    Default

    So like this?

    Java Code:
    public class Slayer{
    /*
    * A near 100% perfect Slayer replica of Runescape Slayer
    * Made by Insomniac Riot, A.K.A. Helix
    */
    
    	public int taskID, taskAmount, slayerExpGiven, slayerLevelNeeded;
    
    	public static void main (String[] args){
    
    		client c = (client) server.playerHandler.players[a];
    
    		int slayerLevelNeeded = 0;
    		int slayerExpGiven = 0;
    		int taskID = 0;
    		int taskAmount = 0;
    
    		if (c.combatLevel >= 3 && c.combatLevel <= 50) {
    			c.taskID = randomLowTask();
    			c.taskAmount = 10 + (misc.random(240));
    			c.talk2("Your task is to kill "+c.taskAmount+" "+c.GetNpcName(c.taskID)+"s.", "Hurry to get 
    
    another task.", 1597);
    		}
    		if (c.combatLevel >= 51 && c.combatLevel <= 100) {
    			c.taskID = randomMediumTask();
    			c.taskAmount = 10 + (misc.random(240));
    			c.talk2("Your task is to kill "+c.taskAmount+" "+c.GetNpcName(c.taskID)+"s.", "Hurry to get 
    
    another task.", 1597);
    		}
    		if (c.combatLevel >= 101) {
    			c.taskID = randomHighTask();
    			c.taskAmount = 10 + (misc.random(240));
    			c.talk2("Your task is to kill "+c.taskAmount+" "+c.GetNpcName(c.taskID)+"s.", "Hurry to get 
    
    another task.", 1597);
    		}
    
    		if(c.taskID > 0 && c.taskAmount == 0){
    			c.addSkillXP(c.taskID * 20, 18);
    			c.taskID = -1;
    			c.taskAmount = -1;
    			c.sM("You completed your assignment, so you recieve Slayer Experience.");
    			c.sM("You can talk with a Slayer Master or use an Enchanted Gem to gain another Task.");
    		}
    
    		returnSlayerName("Jellies");
    		returnSlayerName("Gargoyle");
    		returnSlayerName("Turoth");
    		returnSlayerName("Infernal Mage");
    		returnSlayerName("Crawling Hand");
    		returnSlayerName("Rockslug");
    		returnSlayerName("Cockatrice");
    		returnSlayerName("Cave Crawler");
    		returnSlayerName("Bloodveld");
    		returnSlayerName("Aberrant Specter");
    		returnSlayerName("Kurask");
    		returnSlayerName("Goblin");
    		returnSlayerName("Bear");
    		returnSlayerName("Zombie");
    		returnSlayerName("Cow");
    		returnSlayerName("Ghost");
    		returnSlayerName("Pyrefiend");
    
    		if (server.npcHandler.npcs[attacknpc].npcType == slayerNpcId) {
    			if(c.taskID == slayerNpcId && c.taskAmount > 0){
    				if (c.playerLevel[18] < slayerLevelNeeded) {
    					c.sM("You must have atleast "+slayerLevelNeeded+" Slayer to attack this 
    
    monster.");
    					c.ResetAttackNPC();
    				}
    			c.addSkillXP(slayerExpGiven, 18);
    			c.taskAmount -= 1;
    			}
    		}
    
    		switch (slayerNpcId){
    			case 105: // Bear
    				slayerExpGiven = 26;
    			break;
    			case 106: // Bear
    				slayerExpGiven = 25;
    			break;
    			case 100:
    			case 1769:
    			case 1770:
    			case 1771:
    			case 1772:
    			case 1773:
    			case 1774:
    			case 1775:
    			case 1776: // Goblin
    				slayerExpGiven = 5;
    			break;
    			case 101: // Goblin
    				slayerExpGiven = 14;
    			break;
    			case 102: // Goblin
    				slayerExpGiven = 16;
    			break;
    			case 299:
    			case 444:
    			case 445:
    			case 298: // Goblin
    				slayerExpGiven = 13;
    			break;
    			case 419:
    			case 73: // Zombie
    				slayerExpGiven = 22;
    			break;
    			case 75:
    			case 74:
    			case 751: // Zombie
    				slayerExpGiven = 30;
    			break;
    			case 76: // Zombie
    				slayerExpGiven = 31;
    			break;
    			case 420: // Zombie
    				slayerExpGiven = 36;
    			break;
    			case 421: // Zombie
    				slayerExpGiven = 57;
    			break;
    			case 422: // Zombie
    				slayerExpGiven = 90;
    			break;
    			case 423: // Zombie
    				slayerExpGiven = 130;
    			break;
    			case 424: // Zombie
    				slayerExpGiven = 160;
    			break;
    			case 412: // Bat
    				slayerExpGiven = 8;
    			break;
    			case 81: // Cow
    				slayerExpGiven = 15;
    			break;
    			case 397: // Cow
    				slayerExpGiven = 8;
    			break;
    			case 104:
    			case 491:
    			case 749:
    			case 103: // Ghost
    				slayerExpGiven = 25;
    			break;
    			case 1549: // Ghost
    				slayerExpGiven = 31;
    			break;
    			case 941: // Green Dragon
    				slayerExpGiven = 200;
    			break;
    			case 82: // Lesser Demon
    				slayerExpGiven = 200;
    			break;
    			case 83: // Greater Demon
    				slayerExpGiven = 200;
    			break;
    			case 84: // Black Demon
    				slayerExpGiven = 800;
    			break;
    			case 2745: // Jad
    				slayerExpGiven = 2500;
    			break;
    			case 1600:
    			case 1601:
    			case 1602:
    			case 1603:// Cave Crawler
    				slayerExpGiven = 22;
    				slayerLevelNeeded = 10;
    			break;
    			case 1604:
    			case 1605:
    			case 1606:
    			case 1607: // Aberrant Specter
    				slayerExpGiven = 90;
    				slayerLevelNeeded = 60;
    			break;
    			case 1608:
    			case 1609: // Kurask
    				slayerExpGiven = 97;
    				slayerLevelNeeded = 70;
    			break;
    			case 1618:
    			case 1619: // Bloodveld
    				slayerExpGiven = 97;
    				slayerLevelNeeded = 50;
    			break;
    			case 1620:
    			case 1621: // Cockatrice
    				slayerExpGiven = 37;
    				slayerLevelNeeded = 25;
    			break;
    			case 1622:
    			case 1623: // Rockslug
    				slayerExpGiven = 27;
    				slayerLevelNeeded = 20;
    			break;
    			case 1625: // Smokedevil
    				slayerExpGiven = 105;
    				slayerLevelNeeded = 10;
    			break;
    			case 1616: // Basilisk
    				slayerExpGiven = 75;
    				slayerLevelNeeded = 40;
    			break;
    			case 1637:
    			case 1638:
    			case 1639:
    			case 1640:
    			case 1641:
    			case 1642: // Jellies
    				slayerExpGiven = 75;
    				slayerLevelNeeded = 52;
    			break;
    			case 1648:
    			case 1649:
    			case 1650:
    			case 1651:
    			case 1652: // Crawling Hand
    				slayerExpGiven = 16;
    				slayerLevelNeeded = 5;
    			break;
    			case 1653:
    			case 1654:
    			case 1655:
    			case 1656:
    			case 1657: // Crawling Hand
    				slayerExpGiven = 19;
    				slayerLevelNeeded = 5;
    			break;
    			case 1643:
    			case 1644:
    			case 1645:
    			case 1646:
    			case 1647: // Infernal Mage
    				slayerExpGiven = 60;
    				slayerLevelNeeded = 45;
    			break;
    			case 1626: // Turoth
    				slayerExpGiven = 120;
    				slayerLevelNeeded = 55;
    			break;
    			case 1627:
    			case 1631:
    			case 1632: // Turoth
    				slayerExpGiven = 81;
    				slayerLevelNeeded = 55;
    			break;
    			case 1628: // Turoth
    				slayerExpGiven = 79;
    				slayerLevelNeeded = 55;
    			break;
    			case 1629: // Turoth
    				slayerExpGiven = 77;
    				slayerLevelNeeded = 55;
    			break;
    			case 1630: // Turoth
    				slayerExpGiven = 76;
    				slayerLevelNeeded = 55;
    			break;
    			case 1624: // Dustdevil
    				slayerExpGiven = 105;
    				slayerLevelNeeded = 65;
    			break;
    			case 1613: // Nechryael
    				slayerExpGiven = 210;
    				slayerLevelNeeded = 70;
    			break;
    			case 1633:
    			case 1634:
    			case 1635:
    			case 1636: // Pyrefiend
    				slayerExpGiven = 45;
    				slayerLevelNeeded = 30;
    			break;
    			case 1611: // Gargoyle
    				slayerExpGiven = 105;
    				slayerLevelNeeded = 75;
    			break;
    			case 1610: // Gargoyle
    				slayerExpGiven = 155;
    				slayerLevelNeeded = 75;
    			break;
    			case 1615: // Abyssal Demon
    				slayerExpGiven = 250;
    				slayerLevelNeeded = 85;
    			break;
    			case 2783: // Dark Beast
    				slayerExpGiven = 300;
    				slayerLevelNeeded = 90;
    			break;
    			default:
    				slayerExpGiven = 0;
    				slayerLevelNeeded = 1;
    			break;
    		}
    	}
    }

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,525
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Insomniac Riot View Post
    So like this?
    Yep, like that; (your compiler is the best judge).

    kind regards,

    Jos

  5. #5
    Join Date
    Mar 2010
    Posts
    14
    Rep Power
    0

    Default

    Thank you, your help is much needed

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,525
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Insomniac Riot View Post
    Thank you, your help is much needed
    You're welcome of course; it is extremely handy to learn how to read those compiler messages, but they can be a bit cryptic now and then. The compiler was parsing the body of your main( ... ) method; all that can be present in the body of a method are statements, expressions and declarations. None of them start with the keyword 'public' so the compiler panicked and started whining: it took one of 'statement', 'expression' and 'declaration' (expressions are most frequently used in bodies of methods) so it said "illegal start of expression". (*)

    kind regards,

    Jos

    (*) it's a bit more complicated than this but my explanation will do.

Similar Threads

  1. checking for ints in a String
    By SteroidalPsycho in forum New To Java
    Replies: 1
    Last Post: 03-26-2010, 06:09 PM
  2. GUI's and inputting doubles or ints
    By lopder1 in forum New To Java
    Replies: 19
    Last Post: 11-05-2009, 08:50 PM
  3. reading in unsigned ints into a 2D array
    By newToIt in forum New To Java
    Replies: 9
    Last Post: 03-06-2009, 12:36 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
  •