I think you don't understand PI yet.
It already does that.
|
hi i was wondering if anyone could help me, i'm trying to make it so on my commands, i can do something like this,
"public void Owner && c.playerRights = 3 {
}" i know that would probably never work, but its just an example to show you what i mean, now what i'm wanting is now i can put in all the commands i want to be owner only to be inside those brackets after playerRights = 3, so i don't have to continuously type c.playerRights= whatever, after each code, also it will help organize it so its not all mombo jumbo, so can anyone help me format this or show me how to do this?
P.S. also can anyone tell me how i can make that text box where u can enter code? i never found out how to do that.. like the place you put stuff like "public void" yada yada, thanks
I think you don't understand PI yet.
It already does that.
well tbh i'm completely new so obvious i wouldn't understand that's why i asked for help, and my commands.java doesn't do that....its a cleaned pi source so it has nothing.. just this-
"package server.model.player.packets;
import server.Settings;
import server.GameEngine;
import server.model.player.Client;
import server.model.player.PacketType;
import server.util.Misc;
/**
* Commands
**/
public class Commands implements PacketType {
@Override
public void processPacket(Client c, int packetType, int packetSize) {
String playerCommand = c.getInStream().readString();
Misc.println(c.playerName + " playerCommand: " + playerCommand);
if (Settings.SERVER_DEBUG)
if (playerCommand.startsWith("/") && playerCommand.length() > 1) {
if (c.clanId >= 0) {
System.out.println(playerCommand);
playerCommand = playerCommand.substring(1);
GameEngine.clanChat.playerMessageToClan(c.playerId ,
playerCommand, c.clanId);
} else {
if (c.clanId != -1)
c.clanId = -1;
c.sendMessage("You are not in a clan.");
}
return;
}
// player commands
{
if (playerCommand.equals("home") && c.playerRights >= 0) {
c.getPA().startTeleport(3087, 3502, 0, "modern");
}
// donator commands
// moderator commands
// admin commands
if (playerCommand.startsWith("item") && c.playerRights >= 2) {
try {
String[] args = playerCommand.split(" ");
if (args.length == 3) {
int newItemID = Integer.parseInt(args[1]);
int newItemAmount = Integer.parseInt(args[2]);
if ((newItemID <= 20000) && (newItemID >= 0)) {
c.getItems().addItem(newItemID, newItemAmount);
} else {
c.sendMessage("No such item.");
}
} else {
c.sendMessage("Use as ::item id amount.");
}
} catch (Exception e) {
}
}
// owner commands
}
}
}
If your new, don't use a clean PI then.
The Java™ Tutorials
That link will lead you to all of the information you need to know.
fml, i'm already in the process of watching java guides and learning the basic language and how to do things, but i still want to work on my private server as i go so i can apply what i'm learning, why post a reply if your not actually trying to help answer the question i asked? makes no sense at all don't understand why it's so hard just to help someone whos new out...
Replace your commands.java with that. But you will need to add in your own commands into the brackets itself.
Note; Change the number that is in RED to your owner rank id. Kind of luck Administrators are 2. My guess would be owners are 3.
Best of luck to you.
Code:package server.model.player.packets; import server.Settings; import server.GameEngine; import server.model.player.Client; import server.model.player.PacketType; import server.util.Misc; /** * Commands **/ public class Commands implements PacketType { @Override public void processPacket(Client c, int packetType, int packetSize) { String playerCommand = c.getInStream().readString(); Misc.println(c.playerName + " playerCommand: " + playerCommand); if (Settings.SERVER_DEBUG) if (playerCommand.startsWith("/") && playerCommand.length() > 1) { if (c.clanId >= 0) { System.out.println(playerCommand); playerCommand = playerCommand.substring(1); GameEngine.clanChat.playerMessageToClan(c.playerId , playerCommand, c.clanId); } else { if (c.clanId != -1) c.clanId = -1; c.sendMessage("You are not in a clan."); } return; } // player commands { if (playerCommand.equals("home") && c.playerRights >= 0) { c.getPA().startTeleport(3087, 3502, 0, "modern"); } // donator commands // moderator commands // admin commands if (playerCommand.startsWith("item") && c.playerRights >= 2) { try { String[] args = playerCommand.split(" "); if (args.length == 3) { int newItemID = Integer.parseInt(args[1]); int newItemAmount = Integer.parseInt(args[2]); if ((newItemID <= 20000) && (newItemID >= 0)) { c.getItems().addItem(newItemID, newItemAmount); } else { c.sendMessage("No such item."); } } else { c.sendMessage("Use as ::item id amount."); } } catch (Exception e) { } } // owner commands if (playerCommand.startsWith("item") && c.playerRights >= 3) { try { String[] args = playerCommand.split(" "); if (args.length == 3) { int newItemID = Integer.parseInt(args[1]); int newItemAmount = Integer.parseInt(args[2]); if ((newItemID <= 20000) && (newItemID >= 0)) { c.getItems().addItem(newItemID, newItemAmount); } else { c.sendMessage("No such item."); } } else { c.sendMessage("Use as ::item id amount."); } } catch (Exception e) { } } }
Teach him to leech pl0x
OT:
You could do something like
Code:if (c.playerRights >= 0) { //normal+ commands //ADD COMMANDS FOR NORMAL PLAYERS HERE } if (c.playerRights >= 1) { //mod+ commands //ADD COMMANDS FOR mod+ HERE } if (c.playerRights >= 2) { //admin+ commands //ADD COMMANDS FOR admin+ HERE } if (c.playerRights == 3) { //owner commands //ADD COMMANDS FOR owners HERE }
Code:/** * PLAYER COMMANDS */ if (c.playerRights >= 0) { playerCommands(c, playerCommand); }This makes it so you don't have to use && c.playerRights == ...; every time after a command.Code:public void playerCommands(final Client c, String playerCommand) { //code here }
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |