예제 #1
0
    def _createPlayersView(self, selection):
        '''
        NOT CACHED
        :param selection:
        :return:
        '''
        playersViewButtons = [('Online', 'tribeUI.players.online'), ('Offline', 'tribeUI.players.offline')]
        gui = []

        anchormin_x = 0.105
        anchormin_y = 0.95
        anchormax_x = 0.19
        anchormax_y = 0.99

        gui.append(self.componentUIImage("playersView", parent="TribeBgUI", color="0.2 0.1 0.1 0.25", anchormin="0.000 0.08", anchormax="0.999 0.88"))

        for i, button in enumerate(playersViewButtons):
            if button[0] == selection:
                color = "1.0 0.3 0.3 0.95"
            else:
                color = "1.0 0.9 0.9 0.95"
            anchormin = str(anchormin_x)+' '+str(anchormin_y)
            anchormax = str(anchormax_x)+' '+str(anchormax_y)
            gui.append(self.componentUIText(text=button[0], parent="playersView", color=color, align="MiddleCenter", fontSize="16", anchormin=anchormin, anchormax=anchormax))
            gui.append(self.componentUIButton(command=button[1], parent="playersView", color="0.6 0.6 0.6 0.35", anchormin=anchormin, anchormax=anchormax))
            anchormin_x += 0.1
            anchormax_x += 0.1


        playersView = json.to_json(gui)
        objectList = json.makepretty(playersView)

        return objectList
예제 #2
0
    def _playerListObject(self, playerList, selection):
        '''
        :param playerList: list
        :return: objectList for UI generation
        '''


        gui = []

        gui.append(self.componentUIImage("playerList", parent="playersView", color="0.1 0.1 0.1 0.90", anchormin="0.001 0.0", anchormax="0.999 0.93"))

        anchormin_x = 0.002
        anchormin_y = 0.955
        anchormax_x = 0.097
        anchormax_y = 0.995



        for i, pl in enumerate(playerList):
            if i!=0  and i%20 == 0:
                anchormin_x += 0.1
                anchormin_y = 0.955
                anchormax_x += 0.1
                anchormax_y = 0.995
            anchormin = str(anchormin_x) + ' ' +str(anchormin_y)
            anchormax = str(anchormax_x) + ' '+ str(anchormax_y)
            gui.append(self.componentUIText(text=pl[1], parent="playerList", color="1.0 0.9 0.9 0.95", align="MiddleCenter", fontSize="11", anchormin=anchormin, anchormax=anchormax))
            gui.append(self.componentUIButton(command='tribe.player '+str(pl[0]), parent="playerList", color="0.6 0.6 0.6 0.55", anchormin=anchormin, anchormax=anchormax))
            anchormin_y -= 0.05
            anchormax_y -= 0.05

        playerListUI = json.to_json(gui)
        objectList = json.makepretty(playerListUI)

        return objectList
예제 #3
0
    def _createTribesView(self, tribeData):
        gui = []

        gui.append(self.componentUIImage('tribesView', parent="TribeBgUI", color="0.1 0.1 0.1 0.90", anchormin="0.000 0.08", anchormax="0.999 0.88"))

        anchormin_x = 0.002
        anchormin_y = 0.9
        anchormax_x = 0.15
        anchormax_y = 0.99

        for i, tribeName in enumerate(self.tribeNames):
            if i!=0  and i%9 == 0:
                anchormin_x += 0.15
                anchormin_y = 0.9
                anchormax_x += 0.15
                anchormax_y = 0.99
            anchormin = str(anchormin_x) + ' ' +str(anchormin_y)
            anchormax = str(anchormax_x) + ' '+ str(anchormax_y)
            name = tribeName[0]+' ('+str(tribeName[1])+' members)'
            gui.append(self.componentUIText(text=name, parent="tribesView", color="1.0 0.9 0.9 0.95", align="MiddleCenter", fontSize="13", anchormin=anchormin, anchormax=anchormax))
            gui.append(self.componentUIButton(command="tribe.members "+tribeName[0], parent="tribesView", color="0.6 0.6 0.6 0.55", anchormin=anchormin, anchormax=anchormax))
            anchormin_y -= 0.1
            anchormax_y -= 0.1

        playerListUI = json.to_json(gui)
        objectList = json.makepretty(playerListUI)

        return objectList
