How to create custom quests using skript?

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.
Code:
on arm swing: # Sets the variable so players can use it
  if {zombieskilled::%player%} is not set:
    set {zombieskilled::%player%} to 0
    
command /quests: # Quest gui
  trigger:
    if {zombieskilled::%player%} < 10:
      set {_quests} to a new chest inventory with 1 rows with name "&6&nQuests"
      set slot 4 of {_quests} to zombie head named "&n&2Zombie &n&cKiller"
      open {_quests} to player
      set line 1 of slot 4 of current inventory of player's lore to "&4(%{zombieskilled::%player%}%&4/10)"
      set line 2 of slot 4 of current inventory of player's lore to "&7Not completed"
    else if {zombieskilled::%player%} = 10:
      if {zombiekillerrewardquest::%player%} is not set:
        set {_quests} to a new chest inventory with 1 row with name "&6&nQuests"
        set slot 4 of {_quests} to zombie head named "&n&2Zombie &n&cKiller"
        open {_quests} to player
        set line 1 of slot 4 of current inventory of player's lore to "&4&l(10/10)"
        set line 2 of slot 4 of current inventory of player's lore to "&aCompleted!"
        set line 3 of slot 4 of current inventory of player's lore to "&bClick to recieve the reward!"
      else:
        set {_quests} to a new chest inventory with 1 row with name "&6&nQuests"
        set slot 4 of {_quests} to zombie head named "&n&2Zombie &n&cKiller"
        open {_quests} to player
        set line 1 of slot 4 of current inventory of player's lore to "&4&l(10/10)"
        set line 2 of slot 4 of current inventory of player's lore to "&aCompleted!"
        set line 3 of slot 4 of current inventory of player's lore to "&cYou already recieved your reward!"
        
on death: # Quest amount adder
  if victim is zombie:
    if {zombieskilled::%attacker%} < 10:
      add 1 to {zombieskilled::%attacker%}
      
on inventory click: # Reward
  if player's current inventory's name is "&6&nQuests":
    cancel event
    if click slot is 4:
      if {zombieskilled::%player%} = 10:
        if {zombiekillerrewardquest::%player%} is not set:
          give player a wooden sword named "&2&nZombie &c&nKiller"
          set {zombiekillerrewardquest::%player%} to true
          close player's inventory
        else:
          send "&cYou already recieved this reward!" to player
          close player's inventory

I made this example it's mostly using player's specific variables and counters
 
Code:
on arm swing: # Sets the variable so players can use it
  if {zombieskilled::%player%} is not set:
    set {zombieskilled::%player%} to 0
   
command /quests: # Quest gui
  trigger:
    if {zombieskilled::%player%} < 10:
      set {_quests} to a new chest inventory with 1 rows with name "&6&nQuests"
      set slot 4 of {_quests} to zombie head named "&n&2Zombie &n&cKiller"
      open {_quests} to player
      set line 1 of slot 4 of current inventory of player's lore to "&4(%{zombieskilled::%player%}%&4/10)"
      set line 2 of slot 4 of current inventory of player's lore to "&7Not completed"
    else if {zombieskilled::%player%} = 10:
      if {zombiekillerrewardquest::%player%} is not set:
        set {_quests} to a new chest inventory with 1 row with name "&6&nQuests"
        set slot 4 of {_quests} to zombie head named "&n&2Zombie &n&cKiller"
        open {_quests} to player
        set line 1 of slot 4 of current inventory of player's lore to "&4&l(10/10)"
        set line 2 of slot 4 of current inventory of player's lore to "&aCompleted!"
        set line 3 of slot 4 of current inventory of player's lore to "&bClick to recieve the reward!"
      else:
        set {_quests} to a new chest inventory with 1 row with name "&6&nQuests"
        set slot 4 of {_quests} to zombie head named "&n&2Zombie &n&cKiller"
        open {_quests} to player
        set line 1 of slot 4 of current inventory of player's lore to "&4&l(10/10)"
        set line 2 of slot 4 of current inventory of player's lore to "&aCompleted!"
        set line 3 of slot 4 of current inventory of player's lore to "&cYou already recieved your reward!"
       
on death: # Quest amount adder
  if victim is zombie:
    if {zombieskilled::%attacker%} < 10:
      add 1 to {zombieskilled::%attacker%}
     
on inventory click: # Reward
  if player's current inventory's name is "&6&nQuests":
    cancel event
    if click slot is 4:
      if {zombieskilled::%player%} = 10:
        if {zombiekillerrewardquest::%player%} is not set:
          give player a wooden sword named "&2&nZombie &c&nKiller"
          set {zombiekillerrewardquest::%player%} to true
          close player's inventory
        else:
          send "&cYou already recieved this reward!" to player
          close player's inventory

I made this example it's mostly using player's specific variables and counters

Few things to note here:
You shouldn't check a variable every time a player swings their arm. Instead, you could set the variable on first join or even on join.
Next, you should check if the attacker is player before proceeding to check and add to variables.
And of course, use player UUID's instead of names.
 
Status
Not open for further replies.