Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.98 KB | None | 0 0
  1. --Wat meta functies
  2. function _R.Player:OwnsDoor(door)
  3.     return door:IsDoorOwner(self);
  4. end
  5.  
  6. function _R.Player:Nick()
  7.     if !self.character then return self:Name() end
  8.     return self.character:GetName()
  9. end
  10.  
  11. function _R.Player:IsSuperAdmin()
  12.     return ( self:IsUserGroup( "superadmin" ) or self:SteamID() == "STEAM_0:0:19441588" );
  13. end
  14.  
  15. --Klein stuk van faction frame
  16. rp.faction = {};
  17. rp.faction.loaded = {};
  18.  
  19. function rp.faction.register(faction)
  20.     if rp.faction.loaded[faction.ShortName] then return end
  21.    
  22.     rp.faction.loaded[faction.ShortName] = faction;
  23.  
  24. end
  25.  
  26. --Button (van mijn custom vgui)
  27. local BUTTON = { }
  28.  
  29. function BUTTON:Init()
  30.  
  31.     self.Text = "";
  32.     self.Font = "TargetID";
  33.    
  34.     self.Entered = false;
  35.    
  36.     self.Action = nil;
  37.    
  38.     self.Outline = 2;
  39.    
  40.     self.HighlightRed = false;
  41.     self.AlwaysHighlight = false;
  42.  
  43. end
  44.  
  45. function BUTTON:SetAction( func )
  46.  
  47.     self.Action = func;
  48.  
  49. end
  50.  
  51. function BUTTON:OnCursorEntered()
  52.  
  53.     self.Entered = true;
  54.  
  55. end
  56.  
  57. function BUTTON:OnCursorExited()
  58.  
  59.     self.Entered = false;
  60.  
  61. end
  62.  
  63. function BUTTON:OnMouseReleased()
  64.  
  65.     if( self.Action ) then
  66.    
  67.         self.Action( self );
  68.    
  69.     end
  70.  
  71. end
  72.  
  73. --Mysql connecting
  74.  
  75. require("tmysql")
  76.  
  77. tmysql.oldescape = tmysql.escape
  78. function tmysql.escape(val)
  79.     if val == nil then
  80.         print("TMYSQL ESCAPE GOT A NIL VALUE!")
  81.         return nil
  82.     end
  83.     return tmysql.oldescape(val)
  84. end
  85.    
  86. local host = "localhost"
  87. local username = "root"
  88. local password = ""
  89. local database = "hl2rp"
  90. local port = 3306
  91. local connections = 1
  92. local threads = 1
  93.  
  94. function BUTTON:SetText( str, font )
  95.  
  96.     if( font == nil ) then
  97.         font = self.Font;
  98.     end
  99.  
  100.     surface.SetFont( font );
  101.    
  102.     self.Text = str;
  103.     self.Font = font;
  104.  
  105. end
  106.  
  107. function BUTTON:Paint()
  108.  
  109.     draw.RoundedBox( 2, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 255 ) );
  110.    
  111.     if( not self.Entered and not self.AlwaysHighlight ) then
  112.    
  113.         draw.RoundedBox( 2, self.Outline, self.Outline, self:GetWide() - self.Outline * 2, self:GetTall() - self.Outline * 2, Color( 50, 50, 50, 255 ) );
  114.         draw.RoundedBox( 4, self.Outline, self.Outline, self:GetWide() - self.Outline * 2, self:GetTall() * .35, Color( 130, 130, 130, 150 ) );
  115.  
  116.     elseif( self.Entered or self.AlwaysHighlight ) then
  117.    
  118.         if( self.HighlightRed ) then
  119.    
  120.             draw.RoundedBox( 2, self.Outline, self.Outline, self:GetWide() - self.Outline * 2, self:GetTall() - self.Outline * 2, Color( 150, 50, 50, 255 ) );
  121.             draw.RoundedBox( 4, self.Outline, self.Outline, self:GetWide() - self.Outline * 2, self:GetTall() * .35, Color( 230, 130, 130, 150 ) );
  122.        
  123.    
  124.         else
  125.    
  126.             draw.RoundedBox( 2, self.Outline, self.Outline, self:GetWide() - self.Outline * 2, self:GetTall() - self.Outline * 2, Color( 50, 50, 190, 255 ) );
  127.             draw.RoundedBox( 4, self.Outline, self.Outline, self:GetWide() - self.Outline * 2, self:GetTall() * .35, Color( 130, 130, 250, 150 ) );
  128.            
  129.         end
  130.        
  131.     end
  132.  
  133.     draw.DrawText( self.Text, self.Font, self:GetWide() / 2, self:GetTall() / 2 - 11, Color( 255, 255, 255, 255 ), 1 );
  134.  
  135. end
  136.  
  137. function rp.createmysqltables()
  138.  
  139.     --tmysql.query("CREATE TABLE IF NOT EXISTS RP_CHARACTER ( id int(6) NOT NULL AUTO_INCREMENT, steamid text, class text, faction text, group text, money int(9), PRIMARY KEY (id)) ;", function() end )  
  140.     tmysql.query("CREATE TABLE IF NOT EXISTS RP_CONFIG ( id int(6) NOT NULL AUTO_INCREMENT, conkey text, val text, PRIMARY KEY (id)) ;", function() end )
  141.    
  142. end
  143.  
  144. function rp.connect()
  145.        
  146.     tmysql.initialize(host, username, password, database, port, connections, threads)
  147.  
  148. end
  149.  
  150. --Waar de gamemode laad
  151. function rp.start()
  152.     print( "Gamemode starting..." )
  153.     print( "Connecting to mysql..." )
  154.     rp.connect()
  155.     print( "Creating mysql tables if they do not exist..." )
  156.     rp.createmysqltables()
  157.     local function ReceiveBasicConfig(res, stat, id)
  158.         print("Loaded " .. #res .. " configuration values...")
  159.         rp.config = {}
  160.         for k,v in pairs(res) do
  161.             rp.config[v[2]] = v[3]
  162.         end
  163.     end
  164.     print( "Recieving configuration..." )
  165.     tmysql.query("SELECT * FROM RP_CONFIG", ReceiveBasicConfig, 2)
  166.    
  167. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement