Thread: int[][] Check it out.

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 int[][] Check it out. 
    Registered Member
    Join Date
    Jan 2010
    Posts
    466
    Thanks given
    259
    Thanks received
    77
    Rep Power
    43
    Can someone write the proper way to run this method?

    Code:
    	public void AssignTask(int[][] Npc, int Amount) {
    		if(c.TaskId == -1 && c.TaskAmount == -1) {
    			int t = misc.random(Npc.length);
    			int t2 = misc.random(Level1.length);
    				if(Npc[t][1] <= c.playerLevel[18]) {
    					c.DA().npctalking(c, 1597, "Your task is to slay", "Kill: " + c.GetNpcName(Npc[t][0])+"" , "Amount:" + Amount +"", "");
    					c.TaskId = Npc[t][0];
    					c.TaskAmount = Amount;
    				}
    				else
    				c.DA().npctalking(c, 1597, "Your task is to slay", "Kill: " + c.GetNpcName(Level1[t2][0])+"" , "Amount:" + Amount +"", "");
    				c.TaskId = Level1[t2][0];
    				c.TaskAmount = Amount;
    		} else if(c.TaskId != -1 && c.TaskAmount != -1)
    			c.DA().npctalking(c, 1597, "Your task is to slay", "Kill: " + c.GetNpcName(c.TaskId)+"" , "Amount:" + c.TaskAmount +"", "");
    		}
    	}
    I wrote this, but it didn't work for me.

    Code:
    	 if (NPCID == 1596) {
    		Tasks.AssignTask(TaskId(Tasks.AssignTask.t, 0), TaskAmount);
                 }
    Been up for 2 days and am not thinking clearly, but it looks right to me.
    Reply With Quote  
     

  2. #2  
    Registered Member Yodoxin's Avatar
    Join Date
    Sep 2008
    Age
    33
    Posts
    190
    Thanks given
    0
    Thanks received
    10
    Rep Power
    54
    Fix up the first else with some {}s

    Let's see your TaskId(int,int) method?
    *Ahem* I will not be doing that again...
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jan 2010
    Posts
    466
    Thanks given
    259
    Thanks received
    77
    Rep Power
    43
    Quote Originally Posted by Yodoxin View Post
    Fix up the first else with some {}s

    Let's see your TaskId(int,int) method?
    TaskId is a integer.
    Code:
    public int TaskId = -1;

    Just trying to call this method AssignTask(int[][] Npc, int Amount)

    I tried calling it with this
    Code:
    	 if (NPCID == 1596) {
    		Tasks.AssignTask(TaskId(Tasks.AssignTask.t, 0), TaskAmount);
                 }
    TaskId = npc which is what the integer is calling.
    Reply With Quote  
     

  4. #4  
    Member int[][] Check it out. Market Banned


    Luke132's Avatar
    Join Date
    Dec 2007
    Age
    35
    Posts
    12,574
    Thanks given
    199
    Thanks received
    7,106
    Rep Power
    5000
    What happens when you run it?
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Jan 2010
    Posts
    466
    Thanks given
    259
    Thanks received
    77
    Rep Power
    43
    Well, this is what I am trying to use to call that method, which gives 2 errors.

    Code:
    	 if (NPCID == 1596) {
    		Tasks.AssignTask(TaskId(Tasks.AssignTask.t, 0), TaskAmount);
                 }
    The first error I know why its being thrown, because I am trying to call AssignTask as a variable, but the last error I am getting is a non-static method can not be called.

    [root@localhost ServerName]$ ./compiler
    ./server/players/client.java:8169: cannot find symbol
    symbol : variable AssignTask
    location: class server.players.Skills.Tasks
    Tasks.AssignTask(TaskId(Tasks.AssignTask.t, 0), TaskAmount);
    ^
    ./server/players/client.java:8169: non-static method AssignTask(int[][],int) cannot be referenced from a static context
    Tasks.AssignTask(TaskId(Tasks.AssignTask.t, 0), TaskAmount);
    ^

    Note: ./server/server.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint: deprecation for details.
    2 errors
    Mind is just so cloudy right now and having problems thinking.
    Reply With Quote  
     

  6. #6  
    SERGEANT OF THE MASTER SERGEANTS MOST IMPORTANT PERSON OF EXTREME SERGEANTS TO THE MAX!

    cube's Avatar
    Join Date
    Jun 2007
    Posts
    8,872
    Thanks given
    1,854
    Thanks received
    4,745
    Rep Power
    5000
    Make the method static

    Attached image

    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Jan 2010
    Posts
    466
    Thanks given
    259
    Thanks received
    77
    Rep Power
    43
    It's not that, I just need this method

    Code:
    public void AssignTask(int[][] Npc, int Amount)
    wrote into a call, simular to this

    Code:
    AssignTask(TaskId(t, 0), TaskAmount);
    Thats all I need written out.

    So I can use it such as

    Code:
    	 if (NPCID == 1596) {
    		AssignTask(TaskId(t, 0), TaskAmount);
                 }
    Reply With Quote  
     

  8. #8  
    Registered Member

    Join Date
    Feb 2009
    Age
    27
    Posts
    2,861
    Thanks given
    127
    Thanks received
    226
    Rep Power
    700
    Replace your method with this:
    Code:
    	public static void AssignTask(int[][] Npc, int Amount) {
    		if(c.TaskId == -1 && c.TaskAmount == -1) {
    			int t = misc.random(Npc.length);
    			int t2 = misc.random(Level1.length);
    				if(Npc[t][1] <= c.playerLevel[18]) {
    					c.DA().npctalking(c, 1597, "Your task is to slay", "Kill: " + c.GetNpcName(Npc[t][0])+"" , "Amount:" + Amount +"", "");
    					c.TaskId = Npc[t][0];
    					c.TaskAmount = Amount;
    				}
    				else
    				c.DA().npctalking(c, 1597, "Your task is to slay", "Kill: " + c.GetNpcName(Level1[t2][0])+"" , "Amount:" + Amount +"", "");
    				c.TaskId = Level1[t2][0];
    				c.TaskAmount = Amount;
    		} else if(c.TaskId != -1 && c.TaskAmount != -1)
    			c.DA().npctalking(c, 1597, "Your task is to slay", "Kill: " + c.GetNpcName(c.TaskId)+"" , "Amount:" + c.TaskAmount +"", "");
    		}
    	}
    Also, methods should be un-capitalised.
    Reply With Quote  
     

  9. #9  
    Registered Member
    Join Date
    Jan 2010
    Posts
    466
    Thanks given
    259
    Thanks received
    77
    Rep Power
    43
    Quote Originally Posted by Jarba View Post
    Replace your method with this:
    Code:
    	public static void AssignTask(int[][] Npc, int Amount) {
    		if(c.TaskId == -1 && c.TaskAmount == -1) {
    			int t = misc.random(Npc.length);
    			int t2 = misc.random(Level1.length);
    				if(Npc[t][1] <= c.playerLevel[18]) {
    					c.DA().npctalking(c, 1597, "Your task is to slay", "Kill: " + c.GetNpcName(Npc[t][0])+"" , "Amount:" + Amount +"", "");
    					c.TaskId = Npc[t][0];
    					c.TaskAmount = Amount;
    				}
    				else
    				c.DA().npctalking(c, 1597, "Your task is to slay", "Kill: " + c.GetNpcName(Level1[t2][0])+"" , "Amount:" + Amount +"", "");
    				c.TaskId = Level1[t2][0];
    				c.TaskAmount = Amount;
    		} else if(c.TaskId != -1 && c.TaskAmount != -1)
    			c.DA().npctalking(c, 1597, "Your task is to slay", "Kill: " + c.GetNpcName(c.TaskId)+"" , "Amount:" + c.TaskAmount +"", "");
    		}
    	}
    Also, methods should be un-capitalised.
    That shouldn't work ether as that is making everything within the void static, which won't allow those others methods to be called from the client.
    Reply With Quote  
     

  10. #10  
    Registered Member

    Join Date
    Sep 2008
    Posts
    2,219
    Thanks given
    148
    Thanks received
    204
    Rep Power
    1570
    Code:
    private Tasks tasks = new Tasks();
    
    public Tasks getTasks() {
    	return tasks;
    }
    
    if (NPCID == 1596) {
    	getTasks().AssignTask(TaskId(getTasks().AssignTask.t, 0), TaskAmount);
    }



    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

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •