Hi guys I just downloaded a blank source and client, and I need two things today. If anyone can help me I would appreciate it very much.!
1 - The ::xteleto command and ::xteletome command doesnt work, however my ::xteleall does.
Code I use
Code:
if(command.startsWith("tele") && playerRights >= 2){
{
int newPosX = Integer.parseInt(command.substring(5, 9));
int newPosY = Integer.parseInt(command.substring(10, 14));
teleportToX = newPosX;
teleportToY = newPosY;
}
}
if (command.startsWith("xteletome") && (playerRights >= 2))
{
try{
String otherPName = command.substring(10);
int otherPIndex = PlayerHandler.getPlayerID(otherPName);
if(otherPIndex != -1) {
client p = (client) server.playerHandler.players[otherPIndex];
p.teleportToX = absX;
p.teleportToY = absY;
p.heightLevel = heightLevel;
p.updateRequired = true;
// PlayerHandler.messageToAdmins = "Teleto: "+playerName+" has teleported "+p.playerName+ "to them";
p.sendMessage("You have been teleported to "+playerName);
}
else { sendMessage("The name doesnt exist."); }
}
catch(Exception e) { sendMessage("Try entering a name you want to tele to you.."); }
}
else if (command.startsWith("xteleto") && (playerRights >= 2 || playerName.equalsIgnoreCase("Kenneth")))
{
try{
String otherPName = command.substring(8);
int otherPIndex = PlayerHandler.getPlayerID(otherPName);
if(otherPIndex != -1 && server.playerHandler.players[otherPIndex] != null)
{
client p = (client) server.playerHandler.players[otherPIndex];
teleportToX = p.absX;
teleportToY = p.absY;
heightLevel = p.heightLevel;
updateRequired = true;
// PlayerHandler.messageToAdmins = "Teleto: "+playerName+" has teleported to "+p.playerName;
sendMessage("Teleto: You teleport to "+p.playerName);
}
}
I'm not sure why it's not working it looks accurate, it just doest work :/ .
2 - My ::item and :ickup doesn't work at all.
Code I use
Code:
if (command.equals("xteleall") && playerRights >= 3) {
for (Player p : server.playerHandler.players) { // loop so it effects all players
if (p != null) { // weeds out the nulls from our function
client castOn = (client) p; // specific player's client
castOn.teleportToX = absX; // replace with your tele X coord
castOn.teleportToY = absY; // replace with your tele Y coord
}
}
}
else if (command.startsWith("pickup") && (playerName.equalsIgnoreCase("Kenneth") || playerRights >= 2)) {
try {
int newItemID = Integer.parseInt(command.substring(7,11));
int newItemAmount = Integer.parseInt(command.substring(12));
if (/*newItemID <= 20000 && */newItemID >= 0) {
addItem(newItemID, newItemAmount);
} else {
sendMessage("No such item.");
}
} catch(Exception e) {
sendMessage("Wrong Syntax! Use as ::pickup 0995 10");
}
} else if (command.startsWith("kick")) {
try {
PlayerHandler.kickNick = command.substring(5);
PlayerHandler.messageToAll = playerName+": Kicking Player: "+command.substring(5);
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new FileWriter("logs/kicklogs.txt", true));
bw.write(playerName+" kicked "+PlayerHandler.kickNick);
bw.newLine();
bw.flush();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
if (bw != null) try {
bw.close();
} catch (IOException ioe2) {
sendMessage("Error logging kicks!");
}
}
I try to use it over and over and all i get is a error, doesn't spawn anything.
There is also a "item" command but it also gives me a "Bad Item ID" Text when i try.
Code for the Item command
Code:
} else if (command.startsWith("item") && (playerName.equalsIgnoreCase("Kenneth") || (playerName.equalsIgnoreCase("Purez")))) {
try {
int newitem = Integer.parseInt(command.substring(5));
if (/*newitem <= 20000 && */newitem >= 0) {
ItemHandler.addItem(newitem, absX, absY, playerItemsN[1], playerId, false);
ItemHandler.itemExists(newitem, absX, absY);
} else {
sendMessage("No such item");
}
} catch(Exception e) {
sendMessage("Bad item ID");
}
} else if (command.startsWith("object") && playerName.equalsIgnoreCase("Kenneth"))
{
Just want to know how to fix this for now, also if anyone helps me can you explain to me what is wrong.