예제 #4
0
    def _createHelpMenu(self, selection):
        '''
        NOT CACHED
        :param selection:
        :return:
        '''
        helpButtons = [('Tribes', 'tribeUI.help.tribes'), ('Door System', 'tribeUI.help.doors'), ('Offline Protection', 'tribeUI.help.op'),('Building takeover', 'tribeUI.help.take'),('Server Info', 'tribeUI.help.server'), ('Commands', 'tribeUI.help.commands')]
        gui = []

        anchormin_x = 0.05
        anchormin_y = 0.95
        anchormax_x = 0.19
        anchormax_y = 0.99

        gui.append(self.componentUIImage("helpView", parent="TribeBgUI", color="0.2 0.1 0.1 0.25", anchormin="0.000 0.08", anchormax="0.999 0.88"))

        for i, button in enumerate(helpButtons):
            if button[1] == selection:
                color = "1.0 0.3 0.3 0.95"
            else:
                color = "1.0 0.9 0.9 0.95"
            anchormin = str(anchormin_x)+' '+str(anchormin_y)
            anchormax = str(anchormax_x)+' '+str(anchormax_y)
            gui.append(self.componentUIText(text=button[0], parent="helpView", color=color, align="MiddleCenter", fontSize="13", anchormin=anchormin, anchormax=anchormax))
            gui.append(self.componentUIButton(command=button[1], parent="helpView", color="0.6 0.6 0.6 0.25", anchormin=anchormin, anchormax=anchormax))
            anchormin_x += 0.15
            anchormax_x += 0.15


        helpView = json.to_json(gui)
        objectList = json.makepretty(helpView)

        return objectList
예제 #5
0
    def createPlayerStatistics(self, selection):
        self.destroyOverlay('playerStats')

        gui = []

        gui.append(self.componentUIImage('playerStats', parent="TribeBgUI", color="0.1 0.1 0.1 0.90", anchormin="0.0 0.08", anchormax="0.999 0.88"))
        gui.append(self.componentUIText(text="This is where you'll find your stats. It's under development, and it will be implementation soon (TM).", parent="playerStats", color="1.0 0.9 0.9 0.95", fontSize="16", align="MiddleCenter", anchormin="0.001 0.0", anchormax="0.999 0.93"))
        playerListUI = json.to_json(gui)
        objectList = json.makepretty(playerListUI)
        self.createOverlay(objectList)
예제 #6
0
    def _makeMenu(self, selection):
        '''
        NOT CACHED
        :param selection:
        :return:
        '''
        #menuItems = [("Tribes", "tribeUI.tribes"), ("Players", "tribeUI.players.online"), ("You", "tribeUI.you"), ("Help", 'tribeUI.help.tribes')]
        menuItems = [("Tribes", "tribeUI.tribes"), ("Players", "tribeUI.players.online"), ("Help", 'tribeUI.help.tribes')]

        #self.destroyOverlay(self, selection)
        gui = []

        gui.append(self.componentUIImage("MainMenu", parent="TribeBgUI", color="0.6 0.2 0.2 0.05", anchormin="0.0 0.89", anchormax="0.999 0.96"))

        anchormin_x = 0.005
        anchormin_y = 0.1
        anchormax_x = 0.1
        anchormax_y = 0.89
        for item in menuItems:
            anchormin = str(anchormin_x) + ' ' + str(anchormin_y)
            anchormax = str(anchormax_x) + ' ' + str(anchormax_y)

            if item[0] == selection:
                color = "1.0 0.3 0.3 0.95"
            else:
                color = "1.0 0.9 0.9 0.95"
            gui.append(self.componentUIText(text=item[0], parent="MainMenu", color=color,  align="MiddleCenter", fontSize="16", anchormin=anchormin, anchormax=anchormax))
            gui.append(self.componentUIButton(command=item[1], parent="MainMenu", color="0.6 0.6 0.6 0.35", anchormin=anchormin, anchormax=anchormax))





            anchormin_x += 0.1
            anchormax_x += 0.1


        menuUI = json.to_json(gui)
        objectList = json.makepretty(menuUI)

        return objectList
예제 #7
0
    def createButtons(self):
        buttons = [("Tribes", 'tribeUI.tribes'), ("Players", 'tribeUI.players.online'), ("Help", 'tribeUI.help.tribes')]

        gui = []
        gui.append(self.componentUIImage('TribeMenuButtons', parent="HUD/Overlay", color="0.1 0.1 0.1 0.75", anchormin="0.001 0.975", anchormax="0.999 1.0"))
        anchormin_x = 0.001
        anchormin_y = 0.01
        anchormax_x = 0.1
        anchormax_y = 0.99
        for button in buttons:
            anchormin = str(anchormin_x) + ' ' +str(anchormin_y)
            anchormax = str(anchormax_x) + ' '+ str(anchormax_y)
            gui.append(self.componentUIText(text=button[0], parent="TribeMenuButtons", color="1.0 1.0 1.0 0.8",  align="MiddleCenter", fontSize="13", anchormin=anchormin, anchormax=anchormax))
            gui.append(self.componentUIButton(command=button[1], parent="TribeMenuButtons", color="0.6 0.6 0.6 0.35", anchormin=anchormin, anchormax=anchormax))
            anchormin_x += 0.1
            anchormin_y = 0.01
            anchormax_x += 0.1
            anchormax_y = 0.99
        #gui.append(self.componentUIText(text="Press Enter or Tab to use the menu", parent="TribeMenuButtons", color="0.8 0.7 0.7 0.7", align="MiddleCenter", fontSize="12", anchormin="0.75 0.01", anchormax="1.0 0.999"))
        #gui.append(self.componentUIText(text="GUI is brokenn after patch, wip", parent="TribeMenuButtons", color="0.8 0.7 0.7 0.7", align="MiddleCenter", fontSize="8", anchormin="0.6 0.01", anchormax="1.0 0.999"))
        gameUI = json.to_json(gui)
        objectList = json.makepretty(gameUI)

        self.createOverlay(objectList)
예제 #8
0
    def _makeBackground(self):
        '''
        CACHED
        :return:
        '''
        ##Util.Log("making background")
        gui = []
        #bg
        gui.append(self.componentUIImage("TribeBgUI", parent="HUD/Overlay", color="0.1 0.1 0.1 0.85", anchormin="0.105 0.165", anchormax="0.889 0.955", needsCursor=True))
        #toptray
        gui.append(self.componentUIImage("toptray", parent="TribeBgUI", color="0.2 0.2 0.2 0.35", anchormin="0.0 0.97", anchormax="1.0 1.0"))
        # toptitle
        gui.append(self.componentUIText(text="Tribe and Player Info Panel", parent="TribeBgUI", color="0.8 1.0 1.0 0.95", fontSize="13", anchormin="0.01 0.965", anchormax="0.5 0.99"))

        #close button text
        gui.append(self.componentUIText(text="Close", parent="TribeBgUI", align="MiddleCenter", color="0.8 1.0 1.0 0.95", fontSize="13", anchormin="0.965 0.975", anchormax="0.995 0.995"))
        gui.append(self.componentUIButton(command="tribeUI.close" ,parent="TribeBgUI", color="0.6 0.6 0.6 0.55", anchormin="0.965 0.975", anchormax="0.995 0.995"))

        gui.append(self.componentUIText(text="Visit us on <color=blue>http//crohq.org</color>, facebook page <color=blue>'Croatian Gaming Headquarters'</color>, and join our Steam Group <color=blue>'CroHQ Rust TribeWars'</color>", parent="TribeBgUI", color="0.8 1.0 1.0 0.95", fontSize="15", anchormin="0.01 0.001", anchormax="0.99 0.05"))

        tribesUI = json.to_json(gui)
        objectList = json.makepretty(tribesUI)

        return objectList
예제 #9
0
            {
                "type": "UnityEngine.UI.Text",
                "text": "Skinning",
                "fontSize": 15,
                "align": "MiddleCenter",
            },
            {
                "type": "RectTransform",
                "anchormin": "0.35 0",
                "anchormax": "0.98 0.29"
            }
        ]
    },
]
string = json.encode(level)
levels = json.makepretty(string)


class LevelSystem:
    def On_PluginInit(self):
        Commands.Register("level").setCallback("stats").setDescription("Check your levels").setUsage("/level")
        if not Plugin.IniExists("Settings"):
            Plugin.CreateIni("Settings")
            ini = Plugin.GetIni("Settings")
            ini.AddSetting("Settings", "EXP per hit", "2")
            ini.AddSetting("Settings", "Mining level cap", "50")
            ini.AddSetting("Settings", "WoodCutting level cap", "50")
            ini.AddSetting("Settings", "Skinning level cap", "50")
            ini.AddSetting("Settings", "AutoSave data interval", "120")
            ini.Save()
        ini = Plugin.GetIni("Settings")
