Jump to content
  • 0
Itscadle

[718] Adding a pvp timer when walking from SafeZone to SafePvP tile

Question

Basically I have a pvp server and it uses this class file SafeZone to determine whether you are in an area that you can attack in/be attacked in, or if you are in an area where you cannot be attacked, and I am wanting to add a pvp timer so if someone runs out of the pvp area they can still be attacked for up to 10 seconds, to prevent people from rushing and then running away.

 
package com.rain.game.player;


 

public class SafeZone {
    
    public static boolean playerTiles(Player player) {
        if (edgeBank(player) 
                || grandExchange(player) 
                || varrockBank(player)
                || varrockEastBank(player)
                || camelot(player)
                || camelot2(player)
                || lumbridge(player)
                || falador(player)
                || faladorEast(player)
                || ardy(player)
                || ardy2(player) 
                || port(player)
                || abovetower(player)
                || brandnewhome(player)) {
                player.setCanPvp(false);
                SafeZonenopvp(player);
        } else {
                player.setCanPvp(true);
                SafePvP(player);
            
        }
        return true;
    }
    
    public static boolean SafeZonenopvp(Player player) {
        player.getInterfaceManager().sendTab(player.getInterfaceManager().hasRezizableScreen() ? 34 : 0, 10);
        player.getPackets().sendIComponentText(10, 1, "<col=00FF00>SafeZone (No PvP)");
        player.getPackets().sendIComponentText(10, 2, "<col=FFFFFF> ");
        return true;
        }
    
    public static boolean SafePvP(Player player) {
        player.getInterfaceManager().sendTab(player.getInterfaceManager().hasRezizableScreen() ? 34 : 0, 10);
        player.getPackets().sendIComponentText(10, 1, "<col=00FF00>Safe PvP");
        player.getPackets().sendIComponentText(10, 2, "<col=FFFFFF> ");
        return true;
    }
    
    //edge
         public static boolean edgeBank(Player player) { 
            return (player.getX() > 3090 && player.getY() < 3500
                && player.getX() < 3099 && player.getY() > 3487);
                 }
         
        //grand exchange 
         public static boolean grandExchange(Player player) { 
             return (player.getX() > 3143 && player.getY() < 3513
                && player.getX() < 3186 && player.getY() > 3471);
        }

    //varrock west bank
         public static boolean varrockBank(Player player) { 
             return (player.getX() > 3178 && player.getY() < 3447
                && player.getX() < 3195 && player.getY() > 3431);
         }
         
    //varrock east bank
         public static boolean varrockEastBank(Player player) { 
             return (player.getX() > 3249 && player.getY() < 3426
                && player.getX() < 3259 && player.getY() > 3413);
        }
         
    //camelot
         public static boolean camelot(Player player) { 
             return (player.getX() > 2718 && player.getY() < 3498
                && player.getX() < 2731 && player.getY() > 3486);
        }
         
    //cammy2
         public static boolean camelot2(Player player) { 
             return (player.getX() > 2805 && player.getY() < 3446
                && player.getX() < 2813 && player.getY() > 3437);
        }

    //lummy
         public static boolean lumbridge(Player player) { 
             return (player.getX() > 3201 && player.getY() < 3237
                && player.getX() < 3229 && player.getY() > 3200);
        }
         
    //fally
         public static boolean falador(Player player) { 
             return (player.getX() > 2942 && player.getY() < 3374
                && player.getX() < 2950 && player.getY() > 3367);
        }

    //fally2     
         public static boolean faladorEast(Player player) { 
             return (player.getX() > 3008 && player.getY() < 3359
                && player.getX() < 3020 && player.getY() > 3352);
        }
        
        //Port Phasmatys3699 3471 3686 3461
             public static boolean port(Player player) { 
                 return (player.getX() > 3685 && player.getY() < 3472
                && player.getX() < 3700 && player.getY() > 3460);
        }

            //abovetowerhome 2876 3552 -- 2845 3533
             public static boolean abovetower(Player player) { 
                 return (player.getX() > 2844 && player.getY() < 3552
                && player.getX() < 2876 && player.getY() > 3531);
        }    
             
             
            //Brand New Home
             public static boolean brandnewhome(Player player) { 
                 return (player.getX() > 3413 && player.getY() < 3179
                && player.getX() < 3452 && player.getY() > 3147);
        }     
             
    //ardy
             public static boolean ardy(Player player) { 
                 return (player.getX() > 2611 && player.getY() < 3336
                && player.getX() < 2622 && player.getY() > 3329);
        }
         
    //ardy2
         public static boolean ardy2(Player player) { 
             return (player.getX() > 2648 && player.getY() < 3288
                && player.getX() < 2659 && player.getY() > 3279);
         }
} [/CODE]

Where SafeZone is utilitized in World.java

if (entity instanceof Player) {

			                Player player = (Player) entity;

			                SafeZone.playerTiles(player);

			                player.getControlerManager().moved();

			                if (player.hasStarted())

			                    checkControlersAtMove(player);

			            }

			            entity.checkMultiArea(); [/CODE]
		

		


I found this in the files and I don't know if it could be used but just incase

private void addAttackedByDelay(Entity player) {
        target.setAttackedBy(player);
        target.setAttackedByDelay(Utils.currentTimeMillis() + 5000); // 8seconds
    } [/CODE]

 

 

Edited by Itscadle

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×