Paste #46747: Untitled Paste

Date: 2018/02/25 09:07:59 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


Plot_Cells_Events:
    type: world
    events:
        on system time hourly:
        - inject Plot_Cells_Check_PlotCells


        on player changes sign:
        - if <context.new.get[1]> == "[Cell]" {
            - define plot <context.location.plotsquared_plot||null>
            - if <def[plot]> == null {
                - queue clear
            }
            - define cells <server.flag[Plots.<def[plot]>.Config.Plot_Cells].as_list||li@>
            - if <def[cells].is_empty||true> {
                - narrate "<&c>Du har ikke nogen celler  dit plot"
                - determine "<&4>[Cell]|<context.new.get[2]>|<context.new.get[3]>|<context.new.get[4]>" passively
                - queue clear
            }
            - if <def[cells].contains[<context.new.get[2]>].not||true> {
                - narrate format:util_ff "<&c>Denne celle eksistere ikke  dette plot"
                - determine "<&4>[Cell]|<context.new.get[2]>|<context.new.get[3]>|<context.new.get[4]>" passively
                - queue clear
            }
            - define cell_id <context.new.get[2]>
            - if <server.has_flag[Plots.<def[plot]>.Config.Plot_Cell.cells.<def[cell_id]>.sign]> {
                - define pos <server.flag[Plots.<def[plot]>.Config.Plot_Cell.cells.<def[cell_id]>.sign]>
                - if <def[pos].as_location.material.name.contains[sign]> {
                    - if <def[pos]> != <context.location> {
                        - narrate format:util_ff "<&e>Fjernede forrige celle skilt."
                        - sign type:automatic "<&sp>|<&sp>|<&sp>|<&sp>" <server.flag[Plots.<def[plot]>.Config.Plot_Cell.cells.<def[cell_id]>.sign]>
                    }
                }
            }
            - if <server.has_flag[Plots.<def[plot]>.Config.Plot_Cell.cells.<def[cell_id]>.owner]> {
                - define time_left <server.flag[Plots.<def[plot]>.Config.Plot_Cell.cells.<def[cell_id]>.time_left].div[1000].as_duration>
                - define time_prefix "<def[time_left].time.day>-<def[time_left].time.month>-<def[time_left].time.year>" 
                - determine "<&1>[Cell]|<&b><def[cell_id]>|<&b><server.flag[Plots.<def[plot]>.Config.Plot_Cell.cells.<def[cell_id]>.owner].as_player.name>|<&3><def[time_prefix]>" passively
            }
            else {
                - if <context.new.get[3].replace[$].as_int||null> == null {
                    - define price "$100"
                }
                else {
                    - define price <context.new.get[3]>
                }
                - determine "<&1>[Cell]|<&b><def[cell_id]>|<&3><def[price]>|<&2><&l>Ledig" passively
                - flag server Plots.<def[plot]>.Config.Plot_Cell.cells.<def[cell_id]>.price:<def[price]>
            }
            - flag server Plots.<def[plot]>.Config.Plot_Cell.cells.<def[cell_id]>.sign:<context.location>
            - narrate format:util_ff "<&a>Oprettet celle skilt<&co> <&6><def[cell_id]>"
        }

        on player right clicks WALL_SIGN:
        - inject Plot_Cells_Sign_Task

        on player right clicks SIGN_POST:
        - inject Plot_Cells_Sign_Task

        on player left clicks WALL_SIGN:
        - if <player.gamemode> == CREATIVE {
            - queue clear
        }
        - inject Plot_Cells_Sign_Task

        on player left clicks SIGN_POST:
        - if <player.gamemode> == CREATIVE {
            - queue clear
        }
        - inject Plot_Cells_Sign_Task

        on player clicks Plot_Cells_Item_Add in Plot_Cells_Menu_Cell_Owner:
        - determine cancelled passively

        on player clicks Plot_Cells_Item_Remove in Plot_Cells_Menu_Cell_Owner:
        - determine cancelled passively

        on player clicks Plot_Cells_Item_Leave in Plot_Cells_Menu_Cell_Owner:
        - determine cancelled passively
        - inventory close d:<context.inventory>
        - define plot <player.flag[Plot_Target].as_plotsquared_plot>
        - define cell_id <player.flag[Cell_Target]>
        - narrate format:util_ff "<&a>Du forlod din celle  dette plot"
        - run Plot_Cells_Reset_Cell instantly context:<def[plot]>|<def[cell_id]>

        on player clicks Plot_Cells_Item_Extend in Plot_Cells_Menu_Cell_Owner:
        - determine cancelled passively
        - flag server Plot_Target:<player.flag[Plot_Target]>
        - flag server Cell_Target:<player.flag[Cell_Target]>
        - inventory open d:in@Plot_Cells_Menu_Extend

        on player drags in Plot_Cells_Menu_Cell_Owner:
        - determine cancelled passively

        on player clicks Plot_Cells_Item_Buy in Plot_Cells_Menu_Buy_Cell:
        - determine cancelled passively
        - define plot <player.flag[Plot_Target].as_plotsquared_plot>
        - define cell_id <player.flag[Cell_Target]>
        - foreach <server.flag[Plots.<def[plot]>.Config.Plot_Cells].as_list||li@> {
            - if <server.flag[Plots.<def[plot]>.Config.Plot_Cell.cells.<def[value]>.Owner]||null> == <player> {
                - narrate format:util_ff "<&c>Du har allerede en celle  dette plot"
                - queue clear
            }
        }
        - define price <context.location.sign_contents.get[3].strip_color.replace[$].as_int||100>
        - if <player.money> < <def[price]> {
            - narrate format:util_ff "<&c>Du har ikke råd til at leje denne celle"
            - queue clear
        }
        - money take quantity:<def[price]> from:<player>
        - define time_left <util.date.time.duration.add[1d]>
        - define time_prefix "<def[time_left].time.day>-<def[time_left].time.month>-<def[time_left].time.year>" 
        - narrate format:util_ff "<&a>Du har lejet denne celle for <def[price]>$ til <def[time_prefix]>"
        - flag server Plots.<def[plot]>.Config.Plot_Cell.cells.<def[cell_id]>.time_left:<def[time_left].in_milliseconds>
        # - flag server Plots.<def[plot]>.Config.Plot_Cell.cells.<def[cell_id]>.price:<context.location.sign_contents.get[3]||100>
        - flag server Plots.<def[plot]>.Config.Plot_Cell.cells.<def[cell_id]>.owner:<player>
        - sign type:automatic "<&1>[Cell]|<&b><def[cell_id]>|<&b><player.name>|<&3><def[time_prefix]>" <server.flag[Plots.<def[plot]>.Config.Plot_Cell.cells.<def[cell_id]>.sign]>
        - flag server Plot_Target:<def[plot]>
        - flag server Cell_Target:<def[cell_id]>
        - inventory open d:in@Plot_Cells_Menu_Cell_Owner
        - define world <def[plot].world>
        - define region_id "Cell_<def[world].name>_<def[plot].x>_<def[plot].z>_<def[cell_id]>"
        - execute as_server "worldguard:region addmember <def[region_id]> <player.name> -w <def[world].name>"
        # Execute addowner to WorldGuard (command)

        on player drags in Plot_Cells_Menu_Buy_Cell:
        - determine cancelled passively

        on player clicks Plot_Cells_Item_Info in inventory:
        - determine cancelled passively

        on player clicks Plot_Cells_Item_Wall in inventory:
        - determine cancelled passively

        on player clicks Plot_Cells_Item_Back in inventory:
        - determine cancelled passively
        - flag server Plot_Target:<player.flag[Plot_Target]>
        - flag server Cell_Target:<player.flag[Cell_Target]>
        - inventory open d:in@Plot_Cells_Menu_Cell_Owner

        on player clicks in Plot_Cells_Menu_Extend:
        - determine cancelled passively
        - if <context.item.scriptname.starts_with[Plot_Cells_Item_Extend].not||true> {
            - queue clear
        }
        - define plot <player.flag[Plot_Target].as_plotsquared_plot>
        - define cell_id <player.flag[Cell_Target]>
        - define times <context.item.scriptname.after[Plot_Cells_Item_Extend_].before[Day]>
        - inject Plot_Cells_Extend_Rent

        on player drags in Plot_Cells_Menu_Extend:
        - determine cancelled passively

        on player clicks Plot_Cells_Item_Reset in Plot_Cells_Menu_KontrolPanel:
        - determine cancelled passively
        - inventory close d:<context.inventory>
        - define plot <player.flag[Plot_Target].as_plotsquared_plot>
        - define cell_id <player.flag[Cell_Target]>
        - narrate format:util_ff "<&a>Denne celle er nu blevet resat"
        - run Plot_Cells_Reset_Cell instantly context:<def[plot]>|<def[cell_id]>

        on player clicks Plot_Cells_Item_Delete in Plot_Cells_Menu_KontrolPanel:
        - determine cancelled passively
        - inventory close d:<context.inventory>
        - define plot <player.flag[Plot_Target].as_plotsquared_plot>
        - define cell_id <player.flag[Cell_Target]>
        - run Plot_Cells_Remove instantly context:<def[cell_id]>|<def[plot]> player:<player>

        on player drags in Plot_Cells_Menu_KontrolPanel:
        - determine cancelled passively

        on player drags in Plot_Cells_Menu_RemoveMember:
        - determine cancelled passively