ULX/ULIB SQL Admins & Donator Plugin

in #utopian-io8 years ago (edited)

What is this plugin?

This is a simple but very powerfull Garry's Mod Plugin for gmod servers to grant admin access to users upon connection. The system is capable of setting various permissions for each user based on stored data in a database.
This plugin can be used to grant access to certain ingame features upon donation or set admin access for users easily using an sql database.

Why?

There is no simple plugin or easy to set up plugin that allows you to store your users, moderators, donators admins in database for ulib & ulx. The important feature is the abilitity to specify expiration time for users. This way it is easy to restrict the users to access the site. Plugins are all paid & not available. This plugin aims at simplicity and delivers just what server owners need.

Requirments

Installation

Upload the sqladmins folder to your garrysmod/addons/ folder.

The plugin should create a users table after properly set up. If this did not happen please run the following query or set up similar table strucutre in your database.

CREATE TABLE IF NOT EXISTS `users` (
  `id` int(128) NOT NULL AUTO_INCREMENT,
  `steamid` varchar(200) NOT NULL,
  `access_group` varchar(200) NOT NULL,
  `date` DATETIME DEFAULT NULL,
  `forever` int(1) DEFAULT 0,
  PRIMARY KEY (`id`, `steamid`)
) DEFAULT CHARSET=utf8;

Edit the sqladmins/lua/sql_config.lua file to match your db secrets:

SqlHostname = "database hostname";
SqlUsername = "database username";
SqlPassword = "database password";
SqlDatabase = "database name";
SqlTable = "table where you wish to store your users"
SqlPort = 3306;

Fields are constant, to change their names update the code accordingly!

  • Restart server
  • Profit...

HOW IT WORKS?

The plugin queries the access_group from the database and executes the following command on the PlayerInitialSpawn event.

ULib.ucl.addUser( ply:SteamID(), nil, nil, access_group );

Group's must be specified in the ULIB/ULX config!

API DOCS

Add user with root access to the database with the following SQL Query:

INSERT INTO `users` (`access_group`, `steamid`, `date`, `forever`)  VALUES ('root', '76561198121397642', (NOW() + INTERVAL 1 WEEK), 0);

The query above inserts a new user with root access for 1 week period expiration.
Another example:

INSERT INTO `users` (`access_group`, `steamid`, `date`, `forever`)  VALUES ('vip', '76561198121397642', NOW(), 1);

This query inserts a new user with vip access that never expires! (forever set to 1)

  • forever (0 or 1) wether the user should obtain their access level forever?
  • date a DATETIME() expiration time specified for the access level. Ignored if forever is true
  • steamid 64bit steamid of the user (This is represented as a string)

Example query to get all users who has access to certain privileges

SELECT * from `users` WHERE date>=(NOW()) OR forever=1;

Have a question?

Please open an issue.

License

MIT



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Hey @azarus I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Coin Marketplace

STEEM 0.04
TRX 0.32
JST 0.084
BTC 60995.11
ETH 1571.77
USDT 1.00
SBD 0.47