Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Area data list
- var lpl = [
- {
- //Regional location (p1 must be smaller than p2)
- p1:{x:0, y:0, z:0},
- p2:{x:10, y:10, z:10},
- //Enter
- enterMsg:{
- title: "Enter Danger Area",
- subtitle: "Be careful",
- actionbar: "Enter Area: Danger area",
- message: "You have been enter danger area, be careful.",
- notificationTitle: "Entering Danger Area",
- notificationSubtitle: "Do you feel fear?"
- },
- //Leave
- leaveMsg:{
- title: "Leave Danger Area",
- actionbar: "Leave Area: Danger area",
- message: "You were leaving danger area.",
- notificationTitle: "Leaving Danger Area"
- }
- }
- ];
- //Clear data when player exit the game, so can log in and display again next time.
- function logout(e){
- var pt = e.player.tempdata;
- if(pt.has("lp")) pt.remove("lp");
- }
- function tick(e){
- var p = e.player;
- var pt = p.tempdata;
- if(!pt.has("lp")) pt.put("lp", new Array());
- for(var i in lpl){
- var msg = null;
- var tc = pt.get("lp");
- var tq = tc.indexOf(i);
- if( (lpl[i].p1.x<p.x && p.x<lpl[i].p2.x) && (lpl[i].p1.y<p.y && p.y<lpl[i].p2.y) && (lpl[i].p1.z<p.z && p.z<lpl[i].p2.z) ){
- if(tq==-1){
- var msg = lpl[i].enterMsg;
- tc.push(i);
- pt.put("lp", tc);
- }
- }else{
- if(tq!=-1){
- var msg = lpl[i].leaveMsg;
- tc.splice(tq,1);
- pt.put("lp", tc);
- }
- }
- if(msg!=null){
- if(msg.title!=null) {
- e.API.executeCommand(p.world, "/title " + p.displayName + " title {\"text\":\"" + msg.title + "\"}");
- e.API.executeCommand(p.world, "/title " + p.displayName + " subtitle {\"text\":\"" + ((msg.subtitle!=null)?msg.subtitle:"") + "\"}");
- }
- if(msg.actionbar!=null) e.API.executeCommand(p.world, "/title " + p.displayName + " actionbar {\"text\":\"" + msg.actionbar + "\"}");
- if(msg.message!=null) p.message(msg.message);
- if(msg.notificationTitle!=null) p.sendNotification(msg.notificationTitle, ((msg.notificationSubtitle!=null)?msg.notificationSubtitle:""), 2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement