Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Wat meta functies
- function _R.Player:OwnsDoor(door)
- return door:IsDoorOwner(self);
- end
- function _R.Player:Nick()
- if !self.character then return self:Name() end
- return self.character:GetName()
- end
- function _R.Player:IsSuperAdmin()
- return ( self:IsUserGroup( "superadmin" ) or self:SteamID() == "STEAM_0:0:19441588" );
- end
- --Klein stuk van faction frame
- rp.faction = {};
- rp.faction.loaded = {};
- function rp.faction.register(faction)
- if rp.faction.loaded[faction.ShortName] then return end
- rp.faction.loaded[faction.ShortName] = faction;
- end
- --Button (van mijn custom vgui)
- local BUTTON = { }
- function BUTTON:Init()
- self.Text = "";
- self.Font = "TargetID";
- self.Entered = false;
- self.Action = nil;
- self.Outline = 2;
- self.HighlightRed = false;
- self.AlwaysHighlight = false;
- end
- function BUTTON:SetAction( func )
- self.Action = func;
- end
- function BUTTON:OnCursorEntered()
- self.Entered = true;
- end
- function BUTTON:OnCursorExited()
- self.Entered = false;
- end
- function BUTTON:OnMouseReleased()
- if( self.Action ) then
- self.Action( self );
- end
- end
- --Mysql connecting
- require("tmysql")
- tmysql.oldescape = tmysql.escape
- function tmysql.escape(val)
- if val == nil then
- print("TMYSQL ESCAPE GOT A NIL VALUE!")
- return nil
- end
- return tmysql.oldescape(val)
- end
- local host = "localhost"
- local username = "root"
- local password = ""
- local database = "hl2rp"
- local port = 3306
- local connections = 1
- local threads = 1
- function BUTTON:SetText( str, font )
- if( font == nil ) then
- font = self.Font;
- end
- surface.SetFont( font );
- self.Text = str;
- self.Font = font;
- end
- function BUTTON:Paint()
- draw.RoundedBox( 2, 0, 0, self:GetWide(), self:GetTall(), Color( 0, 0, 0, 255 ) );
- if( not self.Entered and not self.AlwaysHighlight ) then
- draw.RoundedBox( 2, self.Outline, self.Outline, self:GetWide() - self.Outline * 2, self:GetTall() - self.Outline * 2, Color( 50, 50, 50, 255 ) );
- draw.RoundedBox( 4, self.Outline, self.Outline, self:GetWide() - self.Outline * 2, self:GetTall() * .35, Color( 130, 130, 130, 150 ) );
- elseif( self.Entered or self.AlwaysHighlight ) then
- if( self.HighlightRed ) then
- draw.RoundedBox( 2, self.Outline, self.Outline, self:GetWide() - self.Outline * 2, self:GetTall() - self.Outline * 2, Color( 150, 50, 50, 255 ) );
- draw.RoundedBox( 4, self.Outline, self.Outline, self:GetWide() - self.Outline * 2, self:GetTall() * .35, Color( 230, 130, 130, 150 ) );
- else
- draw.RoundedBox( 2, self.Outline, self.Outline, self:GetWide() - self.Outline * 2, self:GetTall() - self.Outline * 2, Color( 50, 50, 190, 255 ) );
- draw.RoundedBox( 4, self.Outline, self.Outline, self:GetWide() - self.Outline * 2, self:GetTall() * .35, Color( 130, 130, 250, 150 ) );
- end
- end
- draw.DrawText( self.Text, self.Font, self:GetWide() / 2, self:GetTall() / 2 - 11, Color( 255, 255, 255, 255 ), 1 );
- end
- function rp.createmysqltables()
- --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 )
- 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 )
- end
- function rp.connect()
- tmysql.initialize(host, username, password, database, port, connections, threads)
- end
- --Waar de gamemode laad
- function rp.start()
- print( "Gamemode starting..." )
- print( "Connecting to mysql..." )
- rp.connect()
- print( "Creating mysql tables if they do not exist..." )
- rp.createmysqltables()
- local function ReceiveBasicConfig(res, stat, id)
- print("Loaded " .. #res .. " configuration values...")
- rp.config = {}
- for k,v in pairs(res) do
- rp.config[v[2]] = v[3]
- end
- end
- print( "Recieving configuration..." )
- tmysql.query("SELECT * FROM RP_CONFIG", ReceiveBasicConfig, 2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement