Facebook
From Cobalt Mockingjay, 7 Years ago, written in Python.
Embed
Download Paste or View Raw
Hits: 324
  1. import re
  2. import ChatManager
  3.  
  4. DEV = False
  5.  
  6. class rules:
  7.  
  8.     def __init__(self):
  9.  
  10.         self.Title = 'Server Rules'
  11.         self.Version = V(1, 0, 1)
  12.         self.Author = 'SkinN'
  13.         self.Description = 'Displays customized rules for your server'
  14.         self.ResourceId = 1514
  15.         self.Default = {
  16.             'SETTINGS': {
  17.                 'PREFIX': '<white>[<end> <cyan>SERVER RULES<end> <white>]<end>',
  18.                 'COMMAND TRIGGER': 'rules',
  19.                 'DEFAULT LANGUAGE': 'en',
  20.                 'ENUMERATE RULES': True,
  21.                 'REMOVE CHAT COLORS': False,
  22.             },
  23.             'MESSAGES': {
  24.                 'TITLE PREFIX': '<orange>•<end> <silver>SERVER RULES<end>:',
  25.                 'AVAILABLE LANGS': 'Available languages',
  26.                 'LANG NOT EXIST': 'Could not find <red>{lang}<end> language, type <lime>/rules list<end> for the full list of languages.'
  27.             },
  28.             'RULES': {
  29.                 'EN': (
  30.                     'Cheating is strictly prohibited.',
  31.                     'Respect all players',
  32.                     'Avoid spam in chat.',
  33.                     'Play fair and don\'t abuse of bugs/exploits.'
  34.                 ),
  35.                 'PT': (
  36.                     'Usar cheats e totalmente proibido.',
  37.                     'Respeita todos os jogadores.',
  38.                     'Evita spam no chat.',
  39.                     'Nao abuses de bugs ou exploits.'
  40.                 ),
  41.                 'FR': (
  42.                     'Tricher est strictement interdit.',
  43.                     'Respectez tous les joueurs.',
  44.                     'Évitez le spam dans le chat.',
  45.                     'Jouer juste et ne pas abuser des bugs / exploits.'
  46.                 ),
  47.                 'ES': (
  48.                     'Los trucos están terminantemente prohibidos.',
  49.                     'Respeta a todos los jugadores.',
  50.                     'Evita el Spam en el chat.',
  51.                     'Juega limpio y no abuses de bugs/exploits.'
  52.                 ),
  53.                 'DE': (
  54.                     'Cheaten ist verboten!',
  55.                     'Respektiere alle Spieler',
  56.                     'Spam im Chat zu vermeiden.',
  57.                     'Spiel fair und missbrauche keine Bugs oder Exploits.'
  58.                 ),
  59.                 'TR': (
  60.                     'Hile kesinlikle yasaktır.',
  61.                     'Tüm oyuncular Saygı.',
  62.                     'Sohbet Spam kaçının.',
  63.                     'Adil oynayın ve böcek / açıkları kötüye yok.'
  64.                 ),
  65.                 'IT': (
  66.                     'Cheating è severamente proibito.',
  67.                     'Rispettare tutti i giocatori.',
  68.                     'Evitare lo spam in chat.',
  69.                     'Fair Play e non abusare di bug / exploit.'
  70.                 ),
  71.                 'DK': (
  72.                     'Snyd er strengt forbudt.',
  73.                     'Respekter alle spillere.',
  74.                     'Undgå spam i chatten.',
  75.                     'Spil fair og misbrug ikke bugs / exploits.'
  76.                 ),
  77.                 'RU': (
  78.                     'Запрещено использовать читы.',
  79.                     'Запрещено спамить и материться.',
  80.                     'Уважайте других игроков.',
  81.                     'Играйте честно и не используйте баги и лазейки.'
  82.                 ),
  83.                 'NL': (
  84.                     'Vals spelen is ten strengste verboden.',
  85.                     'Respecteer alle spelers',
  86.                     'Vermijd spam in de chat.',
  87.                     'Speel eerlijk en maak geen misbruik van bugs / exploits.'
  88.                 ),
  89.                 'UA': (
  90.                     'Обман суворо заборонено.',
  91.                     'Поважайте всіх гравців',
  92.                     'Щоб уникнути спаму в чаті.',
  93.                     'Грати чесно і не зловживати помилки / подвиги.'
  94.                 ),
  95.                 'RO': (
  96.                     'Cheaturile sunt strict interzise!',
  97.                     'Respectați toți jucătorii!',
  98.                     'Evitați spamul în chat!',
  99.                     'Jucați corect și nu abuzați de bug-uri/exploituri!'
  100.                 ),
  101.                 'HU': (
  102.                     'Csalás szigorúan tilos.',
  103.                     'Tiszteld minden játékostársad.',
  104.                     'Kerüld a spammolást a chaten.',
  105.                     'Játssz tisztességesen és nem élj vissza a hibákkal.'
  106.                 )
  107.             }
  108.         }
  109.  
  110.     # -------------------------------------------------------------------------
  111.     # - CONFIGURATION / DATABASE SYSTEM
  112.     def LoadDefaultConfig(self):
  113.         '''Hook called when there is no configuration file '''
  114.  
  115.         self.Config.Clear()
  116.         self.Config = self.Default
  117.         self.SaveConfig()
  118.  
  119.     # -------------------------------------------------------------------------
  120.     def UpdateConfig(self):
  121.         '''Function to update the configuration file on plugin Init '''
  122.  
  123.         # Override config in developer mode is enabled
  124.         if DEV: self.LoadDefaultConfig(); return
  125.  
  126.         # Start configuration checks
  127.         for section in self.Default:
  128.  
  129.             # Is section in the configuration file
  130.             if section not in self.Config:
  131.  
  132.                 # Add section to config
  133.                 self.Config[section] = self.Default[section]
  134.  
  135.             elif isinstance(self.Default[section], dict):
  136.  
  137.                 # Check for sub-section
  138.                 for sub in self.Default[section]:
  139.  
  140.                     if sub not in self.Config[section]:
  141.  
  142.                         self.Config[section][sub] = self.Default[section][sub]
  143.  
  144.         self.SaveConfig()
  145.  
  146.     # -------------------------------------------------------------------------
  147.     # - PLUGIN HOOKS
  148.     def Init(self):
  149.         '''Hook called when the plugin initializes '''
  150.  
  151.         # Update System
  152.         self.UpdateConfig()
  153.  
  154.         # Global and Plugin variables
  155.         global MSG, PLUGIN, RULES
  156.         MSG, PLUGIN, RULES = [self.Config[x] for x in ('MESSAGES', 'SETTINGS', 'RULES')]
  157.  
  158.         self.prefix = PLUGIN['PREFIX'] if PLUGIN['PREFIX'] else ''
  159.  
  160.         # Command trigger
  161.         command.AddChatCommand(PLUGIN['COMMAND TRIGGER'], self.Plugin, 'rules_CMD')
  162.  
  163.         # Plugin Command
  164.         command.AddChatCommand('serverrules', self.Plugin, 'plugin_CMD')
  165.  
  166.     # -------------------------------------------------------------------------
  167.     # - COMMAND FUNCTIONS
  168.     def rules_CMD(self, player, command, args):
  169.         '''Rules command function '''
  170.  
  171.         key = PLUGIN['DEFAULT LANGUAGE'].upper()
  172.  
  173.         if args:
  174.  
  175.             # Get arguments as a string
  176.             arg = ' '.join(args).upper()
  177.  
  178.             if arg.lower() == 'list':
  179.  
  180.                 self.tell(player, '%s %s: <lightblue>%s<end>' % (self.prefix, MSG['AVAILABLE LANGS'], ', '.join(RULES.keys())))
  181.  
  182.                 return
  183.  
  184.             # Check if argument is a valid key
  185.             elif arg in RULES:
  186.  
  187.                 key = arg
  188.  
  189.             else:
  190.  
  191.                 self.tell(player, '%s %s' % (self.prefix, MSG['LANG NOT EXIST'].replace('{lang}', 'arg')))
  192.  
  193.                 return
  194.  
  195.         # Get list of rules
  196.         lis = RULES[key]
  197.  
  198.         self.tell(player, MSG['TITLE PREFIX'])
  199.  
  200.         if PLUGIN['ENUMERATE RULES']:
  201.  
  202.             for n, i in enumerate(lis):
  203.  
  204.                 self.tell(player, '<orange>%s.<end> <lightblue>%s<end>' % (n+1, i))
  205.  
  206.         else:
  207.  
  208.             for i in lis:
  209.  
  210.                 self.tell(player, '<lightblue>%s<end>' % i)
  211.  
  212.     # -------------------------------------------------------------------------
  213.     def plugin_CMD(self, player, command, args):
  214.         '''Plugin command function '''
  215.  
  216.         self.tell(player, '<lightblue><size=18>%s</size> <grey>v%s<end><end>' % (self.Title, self.Version))
  217.         self.tell(player, '<silver><orange><size=20>•</size><end> %s<end>' % self.Description)
  218.         self.tell(player, '<silver><orange><size=20>•</size><end> Plugin developed by <#9810FF>SkinN<end>, powered by <orange>Oxide 2<end>.<end>')
  219.  
  220.     # -------------------------------------------------------------------------
  221.     # - PLUGIN FUNCTIONS / HOOKS
  222.     def playerid(self, player):
  223.         '''Function to return the player UID '''
  224.  
  225.         return str(player.SteamId)
  226.  
  227.     # -------------------------------------------------------------------------
  228.     # - MESSAGE SYSTEM
  229.     def tell(self, player, text):
  230.         '''Function to send a message to a player '''
  231.  
  232.         ChatManager.Instance.AppendChatboxServerSingle(self.scs(text, self.Config['SETTINGS']['REMOVE CHAT COLORS']), player.Player)
  233.  
  234.     # -------------------------------------------------------------------------
  235.     def scs(self, text, con=False):
  236.         '''
  237.            Replaces color names and RGB hex code into HTML code
  238.        '''
  239.  
  240.         colors = (
  241.             'red', 'blue', 'green', 'yellow', 'white', 'black', 'cyan',
  242.             'lightblue', 'lime', 'purple', 'darkblue', 'magenta', 'brown',
  243.             'orange', 'olive', 'gray', 'grey', 'silver', 'maroon'
  244.         )
  245.  
  246.         name = r'\<(\w+)\>'
  247.         hexcode = r'\<(#\w+)\>'
  248.         end = 'end'
  249.  
  250.         if con:
  251.             for x in (end, name, hexcode):
  252.                 for c in re.findall(x, text):
  253.                     if c.startswith('#') or c in colors or x == end:
  254.                         text = text.replace('<%s>' % c, '')
  255.         else:
  256.             text = text.replace('<%s>' % end, '</color>')
  257.             for f in (name, hexcode):
  258.                 for c in re.findall(f, text):
  259.                     if c.startswith('#') or c in colors:
  260.                         text = text.replace('<%s>' % c, '<color=%s>' % c)
  261.         return text

Replies to rules rss

Title Name Language When
Re: rules gd dcs 6 Years ago.
Re: rules Bekaz chaiscript 6 Years ago.
Re: rules Król 4cs 6 Years ago.
Re: rules Król css 6 Years ago.
captcha