Advertisement
thedeadman782004

MC Spawn Quest Rewards CNPC Script

Feb 16th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. //Change this for each quest
  2. var questID = 106;
  3. //Change this in all 4 places in this script and for each quest
  4. var QB106 = 0;//Initialize QB106. Change the name for different quests
  5. var searchRadius = 10;
  6. var entityType = 1;//Type 1 for players
  7.  
  8. function init(event) {
  9. event.npc.world.getTempdata().put(QB106,0);
  10. }
  11.  
  12. //This function finds the player, checks if they have completed the given quest and spawns rewards if they have.
  13. function interact(event) {
  14. var nearestPlayer = event.npc.world.getNearbyEntities(event.npc.getX(),event.npc.getY(),event.npc.getZ(),searchRadius,entityType)[0];
  15. if (!nearestPlayer.hasFinishedQuest(questID) && event.npc.world.getTempdata().get(QB106) == 1) {
  16. event.npc.world.getTempdata().put(QB106,0);//If the quest has been reset on the player but QB106 is still 1, also reset QB106
  17. }
  18. if (nearestPlayer.hasFinishedQuest(questID) && event.npc.world.getTempdata().get(QB106) == 0) {
  19. event.npc.executeCommand(/*MC command*/);
  20. //...More commands here.
  21. event.npc.world.getTempdata().put(QB106,1);
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement