1. 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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Logout Villager

Discussion in 'Requests' started by Computerize, Dec 22, 2019.

  1. Computerize

    Computerize Member

    Joined:
    Oct 10, 2019
    Messages:
    38
    Likes Received:
    0
    Ok, so I would like a skript that if there are people in a 200 block radius or combat timer is true and the person logout a villager will spawn named "&c%player%& &7(Logout Villager)". When this villager is killed, the player's inventory is dropped and when the player logs back on they are TPed to spawn and their inventory and armor is cleared. When the villager dies it will also set {pvpTimer.%player%} to 1800 and will set {deathBan.%player%} to 600. Hopefully someone can help me, thanks! Also please make the villager have no AI.

    Here is my current PvP Timer Skript:
    Code (Text):
    1. on damage of player:
    2.   if attacker is a player:
    3.     if {combatTag.%attacker%} isn't set:
    4.       send "&cYou are now in combat." to attacker
    5.       set {combatTag.%attacker%} to 30
    6.     else:
    7.       set {combatTag.%attacker%} to 30
    8. on damage of player:
    9.   if attacker is a player:
    10.     if {combatTag.%victim%} isn't set:
    11.       send "&cYou are now in combat." to victim
    12.       set {combatTag.%victim%} to 30
    13.     else:
    14.       set {combatTag.%victim%} to 30
    15. every second:
    16.   loop all players:
    17.     if {combatTag.%loop-player%} is set:
    18.       if {combatTag.%loop-player%} > 0:
    19.         remove 1 from {combatTag.%loop-player%}
    20.       else:
    21.         delete {combatTag.%loop-player%}
    22.         send "&aYou are no longer in combat." to loop-player
    23. on command:
    24.   if {combatTag.%player%} is set:
    25.     cancel event
    26.     send "&cYou cannot use commands while in combat."
    27.  
     
  2. Goose

    Supporter

    Joined:
    Nov 23, 2019
    Messages:
    429
    Likes Received:
    30
    Assuming your combat tag skript works, here you go!
    Code (Text):
    1. on damage of player:
    2.   if attacker is a player:
    3.     if {combatTag.%attacker%} isn't set:
    4.       send "&cYou are now in combat." to attacker
    5.       set {combatTag.%attacker%} to 30
    6.     else:
    7.       set {combatTag.%attacker%} to 30
    8. on damage of player:
    9.   if attacker is a player:
    10.     if {combatTag.%victim%} isn't set:
    11.       send "&cYou are now in combat." to victim
    12.       set {combatTag.%victim%} to 30
    13.     else:
    14.       set {combatTag.%victim%} to 30
    15. every second:
    16.   loop all players:
    17.     if {combatTag.%loop-player%} is set:
    18.       if {combatTag.%loop-player%} > 0:
    19.         remove 1 from {combatTag.%loop-player%}
    20.       else:
    21.         delete {combatTag.%loop-player%}
    22.         send "&aYou are no longer in combat." to loop-player
    23. on command:
    24.   if {combatTag.%player%} is set:
    25.     cancel event
    26.     send "&cYou cannot use commands while in combat."
    27. on disconnect:
    28.     if {combattag.%player%} is set:
    29.         spawn a villager
    30.         set {combatvillager::%spawned villager%::%player's uuid%::*} to true
    31.         set the name of the spawned villager to "%event-player%"
    32.         add "{NoAI:1}" to nbt of last spawned entity
    33.         set {inventory::%player's uuid%::*} to all items in player's inventory
    34.         set {logged.%player's uuid%} to true
    35. on death:
    36.     if victim is a villager:
    37.         if {combatvillager::%victim%::%player's uuid%::*} is true:
    38.             drop all items in inventories {inventory::%player's uuid%::*}
    39.             set {killed.%player's uuid%} to true
    40. on join:
    41.     if {logged.%player's uuid%} is true:
    42.         if {killed.%player's uuid%} is true:
    43.             clear player's inventory
    44.             set {logged.%player's uuid%} to false
    45.             set {killed.%player's uuid%} to false
    Have a good day.
     
  3. Computerize

    Computerize Member

    Joined:
    Oct 10, 2019
    Messages:
    38
    Likes Received:
    0
    Thanks so much man.
     
  4. Goose

    Supporter

    Joined:
    Nov 23, 2019
    Messages:
    429
    Likes Received:
    30
    No problem! :emoji_grinning: Make sure to mark this as solved!

    If you need any more help, you can contact me here in a conversation or add me on Discord. My tag is The Goose#1832.
     
  5. Computerize

    Computerize Member

    Joined:
    Oct 10, 2019
    Messages:
    38
    Likes Received:
    0
    Hey, could you make the villager die and not drop items after 45 seconds and if the player joins before those 45 seconds to die and not drop anything
     
  6. Goose

    Supporter

    Joined:
    Nov 23, 2019
    Messages:
    429
    Likes Received:
    30
    Sure. Here's the new skript.


    Code (Text):
    1. on damage of player:
    2.   if attacker is a player:
    3.     if {combatTag.%attacker%} isn't set:
    4.       send "&cYou are now in combat." to attacker
    5.       set {combatTag.%attacker%} to 30
    6.     else:
    7.       set {combatTag.%attacker%} to 30
    8. on damage of player:
    9.   if attacker is a player:
    10.     if {combatTag.%victim%} isn't set:
    11.       send "&cYou are now in combat." to victim
    12.       set {combatTag.%victim%} to 30
    13.     else:
    14.       set {combatTag.%victim%} to 30
    15. every second:
    16.   loop all players:
    17.     if {combatTag.%loop-player%} is set:
    18.       if {combatTag.%loop-player%} > 0:
    19.         remove 1 from {combatTag.%loop-player%}
    20.       else:
    21.         delete {combatTag.%loop-player%}
    22.         send "&aYou are no longer in combat." to loop-player
    23. on command:
    24.   if {combatTag.%player%} is set:
    25.     cancel event
    26.     send "&cYou cannot use commands while in combat."
    27. on disconnect:
    28.     if {combattag.%player%} is set:
    29.         spawn a villager
    30.         set {combatvillager::%spawned villager%::%player's uuid%::*} to true
    31.         set the name of the spawned villager to "%event-player%"
    32.         add "{NoAI:1}" to nbt of last spawned entity
    33.         set {inventory::%player's uuid%::*} to all items in player's inventory
    34.         set {logged.%player's uuid%} to true
    35. on death:
    36.     if victim is a villager:
    37.         if {combatvillager::%victim%::%player's uuid%::*} is true:
    38.             set {waiting.%player's uuid%} to true
    39.             wait 45 seconds
    40.             set {waiting.%player's uuid%} to false
    41.             drop all items in inventories {inventory::%player's uuid%::*}
    42.             set {killed.%player's uuid%} to true
    43. on join:
    44.     if {logged.%player's uuid%} is true:
    45.         if {killed.%player's uuid%} is true:
    46.             if {waiting.%player's uuid%} is false:
    47.                 clear player's inventory
    48.                 set {logged.%player's uuid%} to false
    49.                 set {killed.%player's uuid%} to false
    50.             if {waiting.%player's uuid%} is true:
    51.                 set {waiting.%player's uuid%} to fals
    52.                 set {logged.%player's uuid%} to false
    53.                 set {killed.%player's uuid%} to false
    --- Double Post Merged, Dec 22, 2019, Original Post Date: Dec 22, 2019 ---
    So I didnt really read your full post I just added that villager part, didnt send them to spawn or set your variables to specific values like you wanted. Here is that if you still want it: (I also had a few typos and indentation errors in the previous one so u will want this skript) (THIS CODE IS ALSO SHORTENED SO THE FILE SIZE IS SMALLER REE)
    Code (Text):
    1. on damage of player:
    2.   if attacker is a player:
    3.     if {combatTag.%victim%} isn't set:
    4.       send "&cYou are now in combat." to victim
    5.       set {combatTag.%victim%} to 30
    6.       wait 30 seconds
    7.       send "&aYou are no longer in combat." to victim
    8.     else:
    9.       set {combatTag.%victim%} to 30
    10.       wait 30 seconds
    11.       send "&aYou are no longer in combat." to victim
    12.     if {combatTag.%attacker%} isn't set:
    13.       send "&cYou are now in combat." to attacker
    14.       set {combatTag.%attacker%} to 30
    15.       wait 30 seconds
    16.       send "&aYou are no longer in combat." to attacker
    17.     else:
    18.       set {combatTag.%attacker%} to 30
    19.       wait 30 seconds
    20.       send "&aYou are no longer in combat." to attacker
    21.  
    22. on command:
    23.   if {combatTag.%player%} is set:
    24.     cancel event
    25.     send "&cYou cannot use commands while in combat."
    26. on disconnect:
    27.     if {combattag.%player%} is set:
    28.         spawn a villager
    29.         set {combatvillager::%spawned villager%::%player's uuid%::*} to true
    30.         set the name of the spawned villager to "%event-player%"
    31.         add "{NoAI:1}" to nbt of last spawned entity
    32.         set {inventory::%player's uuid%::*} to all items in player's inventory
    33.         set {logged.%player's uuid%} to true
    34. on death:
    35.     if victim is a villager:
    36.         if {combatvillager::%victim%::%player's uuid%::*} is true:
    37.             set {waiting.%player's uuid%} to true
    38.             wait 45 seconds
    39.             set {waiting.%player's uuid%} to false
    40.             drop all items in inventories {inventory::%player's uuid%::*}
    41.             set {killed.%player's uuid%} to true
    42.             set {pvpTimer.%player%} to 1800
    43.             set {deathBan.%player%} to 600
    44. on join:
    45.     if {logged.%player's uuid%} is true:
    46.         if {killed.%player's uuid%} is true:
    47.             if {waiting.%player's uuid%} is false:
    48.                 clear player's inventory
    49.                 set {logged.%player's uuid%} to false
    50.                 set {killed.%player's uuid%} to false
    51.                 execute console command "spawn %player%"
    52.             if {waiting.%player's uuid%} is true:
    53.                 set {waiting.%player's uuid%} to false
    54.                 set {logged.%player's uuid%} to false
    55.                 set {killed.%player's uuid%} to false
    --- Double Post Merged, Dec 23, 2019 ---
    might not work but no errors sooo


    Code (Text):
    1. on damage of player:
    2.   if attacker is a player:
    3.     if {combatTag.%victim%} isn't set:
    4.       send "&cYou are now in combat." to victim
    5.       set {combatTag.%victim%} to 30
    6.       wait 30 seconds
    7.       send "&aYou are no longer in combat." to victim
    8.     else:
    9.       set {combatTag.%victim%} to 30
    10.       wait 30 seconds
    11.       send "&aYou are no longer in combat." to victim
    12.     if {combatTag.%attacker%} isn't set:
    13.       send "&cYou are now in combat." to attacker
    14.       set {combatTag.%attacker%} to 30
    15.       wait 30 seconds
    16.       send "&aYou are no longer in combat." to attacker
    17.     else:
    18.       set {combatTag.%attacker%} to 30
    19.       wait 30 seconds
    20.       send "&aYou are no longer in combat." to attacker
    21.  
    22. on command:
    23.   if {combatTag.%player%} is set:
    24.     cancel event
    25.     send "&cYou cannot use commands while in combat."
    26. on disconnect:
    27.     if {combattag.%player%} is set:
    28.         spawn a villager
    29.         set {combatvillager::%spawned villager%::%player's uuid%::*} to true
    30.         set the name of the spawned villager to "%event-player%"
    31.         add "{NoAI:1}" to nbt of last spawned entity
    32.         set {inventory::%player's uuid%::*} to all items in player's inventory
    33.         set {logged.%player's uuid%} to true
    34.         set {waiting2.%player's uuid%} to true
    35.         wait 45 seconds
    36.         set {waiting2.%player's uuid%} to false
    37.         set {combatvillager::%spawned villager%::%player's uuid%::*} to false
    38.         kill spawned villager
    39.         stop
    40. on death:
    41.     if victim is a villager:
    42.         if {combatvillager::%victim%::%player's uuid%::*} is true:
    43.             set {waiting.%player's uuid%} to true
    44.             wait 45 seconds
    45.             set {waiting.%player's uuid%} to false
    46.             drop all items in inventories {inventory::%player's uuid%::*}
    47.             set {killed.%player's uuid%} to true
    48.             set {pvpTimer.%player%} to 1800
    49.             set {deathBan.%player%} to 600
    50. on join:
    51.     if {logged.%player's uuid%} is true:
    52.         if {killed.%player's uuid%} is true:
    53.             if {waiting.%player's uuid%} is false:
    54.                 clear player's inventory
    55.                 set {logged.%player's uuid%} to false
    56.                 set {killed.%player's uuid%} to false
    57.                 execute console command "spawn %player%"
    58.             if {waiting.%player's uuid%} is true:
    59.                 set {waiting.%player's uuid%} to false
    60.                 set {logged.%player's uuid%} to false
    61.                 set {killed.%player's uuid%} to false
     
  7. Computerize

    Computerize Member

    Joined:
    Oct 10, 2019
    Messages:
    38
    Likes Received:
    0
    The villager disappears after 10 seconds and the player joins back and {pvpTimer.%player%} and {deathBan.%player%} does not set when the villager dies and the items do not drop and the player joins back and nothing has changed.
     
  8. Goose

    Supporter

    Joined:
    Nov 23, 2019
    Messages:
    429
    Likes Received:
    30
    tbh piling all this code on top of each other is confusing alright
     

Share This Page

Loading...