예제 #10
0
    def _createHelpScreen(self, selection):
        '''
        :param playerList: list
        :return: objectList for UI generation
        '''

        helpText = {'tribeUI.help.op':"<color=white>Offline Protection</color>\n\n" \
                     "The point of the Offline Protection system is, well, to prevent offline raid.\n" \
                     "Since it's one of the kind, you'll have to get to know how it works.\n\n" \
                     "Basically, when you go offline, your buildings get total protection from any player made damage for 24 hours.\n" \
                     "In case you don't come online in the next 24 hours, your building will be susceptible to damage.\n" \
                     "So, if you can't play, be sure to log in at least once in that 24 hour period to refresh the timer.\n" \
                     "NOTE: Offline Protection system doesn't prevent decay or helicopter damage!\n\n" \
                     "if a player attacks you or one of or your buildings, while you are online, you and the attacking player will be flagged with a 20 minute timer.\n" \
                     "If you log off while the timer is still on, when the timer runs out it will be extended for another 20 minutes, and you're building will not be protected until that timer runs out.\n" \
                     "That will prevent logouts in the middle of the raid to prevent raiders to take what they came for.\n" \
                     "So, if you wan't to protect your stuff, you'll have to fight for it!\n\n" \
                     "Tribe system is implemented to prevent players that are in the tribe to trigger Offline Protection system mechanisms.\n" \
                     "If you're playing with someone, join a Tribe to avoid any inconvenience and get some benefits.\n" \
                     "More about Tribe mechanism in Tribes help section.\n\n"\
                     "Usefull commands:.\n" \
                     " - /owner - turns on/off building part ownnership reporting when hitting a building part with a hammer. Hit a cupboard to get a list of authed players.\n"\
                     " - /flag - tells you for how long you'll be flaged\n",
        'tribeUI.help.tribes':"<color=white>TRIBES</color>\n\n" \
                       "If you wan't to live with someone, or use his doors, you'll have to join the tribe with him.\n" \
                       "Tribe members can access all doors belonging to other tribe members. \n" \
                       "If you're not part of the Tribe, you won't be able to use doors on tribe member buildings, even if they don't have a code lock, or you know the lock code.\n" \
                       "More about door changes read in Doors help section.\n\n" \
                       "When you're in a Tribe, aggression flags are applied to the whole Tribe\n" \
                       "Timer for offline protection counts from the moment last member of the tribe went offline\n" \
                       "Tribe members are not flagged if they attack each other.\n\n" \
                       "Tribe system is managed by chat commands.\n" \
                       "Available commands are:\n" \
                       " - /trcreate TribeName- Create a tribe, name must be 3-10 chars \n" \
                       " - /trinvite PlayerName - Invite player to your tribe\n" \
                       " - /traccept - Accept tribe invite \n" \
                       " - /trdetails - Get tribe details \n" \
                       " - /trleave - leave your tribe \n" \
                       " - /trdeny - deny tribe invite \n" \
                       " - /trlist - List tribes \n" \
                       " - /trkick -  kick member from tribe \n\n" \
                       "You can also type /trhelp in chat to get the list of available commands.\n\n",
        'tribeUI.help.doors':"<color=white>DOORS</color>\n\n" \
                      "Door system was implemented for two reasons:\n" \
                      " 1. We couldn't allow players using door on buildings whose owners were offline.\n" \
                      " 2. There's a rare glitch, or a hack, that lets people open doors without the code authorization.\n" \
                      "   - this system prevents both problems.\n\n" \
                      "When you place a door, they are bound to your GameID. Only you can open and close them.\n"\
                      "So there's no real need for code locks on doors any longer.\n" \
                      "If you're member of a Tribe, all tribe members will be able to access your doors automagically.\n\n" \
                      "If you need some privacy, put code locks on chests. \n" \
                      "That will prevent anyone opening them without the code.\n\n"\
                      "IMPORTANT: \n"\
                      "Until recently owners of the door frame were the owners of the doors. This has now changed and the player that places the door is now the real owner of the door, no matter who the owner of the door frame is!\n"\
                      "This means you can actually squat, and/or close someone inside his base with your own doors!",
        'tribeUI.help.take':"<color=white>BUILDING TAKEOVER</color>\n\n"\
                      "If you manage to get a hand of building permissions in a building from a player you can claim his base for yourself.\n"\
                      "You just need to type /take and hit every building block you see with a hammer.\n"\
                      "That way all the parts you hit will be yours from the moment you hit them, and they will be protected when you go offline.\n\n"\
                      "Also, if you get griefed, that's the only way to get ungriefed if the griefing player is offline.\n\n"\
                      "IMPORTANT: This makes protecting your cupboard more important then ever. If you suspect someone has taken the building ownership permisions, please clear the cupboard permissions.\n\n"\
                      "COMMANDS:\n"\
                      "/take - turns on/off building part takeover",
        'tribeUI.help.server':"<color=white>SERVER INFO</color>\n\n" \
                        " - sulfur gather rate increesed 100%, wood by 50%\n" \
                        " - decay lowered to 20% effectiveness\n" \
                        " - metabolism rate incresed, so you'll be hungry and thirsty much more\n" \
                        " - crafting times halved in building priviledge radius\n" \
                        " - when destroying a building part, another building part won't be placeable on that location for 2 minutes.\n"\
                        " - Incediary Rocket damage nulified for buildings (too many calculations for every flame). They still damage players, so you can use them as area deny.\n\n"\
                        "If you want to hide the menu, write /hidemenu in chat. Type /showmenu to show it again.\n\n"\
                        "You can vote for our server on http://rust-servers.net/server/51598/vote/\n"\
                        "Ater you cast your vote come back here and type /vote in chat. You'll get 500 wood and 250 stone for each vote you make.\n\n"\
                        "\nIf you have any other questions, ask in chat, someone will know the answer.\n" \
                        "For any problems with the server plugins, contact the server owner, or plugin developer, Pan Devas on Steam.\n" \
                        "\nJoin our Steam Group ''CroHQ Rust TribeWars'' for server updates and additional information.",
         'tribeUI.help.commands':"<color=white>COMMANDS</color>\n\n" \
                        " - /sleep - slowers you metabolism to a default value, usefull if you go afk in the house, so you don't die from hunger or thirst:\n"\
                        " - /ping  - test your ping\n"\
                        " - /remove - remove a building part you placed with a hammer (one remove in an hour, building priviledge required, can't be pvp flaged)\n"\
                        " - /paint URL name - place images from web on signs\n\n"\
                        "You can also bind keys in F1 console to automate the process of opening the UI:\n"\
                        " bind <key> <commmand>\n"\
                        " writecfg - to safe newly binded keys\n\n"\
                        "Commands:\n"\
                        "- tribeUI.tribes - show tribes\n"\
                        "- tribeUI.players - show online players\n"\
                        "- tribeUI.players.offline - show offline players\n"\
                        "- tribeUI.help - show help\n"\
                        "- tribeUI.close - close the UI\n\n"}

        gui = []

        gui.append(self.componentUIImage(selection, parent="helpView", color="0.1 0.1 0.1 0.90", anchormin="0.001 0.0", anchormax="0.999 0.93"))
        gui.append(self.componentUIText(text="TEXT", parent=selection, color="1.0 0.9 0.9 0.95", fontSize="13", anchormin="0.01 0.0", anchormax="0.999 0.93"))


        helpUI = json.to_json(gui)
        objectList = json.makepretty(helpUI)

        return objectList.Replace("TEXT", helpText[selection])
    {
        "parent": "flagui",
        "components": [
            {
                "type": "UnityEngine.UI.Text",
                "text": "[TEXT]",
                "color": "0.9 0.1 0.1 0.8",
                "fontSize": 11,
                "align": "MiddleCenter",
            },
            {"type": "RectTransform", "anchormin": "0.005 0.005", "anchormax": "0.99 0.995"},
        ],
    },
]
string = json.encode(flagmark)
flagged = json.makepretty(string)


