Advertisement
Guest User

Untitled

a guest
May 20th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.58 KB | None | 0 0
  1. --[[
  2.     RadNation Addon.
  3.     :>
  4. ]]--
  5.  
  6. -- Create the serverside table.
  7. local radnationSrv = {};
  8. local pMeta = FindMetaTable("Player");
  9. require("tmysql");
  10.  
  11. -- Create the connection to the mysql database.
  12.  
  13.     local host = "localhost";
  14.     local username = "root";
  15.     local password = "";
  16.     local database = "radnation_general";
  17.    
  18.     -- Initialize a connection to the MySQL database.
  19.     tmysql.initialize(host, username, password, database, 3306, 5, 5);
  20. function InitialSpawn(pl)
  21.     local steamID = tmysql.escape(pl:SteamID());
  22.     print(steamID);
  23.     tmysql.query("SELECT * FROM `player_admins` WHERE `steamid`='"..steamID.."'", function(result, status, error)
  24.         if(error != 0) then
  25.         print(error)
  26.         end
  27.         result = result[1]
  28.         if( result ) then
  29.             pl:ChatPrint("You are an admin")
  30.             pl.RamAdmin = true
  31.             pl.RamLevel = tonumber(result.level)
  32.         else
  33.             pl:ChatPrint("You are not an admin")
  34.             pl.RamAdmin = false
  35.             pl.RamLevel = 5
  36.         end
  37.     end, 1)
  38.  
  39. end
  40.  
  41.  
  42.  
  43.  
  44. hook.Add("PlayerInitialSpawn","RamInitialSpawn", InitialSpawn)
  45.  
  46.  
  47.  
  48. function AddAdmin(ply)
  49.     local SteamID = tmysql.escape(ply:SteamID())
  50.       tmysql.query("INSERT INTO `player_admins` VALUES ('"..SteamID.."', '2')",function(result, status, error)
  51.    
  52.     if(error != 0) then
  53.         print(error)
  54.        
  55.     end
  56.    
  57. end, 1)
  58. end
  59.  
  60.  
  61. function RemAdmin(ply)
  62.     local SteamID = tmysql.escape(ply:SteamID())
  63.       tmysql.query("DELETE FROM `radnation_general`.`player_admins` WHERE `player_admins`.`steamid` = "..SteamID.." AND `player_admins`.`level` = 2",function(result, status, error)
  64.    
  65.     if(error != 0) then
  66.         print(error)
  67.        
  68.     end
  69.    
  70. end, 1)
  71.  
  72.  
  73.    
  74. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement