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.

Help on Gen Skript

Discussion in 'Requests' started by ItsKirby, Jun 14, 2021.

  1. ItsKirby

    ItsKirby Member

    Joined:
    Jun 5, 2021
    Messages:
    2
    Likes Received:
    0
    I have a generator skript that works like a charm, it works like how you want it to work. But there's a problem. The part of the skript that allows the owner to be able to remove the generator (and only the owner who have placed the generator) is kinda broken.

    It was working fine when i was testing it in a server, but suddenly when i restarted my server to load some plugins, it stopped working and made all the generators that i placed is said that i wasn't the owner of the generator. (You can see more details when you read the skript)

    ** Please tell me how i can fix this problem and make it work once again, if it is not possible, please tell me how i can remove this feature so i don't have to struggle so much.

    Skript:

    Code (Text):
    1. #Functions
    2.  
    3. #Register a gen template.
    4. function registerGen(id: integer, discrim: string, item: item, block: item, upgrade: integer, drop: item):
    5.     set {gens::internal::%{_id}%} to {_discrim}
    6.     set {gen::internal::%{_id}%::item} to {_item}
    7.     set {gen::internal::%{_id}%::block} to {_block}
    8.     set {gen::internal::%{_id}%::upgrade} to {_upgrade}
    9.     set {gen::internal::%{_id}%::drop} to {_drop}
    10.  
    11. #Registers a player's gen, i.e. placed generator.
    12. function placeGen(p: player, block: block, id: integer):
    13.     set {_u} to uuid of {_p}
    14.     add location of {_block} to {gens::player::%{_u}%::*}
    15.     set {_discrim} to size of {gens::player::%{_u}%::*}
    16.     set {_loc} to location of {_block}
    17.     set {gens::all::%{_loc}%} to {_discrim}
    18.     set {gen::player::%{_u}%::%{_discrim}%::id} to {_id}
    19.  
    20.  
    21. #Registers the template generators.
    22. on load:
    23.     #registerGen(id, "name_id", (inventory item of block), block type, price to upgrade, (inventory item of drop))
    24.  
    25.     registerGen(1, "wheat_gen", (hay bale named "&eWheat &fGen &7Tier I" with lore "&7» &fUpgrade: &e&n$2,000" and "&7» &fOutput: &e&n$5"), hay bale, 2000, (wheat named "&eWheat &7Tier I" with lore "&7 &fGenerator Drop" and "&7 &fSell Price: &e&n$5"))
    26.  
    27.     registerGen(2, "melon_gen", (melon named "&aMelon &fGen &7Tier II" with lore "&7 &fUpgrade: &a&n$5,000" and "&7 &fOutput: &a&n$10"), melon, 5000, (melon slice named "&aMelon &7Tier II" with lore "&7 &fGenerator Drop" and "&7 &fSell Price: &a&n$10"))
    28.  
    29.     registerGen(3, "pumpkin_gen", (pumpkin named "&6Pumpkin &fGen &7Tier III" with lore "&7 &fUpgrade: &6&n$10,000" and "&7 &fOutput: &6&n$20"), pumpkin, 10000, (pumpkin pie named "&6Pumpkin &7Tier III" with lore "&7 &fGenerator Drop" and "&7 &fSell Price: &6&n$20"))
    30.  
    31.  
    32.  
    33. #Registers a player's gen upon placement.
    34. on place:
    35.     loop {gens::internal::*}:
    36.         if tool = {gen::internal::%loop-index%::item}:
    37.             if ({maxgens::%player's uuid%} ? 50) > size of {gens::player::%player's uuid%::*}:
    38.                 placeGen(player, event-block, loop-index parsed as integer)
    39.                 send action bar "Server &8» &7You have placed a generator! &6[&e%size of {gens::player::%player's uuid%::*}%&6/&e%({maxgens::%player's uuid%} ? 50)%&6]" to player
    40.             else:
    41.                 cancel event
    42.                 send "Server &8» &cYou have already reached the maximum generators available!"
    43.             exit loop
    44.  
    45. #Unregisters a player's gen upon destruction.
    46. on left click:
    47.     player is sneaking
    48.     if {gens::all::%location of clicked block%} is set:
    49.         set {_discrim} to {gens::all::%location of clicked block%}
    50.         if {gens::player::%player's uuid%::*} contains location of clicked block:
    51.             drop {gen::internal::%{gen::player::%player's uuid%::%{_discrim}%::id}%::item} at clicked block without velocity
    52.             delete {gen::player::%player's uuid%::%{_discrim}%::id}
    53.             remove location of clicked block from {gens::player::%player's uuid%::*}
    54.             send action bar "Server &8» &7You have destroyed a generator! &6[&e%size of {gens::player::%player's uuid%::*}%&6/&e%({maxgens::%player's uuid%} ? 50)%&6]" to player
    55.             delete {gens::all::%location of clicked block%}
    56.             set clicked block to air
    57.         else:
    58.             cancel event
    59.             send action bar "Server &8» &cThat isn't your generator!" to player
    60.  
    61.  
    62. #Cancels breaking of gens.
    63. on break:
    64.     if {gens::all::%location of event-block%} is set:
    65.         play sound "entity.villager.no" for player
    66.         send action bar "Server &8» &cShift left click to pickup your generator!" to player
    67.         cancel event
    68.  
    69. #Spawns an item above every generator.
    70. every 2 seconds:
    71.     loop all players:
    72.         loop {gens::player::%loop-player's uuid%::*}:
    73.             drop {gen::internal::%{gen::player::%loop-player's uuid%::%loop-index%::id}%::drop} at block above loop-value-2 without velocity
    74.  
    75. #Upgrades a generator.
    76. on right click:
    77.     if player is sneaking:
    78.         if {gens::all::%location of clicked block%} is set:
    79.             set {_discrim} to {gens::all::%location of clicked block%}
    80.             if {gens::player::%player's uuid%::*} contains location of clicked block:
    81.                 set {_level} to {gen::player::%player's uuid%::%{_discrim}%::id} + 1
    82.                 if {gens::internal::%{_level}%} is set:
    83.                     if player's balance >= {gen::internal::%{gen::player::%player's uuid%::%{_discrim}%::id}%::upgrade}:
    84.                         remove {gen::internal::%{gen::player::%player's uuid%::%{_discrim}%::id}%::upgrade} from player's balance
    85.                         set clicked block to {gen::internal::%{_level}%::block}
    86.                         add 1 to {gen::player::%player's uuid%::%{_discrim}%::id}
    87.                         send "Server &8» &7Generator upgrade!"
    88.                         play sound "ui.toast.challenge_complete" for player
    89.                     else:
    90.                         send "Server &8» &cInsufficient funds!"
    91.                 else:
    92.                     send "Server &8» &cYou are at max upgrades!"
    93.  
    94. #Sets a player's max gens.
    95. command /setgens <offline player> <integer>:
    96.     permission: console.setgens
    97.     permission message: Server &8» &cSorry, You don't have permission to use this command!
    98.     trigger:
    99.         send "Server &8» &7You have set &e%arg-1%&e's &7gen limit to &e%arg-2%&7!"
    100.         send "Server &8» &7Your gen limit has been set to &e%arg-2% &7by &e%sender%&7!" to arg-1
    101.         set {maxgens::%arg-1's uuid%} to arg-2
    102.         play sound "block.note_block.pling" at volume 60 to arg-1 and player
    103.  
    104.  
    105.  
    106. set event-block to {_b}
    107.         set {g::l::%location of event-block%} to location of event-block
    108.         set {g::o ::%location of event-block%} to uuid of player
     
  2. Minecoll_YT

    Supporter Forums Helper

    Joined:
    Dec 2, 2018
    Messages:
    650
    Likes Received:
    39
    This is the section to request a skript, for help use https://forums.skunity.com/forums/skript/

    But can you dry to debug the variable:
    Code (Text):
    1. {gens::player::%player's uuid%::*}
    this way we can find out if the problem is with the variable or code related
     

Share This Page

Loading...