class OfflineProtection:
    def On_PluginInit(self):
        # debug
        self.start = time.time()
        DataStore.Add("pvpFlags", "flagtableinit", time.time())
        # Items that are not building parts, but should be protected if offlline protection conditions
        self.protectedItems = ("Door", "SimpleBuildingBlock", "BuildingBlock", "StabilityEntity")
        self.ignoredDamagesList = ["Heat", "Decay", "ElectricShock"]

        if not DataStore.GetTable("pvpTribeFlags"):
            DataStore.Add("pvpTribeFlags", "system", time.time())

        settings = self.loadIniSettings()
예제 #12
0
    def _createTribePopup(self, tribeName):

        # windowSizeX=len(self.tribeMembers[tribeName])/10. * 0.25
        # #Util.Log(str(windowSizeX))
        self._getPlayerData("Players")
        details = ['Member:', 'Kills:', 'Deaths:', 'Resources:', 'Last Online']
        data = ['name', 'kills', 'deaths', 'ResStatistics', 'lastonline']
        tribeData = DataStore.Get('Tribes', tribeName)
        gui = []
        anchormin_x = 0.01
        anchormin_y = 0.75
        anchormax_x = 0.2
        anchormax_y = 0.79

        ##Util.Log(str(self.tribeMembers[tribeName]))
        gui.append(self.componentUIImage(tribeName, parent="TribeBgUI", color="0.2 0.2 0.2 0.98", anchormin="0.1 0.15", anchormax="0.9 0.85"))
        gui.append(self.componentUIButton(command="tribe.details.close", parent=tribeName, close=tribeName, color="0.8 1.0 1.0 0.0", anchormin="0.0 0.0", anchormax="1.0 1.0" ))
        gui.append(self.componentUIText(text="Tribename: " + tribeName, parent=tribeName, color="1.0 0.9 0.9 0.95", align="MiddleCenter", fontSize="16", anchormin="0.0 0.94", anchormax="0.99 0.99"))

        if tribeData['creatorID'] != 'system':
            gui.append(self.componentUIText(text="Founder: ", parent=tribeName, color="1.0 0.9 0.9 0.95", fontSize="15", anchormin="0.01 0.85", anchormax="0.2 0.90"))
            gui.append(self.componentUIText(text=self.playerDetails[tribeData['creatorID']]['name'], parent=tribeName, color="1.0 0.9 0.9 0.95", fontSize="15", anchormin="0.1 0.85", anchormax="0.2 0.90"))
            #gui.append(self.componentUIText(text="Members: ", parent=tribeName, color="1.0 0.9 0.9 0.95", fontSize="15", anchormin="0.01 0.79", anchormax="0.2 0.84"))

            for item in details:
                anchormin = str(anchormin_x) + ' ' +str(anchormin_y)
                anchormax = str(anchormax_x) + ' '+ str(anchormax_y)
                gui.append(self.componentUIText(text=item, parent=tribeName, color="1.0 0.9 0.9 0.95", fontSize="13", anchormin=anchormin, anchormax=anchormax))
                anchormin_x += 0.15
                anchormax_x += 0.15

            anchormin_y -= 0.05
            anchormax_y -= 0.05


            for i, pl in enumerate(self.tribeMembers[tribeName]):
                anchormin_x = 0.05
                anchormax_x = 0.15
                anchormin = str(anchormin_x) + ' ' +str(anchormin_y)
                anchormax = str(anchormax_x) + ' '+ str(anchormax_y)

                for item in data:
                    if item == 'name':
                        gui.append(self.componentUIText(text=self.playerDetails[pl][item], parent=tribeName, color="1.0 0.9 0.9 0.95", fontSize="13", anchormin=anchormin, anchormax=anchormax))
                    elif item == 'kills':
                        gui.append(self.componentUIText(text=str(self.playerDetails[pl]['PVPstatistics'][item]), parent=tribeName, color="1.0 0.9 0.9 0.95", fontSize="13", anchormin=anchormin, anchormax=anchormax))
                    elif item == 'deaths':
                        gui.append(self.componentUIText(text=str(self.playerDetails[pl]['PVPstatistics'][item]), parent=tribeName, color="1.0 0.9 0.9 0.95", fontSize="13", anchormin=anchormin, anchormax=anchormax))
                    elif item == 'ResStatistics':
                        gui.append(self.componentUIText(text=str(self.playerDetails[pl][item]), parent=tribeName, color="1.0 0.9 0.9 0.95", fontSize="13", anchormin=anchormin, anchormax=anchormax))
                    elif item == 'lastonline':
                        if Server.FindPlayer(pl):
                            onlineStatus = 'Now'
                        else:
                            onlineStatus = str(round((time.time() - self.playerDetails[pl]['lastonline'])/3600, 2))+ ' hours ago'
                        gui.append(self.componentUIText(text=str(onlineStatus), parent=tribeName, color="1.0 0.9 0.9 0.95", fontSize="13", anchormin=anchormin, anchormax=anchormax))

                    anchormin_x += 0.15
                    anchormax_x += 0.15
                    anchormin = str(anchormin_x) + ' ' +str(anchormin_y)
                    anchormax = str(anchormax_x) + ' '+ str(anchormax_y)

                anchormin_x = 0.01
                anchormax_x = 0.2
                anchormin_y -= 0.05
                anchormax_y -= 0.05
        else:
            gui.append(self.componentUIText(text="Members: ", parent=tribeName, color="1.0 0.9 0.9 0.95", fontSize="15", anchormin="0.01 0.85", anchormax="0.2 0.90"))
            anchormin_y = 0.8
            anchormax_y = 0.85
            for i, pl in enumerate(self.tribeMembers[tribeName]):

                if i!=0  and i%15 == 0:
                    anchormin_x += 0.1
                    anchormin_y = 0.8
                    anchormax_x += 0.2
                    anchormax_y = 0.85
                anchormin = str(anchormin_x) + ' ' +str(anchormin_y)
                anchormax = str(anchormax_x) + ' '+ str(anchormax_y)
                gui.append(self.componentUIText(text=self.playerDetails[pl]['name'], parent=tribeName, color="1.0 0.9 0.9 0.95", align="MiddleCenter", fontSize="13", anchormin=anchormin, anchormax=anchormax))
                anchormin_y -= 0.05
                anchormax_y -= 0.05


        gui.append(self.componentUIText(text="Click here close", parent=tribeName, color="1.0 0.2 0.2 0.95", align="MiddleCenter", fontSize="11", anchormin="0.4 0.05", anchormax="0.6 0.09"))
        gui.append(self.componentUIButton(command="tribe.details.close", parent=tribeName, close=tribeName, color="0.6 0.6 0.6 0.15", anchormin="0.0 0.05", anchormax="1.0 0.09"))


        tribeDetails = json.to_json(gui)
        objectList = json.makepretty(tribeDetails)

        return objectList
                "type": "UnityEngine.UI.Text",
                "text": "[TEXT]",
                "color":  "0.1 0.9 0.1 0.8",
                "fontSize": 11,
                "align": "MiddleCenter",
            },
            {
                "type": "RectTransform",
                "anchormin": "0.005 0.005",
                "anchormax": "0.99 0.995"
            }
        ]
    }
]
string = json.encode(takemark)
takemark = json.makepretty(string)

class OPBuildingChanger():

    def On_PluginInit(self):
        Commands.Register('take').setCallback('take')

        self.takeoverItems = ("SimpleBuildingBlock", 'BuildingBlock')
        self.takeoverPlayers = self.datastoreInit()

        settings = self.loadIniSettings()
        self.takeoverProtection = settings.GetIntSetting('settings', 'takeoverProtection')

    def datastoreInit(self):
        if not DataStore.GetTable("PlayerFlags"):
            DataStore.Add("PlayerFlags", "Take", [])
예제 #14
0
    def _createPlayerPopup(self, playerID):

        # windowSizeX=len(self.tribeMembers[tribeName])/10. * 0.25
        # #Util.Log(str(windowSizeX))
        gui = []

        player = Server.FindPlayer(playerID)

        if player:
            playerData = DataStore.Get('Players', player.GameID)
            onlineStatus = 'Now'
        else:
            player = BasePlayer.FindSleeping(playerID)
            playerData = DataStore.Get('Players', player.userID)
            onlineStatus = str(round((time.time() - playerData['lastonline'])/3600, 2))+ ' hours ago'
        if onlineStatus == 'Now' :
            timeOnline = str(round((playerData['timeonline'] + (time.time() - playerData['lastonline']))/3600,2))+' hours'
        else:
            timeOnline = str(round(playerData['timeonline']/3600,2))+' hours'


        columnTitles = ("Player Details:", "Statistics:", "Top Weapons:", 'Killed:', "Killed by:")

        playerDetails = (('Tribe', playerData['tribe']), ('Tribe Rank', playerData['tribeRank']), ('Last Online', onlineStatus), ('Time Online', timeOnline),('Res gathered', playerData['ResStatistics']))
        statistics = (('Killls', playerData['PVPstatistics']['kills']), ('Deaths', playerData['PVPstatistics']['deaths']), ('Suicides', playerData['PVPstatistics']['suicides']),('Max Range', playerData['PVPstatistics']['max_range']))
        topWeapons = []
        killed = []
        killedBy = []

        weaponUse = []
        for weapon in playerData['WeaponKills'].keys():
            weaponUse.append((weapon, playerData['WeaponKills'][weapon]))
        weaponUse.sort(key=lambda tup: tup[1], reverse=True)
        for i in range(len(weaponUse)):
            topWeapons.append((weaponUse[i][0], weaponUse[i][1]))
            if i > 5:
                break

        for kill in playerData['killed'].keys():
            killed.append((DataStore.Get('Players', kill)['name'], playerData['killed'][kill]))
        killed.sort(key=lambda tup: tup[1], reverse=True)
        killed = killed[:10]
        for killBy in playerData['killedBy'].keys():
            killedBy.append((DataStore.Get('Players', killBy)['name'] ,playerData['killedBy'][killBy]))
        killedBy.sort(key=lambda tup: tup[1], reverse=True)
        killedBy = killedBy[:10]

        columns = [playerDetails, statistics, topWeapons, killed, killedBy]

        ##Util.Log(str(self.tribeMembers[tribeName]))
        gui.append(self.componentUIImage(playerID, parent="playerList", color="0.2 0.2 0.2 0.98", anchormin="0.0 0.01", anchormax="0.999 0.99"))
        gui.append(self.componentUIText(text=playerData['name'], parent=playerID, color="0.8 0.8 0.8 0.75", align="MiddleCenter", fontSize="16", anchormin="0.0 0.94", anchormax="0.99 0.99"))


        for i, title in enumerate(columnTitles):
            anchormin_x = 0.01+(i*0.2)
            anchormin_y = 0.85
            anchormax_x = 0.285+(i*0.2)
            anchormax_y = 0.9
            anchormin = str(anchormin_x) + ' ' + str(anchormin_y)
            anchormax = str(anchormax_x) + ' ' + str(anchormax_y)
            anchorminB = str(anchormin_x)+ ' 0.3'
            anchormaxB = str(anchormax_x-0.1)+ ' ' + str(anchormax_y+0.02)
            anchorminTitle = str(anchormin_x+0.005)+ ' 0.1'
            anchormaxTitle = str(anchormax_x)+ ' ' + str(anchormax_y)

            gui.append(self.componentUIText(text=columnTitles[i], parent=playerID, color="1.0 0.9 0.9 0.85", fontSize="15", anchormin=anchorminTitle, anchormax=anchormaxTitle))
            gui.append(self.componentUIImage("statsBG", parent=playerID, color="0.6 0.6 0.6 0.55", anchormin=anchorminB, anchormax=anchormaxB))
            for j, detail in enumerate(columns[i]):
                anchormin_y = 0.8-((j+1)*0.05)
                anchormax_y = 0.9-((j+1)*0.05)
                anchormin = str(anchormin_x+0.01) + ' ' + str(anchormin_y)
                anchormax = str(anchormax_x) + ' ' + str(anchormax_y)
                gui.append(self.componentUIText(text=columns[i][j][0]+': '+str(columns[i][j][1]), parent=playerID, color="1.0 0.9 0.9 0.95", fontSize="13", anchormin=anchormin, anchormax=anchormax))


        gui.append(self.componentUIText(text="Click here to close", parent=playerID, color="1.0 0.1 0.1 0.95", align="MiddleCenter", fontSize="11", anchormin="0.0 0.05", anchormax="1.0 0.09"))
        gui.append(self.componentUIButton(command="tribe.player.close", parent=playerID, close=playerID, color="0.6 0.6 0.6 0.25", anchormin="0.0 0.05", anchormax="1.0 0.09" ))

        tribeDetails = json.to_json(gui)
        objectList = json.makepretty(tribeDetails)

        return objectList
