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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

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

someone explain me what im doing wrong

Discussion in 'Skript' started by TheCraft, Mar 4, 2020.

Tags:
Thread Status:
Not open for further replies.
  1. TheCraft

    TheCraft Member

    Joined:
    Apr 20, 2019
    Messages:
    22
    Likes Received:
    0
    so bassicly i wanted to make a skript of gens that if u sneak break them it goes to ur inventory and if the gen has the exact name it works and makes things spawn on it every 5 secounds and u can turn it on and off anyways anyone can help me fix this? The code is pretty long just saying
    Code (Text):
    1. options:
    2.     time: 5
    3.     itembar: |
    4.     prefix: &7[&e&lCoil&7]&f&l -
    5.     items: 2
    6. variables:
    7.     {generator} = true
    8.     {mcd} = true
    9.  
    10. command /gen [<option>] [<gentype>]:
    11.     trigger:
    12.         if player has permission "generator.admin":
    13.             if arg-1 is "give":
    14.               if arg-2 is "coal":
    15.                 give player 1 coal block named "&8&lCoal Generator " with lore "{@prefix} &6- &bSneak and mine to pickup"
    16.               else:
    17.                 send "{@prefix} Add a gen type"
    18.               if arg-2 is "iron":  
    19.                 give player 1 iron block named "&7&lIron Generator" with lore "{@prefix} &6- &bSneak and mine to pickup"
    20.               else:
    21.                 send "{@prefix} Add a gen type"
    22.               if arg-2 is "pumpkin":
    23.                 give player 1 pumpkin named "&6&lPumpkin Generator" with lore "{@prefix} &6- &bSneak and mine to pickup"
    24.               else:
    25.                 send "{@prefix} Add a gen type"
    26.               if arg-2 is "melon":
    27.                 give player 1 melon named "&9&Melon Generator" with lore "{@prefix} &6- &bSneak and mine to pickup"
    28.               else:
    29.                 send "{@prefix} Add a gen type"
    30.               if arg-2 is "wheat":
    31.                 give player 1 hay named "&c&l Wheat Generator" with lore "{@prefix} &6- &bSneak and mine to pickup"
    32.               else:
    33.                 send "{@prefix} Add a gen type"
    34.               if arg-2 is "diamond":
    35.                 give player 1 diamond block named "&b&lDiamond Generator" with lore "{@prefix} &6- &bSneak and mine to pickup"
    36.               else:
    37.                 send "{@prefix} Add a gen type"
    38.               if arg-2 is "emerald":
    39.                 give player 1 emerald block named "&a&lEmerald Generator" with lore "{@prefix} &6- &bSneak and mine to pickup"
    40.               else:
    41.                 send "{@prefix} Add a gen type"
    42.             if arg 1 is "on":
    43.                 set {generator} to true
    44.                 send "{@prefix} &7&lgenerator is on now"
    45.             if arg 1 is "off":
    46.                 set {generator} to false
    47.                 send "{@prefix} &7&lgenerator is off now"
    48.             if arg-1 is "bar":
    49.                 set {mcd} to false
    50.                 send "{@prefix} &7&lbar mod on"
    51.             if arg-1 is "time":
    52.                 set {mcd} to true
    53.                 send "{@prefix} &7&time mod on"
    54.             if arg-1 is not set
    55.             send "{@prefix} &6- &c/gen [<option>] [<gentype>]"
    56.             if arg-2 is not set
    57.             send "{@prefix} &6- &cPlease select a valid gen type."
    58. on break of Coal block:
    59.     if {generator.%Block%} is true:
    60.         if player has permission "generator.admin":
    61.             remove location of event-block from {Coalgen.loc::*}
    62.             set {generator.%Block%} to false
    63.             delete holo object "%location of block%"
    64.             clear {pp%Block%::*}
    65.             clear {cc%Block%::*}
    66. on break of Iron block:
    67.     if {generator.%Block%} is true:
    68.         if player has permission "generator.admin":
    69.             remove location of event-block from {Irongen.loc::*}
    70.             set {generator.%Block%} to false
    71.             delete holo object "%location of block%"
    72.             clear {pp%Block%::*}
    73.             clear {cc%Block%::*}
    74. on break of Pumpkin block:
    75.     if {generator.%Block%} is true:
    76.         if player has permission "generator.admin":
    77.             remove location of event-block from {Pumpkingen.loc::*}
    78.             set {generator.%Block%} to false
    79.             delete holo object "%location of block%"
    80.             clear {pp%Block%::*}
    81.             clear {cc%Block%::*}
    82. on break of Melon block:
    83.     if {generator.%Block%} is true:
    84.         if player has permission "generator.admin":
    85.             remove location of event-block from {Melongen.loc::*}
    86.             set {generator.%Block%} to false
    87.             delete holo object "%location of block%"
    88.             clear {pp%Block%::*}
    89.             clear {cc%Block%::*}
    90. on break of Redstone block:
    91.     if {generator.%Block%} is true:
    92.         if player has permission "generator.admin":
    93.             remove location of event-block from {redstonegen.loc::*}
    94.             set {generator.%Block%} to false
    95.             delete holo object "%location of block%"
    96.             clear {pp%Block%::*}
    97.             clear {cc%Block%::*}
    98. on break of Diamond block:
    99.     if {generator.%Block%} is true:
    100.         if player has permission "generator.admin":
    101.             remove location of event-block from {diamondgen.loc::*}
    102.             set {generator.%Block%} to false
    103.             delete holo object "%location of block%"
    104.             clear {pp%Block%::*}
    105.             clear {cc%Block%::*}
    106. on break of Emerald block:
    107.     if {generator.%Block%} is true:
    108.         if player has permission "generator.admin":
    109.             remove location of event-block from {emeraldgen.loc::*}
    110.             set {generator.%Block%} to false
    111.             delete holo object "%location of block%"
    112.             clear {pp%Block%::*}
    113.             clear {cc%Block%::*}
    114. on break of coal block:
    115.   if %player% is sneaking
    116.     set {_loc} to location of block
    117.     set block at {_loc} to air
    118.     give player 1 coal block named "&b&lCoal &bGenerator " with lore "{@prefix} &6- &bSneak and mine to pickup"
    119. on break of melon block:
    120.   if %player% is sneaking
    121.     set {_loc} to location of block
    122.     set block at {_loc} to air
    123.     give player 1 melon named "&b&lMelon &bGenerator " with lore "{@prefix} &6- &bSneak and mine to pickup"
    124. on break of pumpkin block:
    125.   if %player% is sneaking
    126.     set {_loc} to location of block
    127.     set block at {_loc} to air
    128.     give player 1 pumpkin named "&b&lPumpkin &bGenerator " with lore "{@prefix} &6- &bSneak and mine to pickup"
    129. on break of iron block:
    130.   if %player% is sneaking
    131.     set {_loc} to location of block
    132.     set block at {_loc} to air
    133.     give player 1 coal block named "&b&lIron &bGenerator " with lore "{@prefix} &6- &bSneak and mine to pickup"
    134. on break of diamond block:
    135.   if %player% is sneaking
    136.     set {_loc} to location of block
    137.     set block at {_loc} to air
    138.     give player 1 diamond block named "&b&lDiamond &bGenerator " with lore "{@prefix} &6- &bSneak and mine to pickup"
    139. on break of emerald block:
    140.   if %player% is sneaking
    141.     set {_loc} to location of block
    142.     set block at {_loc} to air
    143.     give player 1 emerald block named "&b&lEmerald &bGenerator " with lore "{@prefix} &6- &bSneak and mine to pickup"
    144. on break of hay:
    145.   if %player5 is sneaking
    146.     set {_loc} to location of block
    147.     set block at {_loc} to air
    148.     give %player% 1 hay named "&b&lWheat &bGenerator " with lore "{@prefix} &6- &bSneak and mine to pickup"
    149. on place of hay block:  
    150.     if player's tool is hay named "&b&lWheat &bGenerator " with lore "{@prefix} &6- &bSneak and mine to pickup":
    151.         set {wheatgen.loc::*} location of block
    152.         spawn diamond above {diamondgen.loc::*}
    153.         set {generator.%Block%} to true
    154.         set {gen.%Block%} to {@time}      
    155.         loop {@time} times:
    156. on place of pumpkin:  
    157.     if player's tool is diamond block named "&b&lDiamond &bGenerator " with lore "{@prefix} &6- &bSneak and mine to pickup":
    158.         set {pumpkingen.loc::*} location of block
    159.         spawn pumpkin above {pumpkingen.loc::*}
    160.         set {generator.%Block%} to true
    161.         set {gen.%Block%} to {@time}      
    162.         loop {@time} times:
    163. on place of melon:  
    164.     if player's tool is melon named "&b&lMelon &bGenerator " with lore "{@prefix} &6- &bSneak and mine to pickup":
    165.         set {wheatgen.loc::*} location of block
    166.         spawn melon above {diamondgen.loc::*}
    167.         set {generator.%Block%} to true
    168.         set {gen.%Block%} to {@time}      
    169.         loop {@time} times:
    170. on place of coal block:  
    171.     if player's tool is coal block named "&b&lCoal &bGenerator " with lore "{@prefix} &6- &bSneak and mine to pickup":
    172.         set {coalgen.loc::*} location of block
    173.         spawn coal above {coalgen.loc::*}
    174.         set {generator.%Block%} to true
    175.         set {gen.%Block%} to {@time}      
    176.         loop {@time} times:
    177. on place of iron block:  
    178.     if player's tool is iron block named "&b&lIron &bGenerator " with lore "{@prefix} &6- &bSneak and mine to pickup":
    179.         set {irongen.loc::*} location of block
    180.         spawn iron above {irongen.loc::*}
    181.         set {generator.%Block%} to true
    182.         set {gen.%Block%} to {@time}      
    183.         loop {@time} times:
    184. on place of diamond block:  
    185.     if player's tool is diamond block named "&b&lDiamond &bGenerator " with lore "{@prefix} &6- &bSneak and mine to pickup":
    186.         set {diamondgen.loc::*} location of block
    187.         spawn diamond above {diamondgen.loc::*}
    188.         set {generator.%Block%} to true
    189.         set {gen.%Block%} to {@time}      
    190.         loop {@time} times:
    191. on place of emerald block:  
    192.     if player's tool is emerald block named "&b&lEmerald &bGenerator " with lore "{@prefix} &6- &bSneak and mine to pickup":
    193.         set {emeraldgen.loc::*} location of block
    194.         spawn emerald above {emeraldgen.loc::*}
    195.         set {generator.%Block%} to true
    196.         set {gen.%Block%} to {@time}      
    197.         loop {@time} times:
    thanks for any help
     
  2. Lego_freak1999

    Lego_freak1999 Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    664
    Likes Received:
    45
    Well maybe u can first use format? Errors? Whats not working?

    also a pumpkin is not a diamond block

    Code (Text):
    1. on place of pumpkin:
    2.     if player's tool is diamond block named "&b&lDiamond &bGenerator
     
  3. TheCraft

    TheCraft Member

    Joined:
    Apr 20, 2019
    Messages:
    22
    Likes Received:
    0
    thanks i didnt see the miss typing
    btw is 72 errors so if u want i can send i just need to find a way to send it without copying it all and im pretty new to skript so thats why i have no idea what im doing im trying to use docs and learn from the skunity community
     
  4. Lego_freak1999

    Lego_freak1999 Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    664
    Likes Received:
    45
    nvm looked at the code and u didn't even finnished the code this requires someone to take time to make it for u so u should post it in the request section.

    Can u also explain in more dept what its supposed to do?

    Wenn placed does it need to go on every ... seconds or go on for a set time and stop.
    What do u want to happen wenn the server restarts stop all generators make them continue?

    pls be more descriptive
     
  5. TheCraft

    TheCraft Member

    Joined:
    Apr 20, 2019
    Messages:
    22
    Likes Received:
    0

    a gens skript that is bassicly when u shift break the gen it gives it to ur inventory with the exact name so u can replace it and it drops on the head of the gen the type of the gen is like diamond gen drops diamonds every 5 secounds i dont want it to glitch out when i restart server i want it to keep working after the server restarts its just that i am new to skripting and i dont know all of those things i am learning from skunity and community so i thought i finished the code thats why i came here would be pleasure if someone fixes this code and sends it so i can understand my errors and what did i forget to do

    btw the command dosent even exists
    even after i reloaded it
    --- Double Post Merged, Mar 4, 2020, Original Post Date: Mar 4, 2020 ---
    oh and how to do that u cant break it without shifting
     
  6. Lego_freak1999

    Lego_freak1999 Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    664
    Likes Received:
    45
    Are generators per player or global so if u do /off all the generators are off from a specific player or like all server wide
     
  7. TheCraft

    TheCraft Member

    Joined:
    Apr 20, 2019
    Messages:
    22
    Likes Received:
    0
    specific player also i wanted to do that u can only break ur own gens
     
  8. Lego_freak1999

    Lego_freak1999 Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    664
    Likes Received:
    45
    why are on off admin commands then?
     
  9. TheCraft

    TheCraft Member

    Joined:
    Apr 20, 2019
    Messages:
    22
    Likes Received:
    0
    actually i need to change that later
     
  10. Lego_freak1999

    Lego_freak1999 Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    664
    Likes Received:
    45
    later this day u get an answer
     
  11. TheCraft

    TheCraft Member

    Joined:
    Apr 20, 2019
    Messages:
    22
    Likes Received:
    0
    kk
    --- Double Post Merged, Mar 4, 2020, Original Post Date: Mar 4, 2020 ---
    Anyone else can help?
     
  12. Lego_freak1999

    Lego_freak1999 Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    664
    Likes Received:
    45
    oh dont want my help k
     
  13. TheCraft

    TheCraft Member

    Joined:
    Apr 20, 2019
    Messages:
    22
    Likes Received:
    0
    i do i thought u said someone else will answer sorry!
     
  14. Lego_freak1999

    Lego_freak1999 Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    664
    Likes Received:
    45
    Update got an sollution for most parts for u just need to look into 1 last thing
     
  15. TheCraft

    TheCraft Member

    Joined:
    Apr 20, 2019
    Messages:
    22
    Likes Received:
    0
    kk
     
  16. Lego_freak1999

    Lego_freak1999 Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    664
    Likes Received:
    45
    Sry for the long wait but as u can see below here it took some while hope u happy and have no errors bc of versions if u do pls reply

    i ussed alot of comments to explain it to u

    Code (Text):
    1. #WARNING!!!!
    2.  
    3. #This Script has a known bug:
    4. # If a generator has been placed and then someone moves it with a piston it gets deleted(if it was on or gets turned on) + the owner has no way to get his generator back.
    5. # U can enable the code right below here as temperarly fix if u don't mind disableing pistons. I don't have time to make a propper fix rn:
    6.  
    7. # On piston extend:
    8. #     cancel event
    9. #
    10. # On piston retract:
    11. #     cancel event
    12.  
    13. #End Temp fix
    14.  
    15. options:
    16.     #Prefix
    17.     prefix: &7[&e&lCoil&7]&f&l -
    18.     #lore of the generator item to be placed
    19.     lore: &7[&e&lCoil&7]&f&l - &6- &bSneak and mine to pickup
    20.     #name suffix of the generator
    21.     namesuffix: Generator
    22.  
    23. #function to manage spawning items
    24. function genitem(uuid: text,loc: location):
    25.     #check if the player didnt turned his generators off
    26.     if {genoff::%{_uuid}%} is set:
    27.         stop
    28.     #check if the generator still exists
    29.     if {generators::%{_uuid}%::%{_loc}%} is set:
    30.         #get the type of generator
    31.         set {_type} to {generators::%{_uuid}%::%{_loc}%}
    32.         # Check if the block at the location is still valid
    33.         if block at {_loc} is {gentypes::%{_type}%}:
    34.             #get the item of the right type
    35.             set {_item} to {gentypes::%{_type}%::item}
    36.             #spawn the item
    37.             drop {_item} above {_loc} without velocity
    38.             #make shure time is set and can't be <none>
    39.             set {_time} to 1
    40.             #get the propper interval of the right type
    41.             set {_time} to {gentypes::%{_type}%::interval}
    42.             #CHECK for atleast 1 tick to prefent a server crash (bc then this will spam without a delay)
    43.             if {_time} < 1:
    44.                 set {_time} to 1
    45.             #loop time amount times
    46.             loop {_time} times:
    47.                 #check if the generator needs to stop bc of a script reload
    48.                 if {GEN.ON} is not set:
    49.                     stop
    50.                 #check if the player turned his generators off
    51.                 if {genoff::%{_uuid}%} is set:
    52.                     stop
    53.                 #wait 1 tick * {_time}
    54.                 wait 1 tick
    55.             #start this function again after {_time} so it keeps repeating the spawn process
    56.             genitem({_uuid}, {_loc})
    57.             #stop the function so it doesnt go to the delete lines
    58.             stop
    59.         #if the block isn't there anymore and this data still beeing set is invalid data and should be deleted
    60.         delete {generators::%{_uuid}%::%{_loc}%}
    61.         delete {generators::%{_uuid}%::%{_loc}%::loc}
    62.  
    63. on script load:
    64.     #stop all the generators
    65.     delete {GEN.ON}
    66.     #reset all the types
    67.     loop {gentypes::*}:
    68.         delete {gentypes::%loop-index%::*}
    69.     delete {gentypes::*}
    70.  
    71.     #creating type coal
    72.     set {gentypes::coal} to coal block
    73.     set {gentypes::coal::item} to coal
    74.     #interval in ticks 20 ticks = 1 second
    75.     set {gentypes::coal::interval} to 100 #in ticks 20 ticks = 1 second
    76.     set {gentypes::coal::name} to "&8&lCoal {@namesuffix}"
    77.  
    78.     #creating type iron
    79.     set {gentypes::iron} to iron block
    80.     set {gentypes::iron::item} to iron ingot
    81.     #interval in ticks 20 ticks = 1 second
    82.     set {gentypes::iron::interval} to 80
    83.     set {gentypes::iron::name} to "&7&lIron {@namesuffix}"
    84.  
    85.     #security messure waiting to make shure all generators have been stopped by now
    86.     wait 1 second
    87.  
    88.     #Enable variable so generators are allowed to start again
    89.     set {GEN.ON} to true
    90.  
    91.     #loop all uuids
    92.     loop indices of {generators::*}:
    93.         #loop all locations of a uuid
    94.         loop {generators::%loop-value%::*}:
    95.             #get formatted location of a generator of a uuid
    96.             set {_l} to {generators::%loop-value-1%::%loop-index%::loc}
    97.             #start generator
    98.             genitem(loop-value-1, {_l})
    99.  
    100. #main command
    101. command /gen [<text>] [<text>]:
    102.     trigger:
    103.         #premission check
    104.         if player has permission "generator.admin":
    105.             if arg-1 is "give":
    106.                 #check if the type exists
    107.                 if {gentypes::%arg 2%::name} is set:
    108.                     #give the requested type
    109.                     give player {gentypes::%arg 2%} named {gentypes::%arg 2%::name} with lore {gentypes::%arg 2%::lore}
    110.                     stop
    111.                 send "{@prefix} &6- &cPlease select a valid gen type."
    112.                 stop
    113.             if arg 1 is "on":
    114.                 #check if its off so u can't turn it on double
    115.                 if {genoff::%uuid of player%} is set:
    116.                     send "{@prefix} &7&lgenerator is on now"
    117.                     set {_uuid} to uuid of player
    118.                     #allow generators to start for this player
    119.                     delete {genoff::%uuid of player%}
    120.                     #loop all locations of player
    121.                     loop {generators::%{_uuid}%::*}:
    122.                         #get formatted location of a generator of player
    123.                         set {_l} to {generators::%{_uuid}%::%loop-index%::loc}
    124.                         #start generator
    125.                         genitem({_uuid}, {_l})
    126.                 else:
    127.                     send "{@prefix} &7&lgenerator is already on"
    128.                 stop
    129.             if arg 1 is "off":
    130.                 #check if the generators of the player aren't already off
    131.                 if {genoff::%uuid of player%} is not set:
    132.                     send "{@prefix} &7&lgenerator is off now"
    133.                     #turn generators off
    134.                     set {genoff::%uuid of player%} to true
    135.                 else:
    136.                     send "{@prefix} &7&lgenerator is already off"
    137.                 stop
    138.             send "{@prefix} &6- &c/gen [<option>] [<gentype>]"
    139.  
    140. #debug command to delete all data if some manage to get stuck WARNING this is all data so all generators placed currently are lost.
    141. command /DEBUGGENRESET:
    142.     trigger:
    143.         loop indices of {generators::*}:
    144.             loop {generators::%loop-value%::*}:
    145.                 delete {generators::%loop-value-1%::%loop-index%::*}
    146.             delete {generators::%loop-value%::*}
    147.         delete {generators::*}
    148.         delete {genoff::*}
    149.  
    150. #break event
    151. on break:
    152.     #check if the current block is a generator and if this player is the owner
    153.     if {generators::%uuid of player%::%location of event-block%} is set:
    154.         #check if the player is sneaking
    155.         if player is sneaking:
    156.             send "{@prefix} &7&lgenerator removed!"
    157.             #get type of the broken generator
    158.             set {_type} to {generators::%uuid of player%::%location of event-block%}
    159.             #delete data of generator
    160.             delete {generators::%uuid of player%::%location of event-block%}
    161.             delete {generators::%uuid of player%::%location of event-block%::loc}
    162.             send "{@prefix} &7&lGenerator Recieved!" to player
    163.             #give back generator
    164.             give player {gentypes::%{_type}%} named {gentypes::%{_type}%::name} with lore {gentypes::%{_type}%::lore}
    165.             stop
    166.         #cancels block break if the player is not sneaking
    167.         cancel event
    168.     #check if the block is a generator but if the player is not the owner
    169.     loop indices of {generators::*}:
    170.         if {generators::%loop-value%::%location of event-block%} is set:
    171.             #cancel block break bc the player is not the owner
    172.             cancel event
    173.             #can stop the loop bc the event already has been canceled
    174.             stop
    175.  
    176. #place event
    177. On place:
    178.     #get all the current types of generators
    179.     loop {gentypes::*}:
    180.         #check if the tool of the player is a know block that could be a generator
    181.         if player's tool is loop-value:
    182.             #check if the name of tool of the player is equal to how a generator is supposed to be called
    183.             if name of player's tool is {gentypes::%loop-index%::name}:
    184.                 #check if there is any old corrupted data for this location
    185.                 if {generators::%uuid of player%::%location of event-block%} is set:
    186.                     #delete corrupted data
    187.                     delete {generators::%uuid of player%::%location of event-block%}
    188.                     delete {generators::%uuid of player%::%location of event-block%::loc}
    189.                 #Create the data for the new generator
    190.                 set {generators::%uuid of player%::%location of event-block%} to loop-index
    191.                 set {generators::%uuid of player%::%location of event-block%::loc} to location of event-block
    192.                 send "{@prefix} &7&lGenerator Created!" to player
    193.                 #Check if this player has its generators off
    194.                 if {genoff::%uuid of player%} is set:
    195.                     send "{@prefix} &7&lU currently have generators off. /gen on" to player
    196.                 else:
    197.                     #start the new created generator
    198.                     genitem(uuid of player, location of event-block)
    199.             stop
    200.  
     
  17. TheCraft

    TheCraft Member

    Joined:
    Apr 20, 2019
    Messages:
    22
    Likes Received:
    0
    Thankes i will try it!
    --- Double Post Merged, Mar 5, 2020, Original Post Date: Mar 5, 2020 ---
    works perfect ima read it all btw how to make it upgradable and that the console can give the gens to a player i mean i want to make a shop that they but it from so th e console uses to cmd to give it to them
     
  18. Lego_freak1999

    Lego_freak1999 Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    664
    Likes Received:
    45
    Upgradable depends what specs do u want to change?

    Why trough console? if i may ask?
     
  19. TheCraft

    TheCraft Member

    Joined:
    Apr 20, 2019
    Messages:
    22
    Likes Received:
    0
    Through console because the player wont have the generator.admin perm node so he wont find out and abuse it and idk any other way to do it anyways upgradable i meant that when u shift right click it upgrades it to the next level of the gen like from wheat to pumpkin i put new gens by the order at the script u sended me u can check it out
    Code (Text):
    1. #WARNING!!!!
    2.  
    3. #This Script has a known bug:
    4. # If a generator has been placed and then someone moves it with a piston it gets deleted(if it was on or gets turned on) + the owner has no way to get his generator back.
    5. # U can enable the code right below here as temperarly fix if u don't mind disableing pistons. I don't have time to make a propper fix rn:
    6.  
    7. # On piston extend:
    8. #     cancel event
    9. #
    10. # On piston retract:
    11. #     cancel event
    12.  
    13. #End Temp fix
    14.  
    15. options:
    16.     #Prefix
    17.     prefix: &7[&e&lCoil&7]&f&l -
    18.     #lore of the generator item to be placed
    19.     lore: &7[&e&lCoil&7]&f&l - &6- &bSneak and mine to pickup
    20.     #name suffix of the generator
    21.     namesuffix: Generator
    22.  
    23. #function to manage spawning items
    24. function genitem(uuid: text,loc: location):
    25.     #check if the player didnt turned his generators off
    26.     if {genoff::%{_uuid}%} is set:
    27.         stop
    28.     #check if the generator still exists
    29.     if {generators::%{_uuid}%::%{_loc}%} is set:
    30.         #get the type of generator
    31.         set {_type} to {generators::%{_uuid}%::%{_loc}%}
    32.         # Check if the block at the location is still valid
    33.         if block at {_loc} is {gentypes::%{_type}%}:
    34.             #get the item of the right type
    35.             set {_item} to {gentypes::%{_type}%::item}
    36.             #spawn the item
    37.             drop {_item} above {_loc} without velocity
    38.             #make shure time is set and can't be <none>
    39.             set {_time} to 1
    40.             #get the propper interval of the right type
    41.             set {_time} to {gentypes::%{_type}%::interval}
    42.             #CHECK for atleast 1 tick to prefent a server crash (bc then this will spam without a delay)
    43.             if {_time} < 1:
    44.                 set {_time} to 1
    45.             #loop time amount times
    46.             loop {_time} times:
    47.                 #check if the generator needs to stop bc of a script reload
    48.                 if {GEN.ON} is not set:
    49.                     stop
    50.                 #check if the player turned his generators off
    51.                 if {genoff::%{_uuid}%} is set:
    52.                     stop
    53.                 #wait 1 tick * {_time}
    54.                 wait 1 tick
    55.             #start this function again after {_time} so it keeps repeating the spawn process
    56.             genitem({_uuid}, {_loc})
    57.             #stop the function so it doesnt go to the delete lines
    58.             stop
    59.         #if the block isn't there anymore and this data still beeing set is invalid data and should be deleted
    60.         delete {generators::%{_uuid}%::%{_loc}%}
    61.         delete {generators::%{_uuid}%::%{_loc}%::loc}
    62.  
    63. on script load:
    64.     #stop all the generators
    65.     delete {GEN.ON}
    66.     #reset all the types
    67.     loop {gentypes::*}:
    68.         delete {gentypes::%loop-index%::*}
    69.     delete {gentypes::*}
    70.  
    71.    #creating type wheat  - Level 1
    72.     set {gentypes::wheat} to hay block
    73.     set {gentypes::wheat::item} to coal
    74.     #interval in ticks 20 ticks = 1 second
    75.     set {gentypes::wheat::interval} to 200 #in ticks 20 ticks = 1 second
    76.     set {gentypes::wheat::name} to "&bWheat {@namesuffix}"
    77.  
    78.    #creating type pumpkin - Level 2
    79.     set {gentypes::pumpkin} to pumpkin
    80.     set {gentypes::pumpkin::item} to pumpkin
    81.     #interval in ticks 20 ticks = 1 second
    82.     set {gentypes::pumpkin::interval} to 200
    83.     set {gentypes::pumpkin::name} to "&bPumpkin {@namesuffix}"
    84.  
    85. #creating type melon - Level 3
    86.     set {gentypes::melon} to melon
    87.     set {gentypes::melon::item} to melon
    88.     #interval in ticks 20 ticks = 1 second
    89.     set {gentypes::melon::interval} to 200
    90.     set {gentypes::melon::name} to "&bMelon {@namesuffix}"
    91.  
    92. #creating type coal - Level 4
    93.     set {gentypes::coal} to coal block
    94.     set {gentypes::coal::item} to coal
    95.     #interval in ticks 20 ticks = 1 second
    96.     set {gentypes::coal::interval} to 200
    97.     set {gentypes::coal::name} to "&bCoal {@namesuffix}"
    98.  
    99. #creating type iron - Level 5
    100.     set {gentypes::iron} to iron block
    101.     set {gentypes::iron::item} to iron ingot
    102.     #interval in ticks 20 ticks = 1 second
    103.     set {gentypes::iron::interval} to 200
    104.     set {gentypes::iron::name} to "&bIron {@namesuffix}"
    105.  
    106. #creating type diamond - Level 6
    107.     set {gentypes::diamond} to diamond block
    108.     set {gentypes::diamond::item} to diamond
    109.     #interval in ticks 20 ticks = 1 second
    110.     set {gentypes::diamond::interval} to 200
    111.     set {gentypes::diamond::name} to "&bDiamond {@namesuffix}"
    112.  
    113. #creating type emerald - Level 7
    114.     set {gentypes::emerald} to emerald block
    115.     set {gentypes::emerald::item} to emerald
    116.     #interval in ticks 20 ticks = 1 second
    117.     set {gentypes::emerald::interval} to 200
    118.     set {gentypes::emerald::name} to "&bEmerald {@namesuffix}"
    119.  
    120. #creating type redmush - Level 7
    121.     set {gentypes::redmush} to red mushroom block
    122.     set {gentypes::redmush::item} to red mushroom
    123.     #interval in ticks 20 ticks = 1 second
    124.     set {gentypes::redmush::interval} to 200
    125.     set {gentypes::redmush::name} to "&bMushroom {@namesuffix}"
    126.  
    127.     #security measure waiting to make sure all generators have been stopped by now
    128.     wait 1 second
    129.  
    130.     #Enable variable so generators are allowed to start again
    131.     set {GEN.ON} to true
    132.  
    133.     #loop all uuids
    134.     loop indices of {generators::*}:
    135.         #loop all locations of a uuid
    136.         loop {generators::%loop-value%::*}:
    137.             #get formatted location of a generator of a uuid
    138.             set {_l} to {generators::%loop-value-1%::%loop-index%::loc}
    139.             #start generator
    140.             genitem(loop-value-1, {_l})
    141.  
    142. #main command
    143. command /gen [<text>] [<text>]:
    144.     trigger:
    145.         #premission check
    146.         if player has permission "generator.admin":
    147.             if arg-1 is "give":
    148.                 #check if the type exists
    149.                 if {gentypes::%arg 2%::name} is set:
    150.                     #give the requested type
    151.                     give player {gentypes::%arg 2%} named {gentypes::%arg 2%::name} with lore {gentypes::%arg 2%::lore}
    152.                     stop
    153.                 send "{@prefix} &6- &cPlease select a valid gen type."
    154.                 stop
    155.             if arg 1 is "on":
    156.                 #check if its off so u can't turn it on double
    157.                 if {genoff::%uuid of player%} is set:
    158.                     send "{@prefix} &bGenerator is on now"
    159.                     set {_uuid} to uuid of player
    160.                     #allow generators to start for this player
    161.                     delete {genoff::%uuid of player%}
    162.                     #loop all locations of player
    163.                     loop {generators::%{_uuid}%::*}:
    164.                         #get formatted location of a generator of player
    165.                         set {_l} to {generators::%{_uuid}%::%loop-index%::loc}
    166.                         #start generator
    167.                         genitem({_uuid}, {_l})
    168.                 else:
    169.                     send "{@prefix} &bgenerator is already on"
    170.                 stop
    171.             if arg 1 is "off":
    172.                 #check if the generators of the player aren't already off
    173.                 if {genoff::%uuid of player%} is not set:
    174.                     send "{@prefix} &bGenerator is off now"
    175.                     #turn generators off
    176.                     set {genoff::%uuid of player%} to true
    177.                 else:
    178.                     send "{@prefix} &bgenerator is already off"
    179.                 stop
    180.             send "{@prefix} &6- &c/gen [<option>] [<gentype>]"
    181.  
    182. #debug command to delete all data if some manage to get stuck WARNING this is all data so all generators placed currently are lost.
    183. command /DEBUGGENRESET:
    184.     trigger:
    185.         loop indices of {generators::*}:
    186.             loop {generators::%loop-value%::*}:
    187.                 delete {generators::%loop-value-1%::%loop-index%::*}
    188.             delete {generators::%loop-value%::*}
    189.         delete {generators::*}
    190.         delete {genoff::*}
    191.  
    192. #break event
    193. on break:
    194.     #check if the current block is a generator and if this player is the owner
    195.     if {generators::%uuid of player%::%location of event-block%} is set:
    196.         #check if the player is sneaking
    197.         if player is sneaking:
    198.             send "{@prefix} &bGenerator collected!"
    199.             #get type of the broken generator
    200.             set {_type} to {generators::%uuid of player%::%location of event-block%}
    201.             #delete data of generator
    202.             delete {generators::%uuid of player%::%location of event-block%}
    203.             delete {generators::%uuid of player%::%location of event-block%::loc}
    204.             #give back generator
    205.             give player {gentypes::%{_type}%} named {gentypes::%{_type}%::name} with lore {gentypes::%{_type}%::lore}
    206.             stop
    207.         #cancels block break if the player is not sneaking
    208.         cancel event
    209.     #check if the block is a generator but if the player is not the owner
    210.     loop indices of {generators::*}:
    211.         if {generators::%loop-value%::%location of event-block%} is set:
    212.             #cancel block break bc the player is not the owner
    213.             cancel event
    214.             #can stop the loop bc the event already has been canceled
    215.             stop
    216.  
    217. #place event
    218. On place:
    219.     #get all the current types of generators
    220.     loop {gentypes::*}:
    221.         #check if the tool of the player is a know block that could be a generator
    222.         if player's tool is loop-value:
    223.             #check if the name of tool of the player is equal to how a generator is supposed to be called
    224.             if name of player's tool is {gentypes::%loop-index%::name}:
    225.                 #check if there is any old corrupted data for this location
    226.                 if {generators::%uuid of player%::%location of event-block%} is set:
    227.                     #delete corrupted data
    228.                     delete {generators::%uuid of player%::%location of event-block%}
    229.                     delete {generators::%uuid of player%::%location of event-block%::loc}
    230.                 #Create the data for the new generator
    231.                 set {generators::%uuid of player%::%location of event-block%} to loop-index
    232.                 set {generators::%uuid of player%::%location of event-block%::loc} to location of event-block
    233.                 send "{@prefix} &bGenerator Placed!" to player
    234.                 #Check if this player has its generators off
    235.                 if {genoff::%uuid of player%} is set:
    236.                     send "{@prefix} &bU currently have generators off. /gen on" to player
    237.                 else:
    238.                     #start the new created generator
    239.                     genitem(uuid of player, location of event-block)
    240.             stop
    241.  
    --- Double Post Merged, Mar 5, 2020, Original Post Date: Mar 5, 2020 ---
    Btw i found a bug when u place the gen it instantly spawns the item i mean that can be abused ppl can break and place it ton of times to make it for faster
     
  20. Lego_freak1999

    Lego_freak1999 Well-Known Member

    Joined:
    Jan 26, 2017
    Messages:
    664
    Likes Received:
    45
    Okay bug will be easy fix but how do they buy the generator then?
     
Thread Status:
Not open for further replies.

Share This Page

Loading...