What's wrong with this? (String VS String telling me it needs to be left sided)

Automatic

User is banned.
Reputation
0
Code:
import com.rsbuddy.script.ActiveScript;
import com.rsbuddy.script.methods.Game;
import com.rsbuddy.script.methods.Npcs;
import com.rsbuddy.script.methods.Players;
import com.rsbuddy.script.wrappers.Npc;


public class combatTest extends ActiveScript {

	
	@Override
	public int loop() {
		if(Game.isLoggedIn()) {
			if(!Players.getLocal().isInCombat()) {
				if(!Players.getLocal().isMoving()) {
					Npc[] allNpcs = Npcs.getLoaded();
					for(int i = 0; i <= allNpcs.length; i++) {
						if(allNpcs[i].getName() = "Goblin") {
							if(!allNpcs[i].isInCombat()) {
								allNpcs[i].interact("Attack Goblin");
							}
						}
					}
				}
			}
		}
		return 0;
	}

}

The line "if(allNpcs.getName() = "Goblin") {" tells me "Goblin" needs to be left-sided. Probably something stupid, I've been stupid the last few days.

EDIT: meant to be botting forum, I fail at choosing forums :(

/move

 
= is to set variables.
== Parenthesis is to check if equal to.

Code:
if(allNpcs[i].getName() == "Goblin") {
                            if(!allNpcs[i].isInCombat()) {
                                allNpcs[i].interact("Attack Goblin");
                            }
                        }
 
Yeah, I worked that out on runegear D:

Also, I started using .equals("string");

After typing ; I automatically pressed control + S, I save WAY to much
 
Automatic Coding said:
Yeah, I worked that out on runegear D:

Also, I started using .equals("string");

After typing ; I automatically pressed control + S, I save WAY to much

I saw your thread on RSBuddy :p


Yeah, when you code for quite a bit of time, CTRL + S goes into your sub-conscious and you do it automatically without thinking.
 
Chewbaka said:
Automatic Coding said:
Yeah, I worked that out on runegear D:

Also, I started using .equals("string");

After typing ; I automatically pressed control + S, I save WAY to much

I saw your thread on RSBuddy :p


Yeah, when you code for quite a bit of time, CTRL + S goes into your sub-conscious and you do it automatically without thinking.

I meant rsbuddy...

Also, how do I use bank? That's been removed to >.>

EDIT: Different import, org/widgets and not com/wrapper.

/close.
 
Automatic Coding said:
Chewbaka said:
Automatic Coding said:
Yeah, I worked that out on runegear D:

Also, I started using .equals("string");

After typing ; I automatically pressed control + S, I save WAY to much

I saw your thread on RSBuddy :p


Yeah, when you code for quite a bit of time, CTRL + S goes into your sub-conscious and you do it automatically without thinking.

I meant rsbuddy...

Also, how do I use bank? That's been removed to >.>

EDIT: Different import, org/widgets and not com/wrapper.

/close.



Yeah, I don't have to worry about those imports since Eclipse automatically gets their docs and will tell me what to import and do it for me :D
 
Chewbaka said:
Automatic Coding said:
Chewbaka said:
I saw your thread on RSBuddy :p


Yeah, when you code for quite a bit of time, CTRL + S goes into your sub-conscious and you do it automatically without thinking.

I meant rsbuddy...

Also, how do I use bank? That's been removed to >.>

EDIT: Different import, org/widgets and not com/wrapper.

/close.



Yeah, I don't have to worry about those imports since Eclipse automatically gets their docs and will tell me what to import and do it for me :D



Yeah but when there's two types (bank = org/widgets and bank = com/widgets) it normally picks the wrong one to put at the top of the list (alphabetical I think)
 
Back
Top