예제 #15
0
            {
                "type": "UnityEngine.UI.Text",
                "text": "[TEXT]",
                "fontSize": 20,
                "align": "MiddleCenter",
            },
            {
                "type": "RectTransform",
                "anchormin": "0.005 0.005",
                "anchormax": "0.995 0.995"
            }
        ]
    }
]
string = json.encode(broadcastgui)
broadcast = json.makepretty(string)


class UITEST:
    def On_Command(self, CommandEvent):
        Player = CommandEvent.User
        cmd = CommandEvent.Cmd
        args = CommandEvent.Args
        if cmd == "show":
            if Player.Admin:
                if len(args) == 0:
                    Player.Message("Usage: /show <insert your message here>")
                else:
                    timer = Plugin.GetTimer("RemoveBroadcast")
                    if timer is not None:
                        timer.Kill()
            {
                "type": "UnityEngine.UI.Text",
                "text": "[TIME]",
                "fontSize": 20,
                "align": "MiddleCenter",
            },
            {
                "type": "RectTransform",
                "anchormin": "0.755 0.55",
                "anchormax": "0.995 0.95"
            }
        ]
    }
]
string = json.encode(HUDBAR)
hud = json.makepretty(string)
HEALTHBAR = [
    {
        "name": "healthui",
        #"parent": "Overlay",
        "components":
        [
            {
                "type": "UnityEngine.UI.Image",
                "color": "0.3 0.3 0.3 0.2",
            },
            {
                "type": "RectTransform",
                "anchormin": "0.007 0.010",
                "anchormax": "0.195 0.040"
            }
        "parent":
        "hudui",
        "components": [{
            "type": "UnityEngine.UI.Text",
            "text": "[TIME]",
            "fontSize": 20,
            "align": "MiddleCenter",
        }, {
            "type": "RectTransform",
            "anchormin": "0.755 0.55",
            "anchormax": "0.995 0.95"
        }]
    }
]
string = json.encode(HUDBAR)
hud = json.makepretty(string)
HEALTHBAR = [
    {
        "name":
        "healthui",
        #"parent": "Overlay",
        "components": [{
            "type": "UnityEngine.UI.Image",
            "color": "0.3 0.3 0.3 0.2",
        }, {
            "type": "RectTransform",
            "anchormin": "0.007 0.010",
            "anchormax": "0.195 0.040"
        }]
    },
    {
예제 #18
0
            {
                "type": "UnityEngine.UI.Text",
                "text": "[TEXT]",
                "fontSize": 20,
                "align": "MiddleCenter",
            },
            {
                "type": "RectTransform",
                "anchormin": "0.005 0.005",
                "anchormax": "0.995 0.995"
            }
        ]
    }
]
string = json.encode(broadcastgui)
broadcast = json.makepretty(string)


class LegacyBroadcast:
    def On_PluginInit(self):
        if not Plugin.IniExists("Settings"):
            Plugin.CreateIni("Settings")
            ini = Plugin.GetIni("Settings")
            ini.AddSetting("Settings", "Command", "/say")
            ini.AddSetting("Settings", "Popup time", "10")
            ini.AddSetting("Allowed Ranks", "Users", "false")
            ini.AddSetting("Allowed Ranks", "Moderators", "true")
            ini.AddSetting("Allowed Ranks", "Admins", "true")
            ini.Save()
        ini = Plugin.GetIni("Settings")
        DataStore.Add("BroadCast", "Timer", int(ini.GetSetting("Settings", "Popup time")) * 1000)