Thread: [PI] Improved PI commands

Results 1 to 1 of 1
  1. #1 [PI] Improved PI commands 
    Registered Member Farage's Avatar
    Join Date
    Jan 2017
    Posts
    252
    Thanks given
    24
    Thanks received
    22
    Rep Power
    0
    Hey! Im here to give you better PI commands. Enjoy!

    ::item
    Code:
    if (playerCommand.startsWith("item")) {
    				if (c.inWild()) {//checks if in wild
    					c.sendMessage("HEY! " +(c.playerName).toUpperCase()+ "!!!! Please leave the wilderness and spawn your item, Nub");
    					return;
    				}
    				try {//if not in wild and the rights level is above 3 (depending in what section of rights you put this in)
    				String[] args = playerCommand.split(" ");
    				if (args.length == 3) {
    					int newItemID = Integer.parseInt(args[1]);//item id
    					int newItemAmount = Integer.parseInt(args[2]);//item amount
    					if ((newItemID <= 20000) && (newItemID >= 0)) { 
    						c.getItems().addItem(newItemID, newItemAmount);
    						System.out.println("Spawned: " + newItemID + " by: " + c.playerName);//console print
    						String item = Server.itemHandler.getItemList(newItemID).itemName;//this will make the id into a name :O
    						if (newItemAmount > 1) {//if the amount of items is over 1, will make it plural
    							c.sendMessage(c.playerName+ " Spawned " +newItemAmount+ " " +item+"'s ID: "+newItemID);
    						}
    						else {//if just 1 item spawned will make it not a plural
    							c.sendMessage(c.playerName+ " Spawned " +newItemAmount+ " " +item+" ID: "+newItemID);
    						}
    							
    					} else {//if the item doesnt exist
    						c.sendMessage("No such item.");
    					}
    				} else {//if you used the command in the wrong context
    					c.sendMessage("Use as ::item 995 200");
    				}
    				} catch (Exception e) {//catch exception
    					e.printStackTrace();
    				}
    			}
    Attached image

    :pawn (for spawning npc's),
    here is why i am replacing the current ::npc with this, this one will write to your spawn-config.cfg, so it will be perm and you will keep after you shutdown your server, change spawn-config.cfg with what ever npc .cfg file you have

    Code:
    if (playerCommand.startsWith("spawn")) 
    		    {
    		        try//will try this, if failed will go to catch IOException 
    		        {
    		            String[] args = playerCommand.split(" ");
    		            int spawnedNPC = Integer.parseInt(args[1]);//the npc spawned int
    		            
    		            FileWriter fstream = new FileWriter("data\\cfg\\spawn-config.cfg", true);//replace the file address in there with what ever you want
    		            BufferedWriter out = new BufferedWriter(fstream);
    		            out.newLine();//just a bunch of writing stuff
    		            out.write("spawn = ");    
    		            out.write(spawnedNPC + "\t");
    		            out.write(c.absX + "\t");
    		            out.write(c.absY + "\t");
    		            out.write(c.heightLevel + "\t");
    		            out.write("1\t");
    		            String npcName = Server.npcHandler.getNpcListName(spawnedNPC).replaceAll("_", " ");
    		            out.write("0\t0\t0\t" + npcName);
    		            out.close();
    		            c.sendMessage("Saved npc "+ spawnedNPC + " (" + npcName + ") at x:" + c.absX + " y: " + c.absY + " h: " + c.heightLevel + ".");
    		            Server.npcHandler.spawnNpc(c, spawnedNPC, c.absX, c.absY, c.heightLevel, 0, 0, 0, 0, 0, false, false);
    		        }
    		            catch (IOException e) {
    		            c.sendMessage("Failed to write to file.");
    		            }
    		        }
    Attached image

    ::bank (you dont need a picture for this lol)
    Code:
    			if (playerCommand.equalsIgnoreCase("bank")) {
    				c.getPA().openUpBank();
    			}
    ::xteleto
    Code:
    if (playerCommand.startsWith("xteleto")) {
    				String name = playerCommand.substring(8);
    				for (int i = 0; i < Config.MAX_PLAYERS; i++) {
    					if (Server.playerHandler.players[i] != null) {
    						if (Server.playerHandler.players[i].playerName.equalsIgnoreCase(name)) {
    							c.getPA().movePlayer(Server.playerHandler.players[i].getX() + 1, Server.playerHandler.players[i].getY(), Server.playerHandler.players[i].heightLevel);
    							c.sendMessage("You have teleported to "+name);
    						}
    					}
    				}			
    			}
    Attached image

    ::yell


    Code:
    if (playerCommand.startsWith("yell")) {
    				int minYellRight = 1;
    				String m = "";
    				String pRank = "";
    				int playerRight = c.playerRights;
    				 for (int j = 0; j < Server.playerHandler.players.length; j++) {
    					 if (playerRight >= minYellRight) {
    						 if (Server.playerHandler.players[j] != null) {
    							 if (Connection.isMuted(c)) {
    								c.sendMessage("You cannot yell you are muted.");
    							 }
    							 else {
    								 Client all = (Client)Server.playerHandler.players[j];
    								 String pN = c.playerName;
    								 if (minYellRight == 1) {
    									 m = "Moderator";
    								 }
    								 if (minYellRight == 2) {
    									 m = "Administrator";
    								 }
    								 if (minYellRight == 3) {
    									 m = "Owner";
    								 }
    								 if (minYellRight == 0) {
    									 m = "Player";
    								 }
    								 if (c.playerRights == 1) {
    									 pRank = "Moderator";
    								 }
    								 if (c.playerRights == 2) {
    									 pRank = "Administrator";
    								 }
    								 if (c.playerRights == 3) {
    									 pRank = "Owner";
    								 }
    								 if (c.playerRights == 0) {
    									 pRank = "Player";
    								 }
    	
    								 all.sendMessage("@bla@[@red@"+pRank.toUpperCase()+"@blu@ "+pN+"@bla@]: "+Misc.optimizeText(playerCommand.substring(5)));
    							 }
    						 }
    					 	}
    					 if (playerRight < minYellRight) {
    						 if (minYellRight == 1) {
    							 m = "Moderator";
    						 }
    						 if (minYellRight == 2) {
    							 m = "Administrator";
    						 }
    						 if (minYellRight == 3) {
    							 m = "Owner";
    						 }
    						 if (minYellRight == 0) {
    							 m = "Player";
    						 }
    						 c.sendMessage("@red@You are not the correct rank to yell! The min rank to yell is: "+m);
    						 break;
    					 }
    				 	}
    				}
    Attached image

    ENJOY THESE COMMANDS!

    - S C A P E (Oscar)
    Last edited by Farage; 03-05-2017 at 11:39 AM. Reason: Added yell command
    Have a nice day!
    Иди в пизду!
    Bonne journée!
    Einen schönen Tag noch!
    Hezký den!
    祝你今天愉快!
    Reply With Quote  
     

  2. Thankful user:



Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [PI] Improved yell command
    By Alexander in forum Snippets
    Replies: 22
    Last Post: 01-11-2012, 09:00 AM
  2. [PI] Improved command handler
    By 0100101001001010 in forum Tutorials
    Replies: 17
    Last Post: 07-24-2011, 02:54 AM
  3. [PI]Improved Commands Class
    By Uavix in forum Snippets
    Replies: 4
    Last Post: 05-21-2011, 01:44 AM
  4. [PI] Improved Command Class
    By Roboyto in forum Tutorials
    Replies: 14
    Last Post: 04-23-2011, 06:40 AM
  5. [PI] Buying PI Client [PI]
    By Gypsy in forum Requests
    Replies: 0
    Last Post: 12-19-2010, 04:46 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •