[FilterScript] TAdmin - A MySQL administration system
#1

TAdmin

A MySQL administration system because we don’t have enough of those!



This is my first ever release so go easy on me D: Hopefully the system is gonna be useful to some people because I spent a lot of time working on it and I’m super proud of the final product.

If you have suggestions, improvements, found bugs or just need some help, please make an issue, PM me on forum or post in the SA:MP forum topic.

The system current features:
  • A basic login and registration system.
  • +25 admin commands.
  • Advanced player and world management commands. (/set, /give, /all)
  • Simple ban system that stores the bans in a MySQL table.
  • Admin logging saved in MySQL table.
  • Easy configuration.
  • Basic spectating system.
  • RCON login attempts logging, query errors logging and more.
  • Advanced report system.
  • Discord intergration.
Requirements
Installation

1. Clone this repository locally and download the required plugins/includes.
2. Put the tadmin_tools.inc file in the pawno/include folder.
3. Open the pwn file and edit the following lines with your details:

pawn Code:
#define SYSTEMNAME “TAdmin” // Feel free to change it to “Admin System”, “Admin” etc etc.


#define ADMIN_MAX_LEVELS    4

#define COLOR_ADMINMSG           0xCC0000FF // Color used in the ‘Admin Message:’ messages.
#define ADMIN_LEVEL_1_COLOR   0xFF9900AA
#define ADMIN_LEVEL_2_COLOR   0x33AA33AA
#define ADMIN_LEVEL_3_COLOR   0x006699AA
#define ADMIN_LEVEL_4_COLOR   0xFF0000FF

#define ADMIN_LEVEL_1_NAME  “Trial Admin”
#define ADMIN_LEVEL_2_NAME  “Admin”
#define ADMIN_LEVEL_3_NAME  “Lead Admin”
#define ADMIN_LEVEL_4_NAME  “Management”

new bool:TAdmin_Debug = false;
new bool:SendQueryErrorsToAdmins = true;
new bool:AdminMapTeleport = true;
new bool:RCONFailedNotification = true;
new bool:UseDiscord = true;

/* TAdmin_Debug: Setting this to true will show debug messages in the server log, useful for debugging issues with TAdmin.
SendQueryErrorsToAdmins: Setting this to true will send Query errors to in-game admins. Query errors are always shown in the console regardless of this setting.
AdminMapTeleport: Setting this to true will allow admins to teleport by clicking on the map.
RCONFailedNotification: Setting this to true will send failed rcon login messages to all online admins. Failed login attempts are saved to Logs/FailedRCONLogins.txt regardless of this setting.
UseDiscord:  Setting this to true will enable all Discord related features. Discord settings can be found below. */


#define MAX_MUTE_TIME       120 // The max amount of time an admin can mute a player (in minutes)
#define MAX_JAIL_TIME       60 //The max amount of time an admin can jail a player (in minutes)

#define MYSQL_HOSTNAME      “localhost”
#define MYSQL_USERNAME      “root”
#define MYSQL_PASSWORD      “”
#define MYSQL_DATABASE      “main”

// – Discord Settings
#define ChannelAdminLogs “”
#define ChannelAdminChat “”
// Both AdminLogs and AdminChat require a Discord channel ID. Info here: [URL="http://toni.pw/l/discorddevmode"]http://toni.pw/l/discorddevmode[/URL]
4. Inside the Scriptfiles folder, create another folder titled Logs.

5. Open PHPMyAdmin localhost/phpmyadmin and create a new database corresponding to the value MYSQL_DATABASE in tadmin.pwn file.

6. Once you have created the database, import the main.sql file and you should have 4 tables titled accounts, adminlogs, reports and bans.

7. Finally, compile the filterscript, include it in server.cfg file filterscripts tadmin and run the server.

FAQ

Quote:
Q: How do I check if the player is an admin?

A: if(PlayerInfo[playerid][pAdmin] < 1) return 0; This is gonna check if the player's admin level is less than 1 and if it is, it returns 0, else it executes the command.

Quote:
Q: How do I add another admin level?

A: This is a bit more complicated so bear with me:

1. Firstly, increase the ADMIN_MAX_LEVELS value to whatever you want (I'll use 5 in this case).

2. Add the level's name and color:
#define ADMIN_LEVEL_5_COLOR 0xFF00FFFF` `#define ADMIN_LEVEL_5_NAME "Owner"

3. Edit GetAdminRank:
pawn Code:
GetAdminRank(playerid)
{
    new arank[64];
    switch(PlayerInfo[playerid][pAdmin])
    {
        case 5: arank = ADMIN_LEVEL_5_NAME;
        case 4: arank = ADMIN_LEVEL_4_NAME;
        case 3: arank = ADMIN_LEVEL_3_NAME;
        case 2: arank = ADMIN_LEVEL_2_NAME;
        case 1: arank = ADMIN_LEVEL_1_NAME;
        default: arank = "Unknown";
    }
    return arank;
}
4. Then, you can add the new admin level to /ahelp.
pawn Code:
SendClientMessage(playerid, ADMIN_LEVEL_5_COLOR, "Level 5 - {FFFFFF}Commands go here");
5. Finally, modify the /admins command so it can show level 5 admins as well:
pawn Code:
case 5: format(string, sizeof(string), "%s (%d) - Level %d (%s)", GetName(i), i, PlayerInfo[i][pAdmin], ADMIN_LEVEL_5_NAME);
Quote:

Q: I don’t care about the Discord stuff, can I remove them?

A: You can however you will have to spend some time removing them. I might release a seperate version without the Discord stuffs but for now, simply remove anything that says Discord.

Credits
  • SA:MP team
  • Y_Less - SSCANF2 and Whirlpool
  • Zeex - ZCMD
  • BlueG - MySQL
  • Emmet_ - easyDialog
  • Southclaws - Chrono
  • willbedie - Registration and Login system Link as well as his ban system Link
  • maddinat0r - Discord Connector
  • Luka.P - PlayerZone include
  • Twixxx - Player_Geolocation include
Reply
#2

well done. +REP
Reply
#3

excellent explanatory and detailing.Thank you for releasing such an unique source easy manageable
Reply
#4

The script is good but needs a lot of tweaks.

You're using latest MySQL plugin but not foreach, the classic for(new i = 0; i < MAX_PLAYERS; i ++).

In the account check on OnPlayerConnect you don't need LIMIT 1.

pawn Code:
mysql_format(db, query, sizeof(query), "SELECT `pPass`, `pID` FROM `accounts` WHERE `pUsername` = '%e'", GetName(playerid));
Is enough.

Also why a loop to send a connect message? Just use SendClientMessageToAll! No need to loop everytime someone connects.

This:

pawn Code:
public OnPlayerConnect(playerid)
{
    new query[140], string[50];

    mysql_format(db, query, sizeof(query), "SELECT `pPass`, `pID` FROM `accounts` WHERE `pUsername` = '%e' LIMIT 0, 1", GetName(playerid));
    mysql_tquery(db, query, "CheckPlayer", "i", playerid);
   
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if (!IsPlayerConnected(i)) continue;
        if (PlayerInfo[i][pAdmin] != 0) {
            format(string, sizeof(string), "* %s (%d) has connected. Country: %s", GetName(playerid), playerid, GetPlayerCountry(playerid));
        }
        else
        {
            format(string, sizeof(string), "* %s (%d) has connected.", GetName(playerid), playerid);
        }
        SendClientMessage(i, COLOR_GRAY, string);
    }
    if(TAdmin_Debug == true)
    {
        printf("[%s - Debug]: Player %s (%d) from %s, %s with IP %s connected. - OnPlayerConnect", SYSTEMNAME, GetName(playerid), playerid, GetPlayerCity(playerid), GetPlayerCountry(playerid), returnIP(playerid));
    }
    ResetPlayerVariables(playerid);
    TogglePlayerClock(playerid, 1);
    return 1;
}
Can be reduced to:

pawn Code:
public OnPlayerConnect(playerid)
{
    new query[140], string[100];

    mysql_format(db, query, sizeof(query), "SELECT `pPass`, `pID` FROM `accounts` WHERE `pUsername` = '%e'", GetName(playerid));
    mysql_tquery(db, query, "CheckPlayer", "i", playerid);
   
    format(string, sizeof(string), "* %s (%d) has connected. Country: %s", GetName(playerid), playerid, GetPlayerCountry(playerid));
    SendAdminMessage(COLOR_ADMINMSG, string);
   
    format(string, sizeof(string), "* %s (%d) has connected.", GetName(playerid), playerid);
    SendClientMessageToAll(COLOR_GRAY, string);
   
    if(TAdmin_Debug == true) printf("[%s - Debug]: Player %s (%d) from %s, %s with IP %s connected. - OnPlayerConnect", SYSTEMNAME, GetName(playerid), playerid, GetPlayerCity(playerid), GetPlayerCountry(playerid), returnIP(playerid));
   
    ResetPlayerVariables(playerid); TogglePlayerClock(playerid, 1);
    return 1;
}
For timers, use y_timers instead of default SetTimer.

/ahelp can be reduced up to 30% of lines too.

Also you're using Whirlpool without salting the passwords. Use SALT and SHA-256 to encrypt them. Better for you and better for the security of who'll use this system

Basically, this is a good system, but as said already, needs a lot of tweaks.

Good job tho.
Reply
#5

Quote:
Originally Posted by KinderClans
View Post
You're using latest MySQL plugin but not foreach, the classic for(new i = 0; i < MAX_PLAYERS; i ++).
Originally, I wanted to use as little includes/plugins as possible so it's easier for anyone to just add it so I decided to go with classic loops and not foreach. But in the end, I still ended up with a lot of includes and plugins so I'll probably just add foreach in a future update. Same with y_timers.

Quote:
Originally Posted by KinderClans
View Post
mysql_format(db, query, sizeof(query), "SELECT `pPass`, `pID` FROM `accounts` WHERE `pUsername` = '%e'", GetName(playerid));
Thanks! Will fix this in a future update.

Quote:
Originally Posted by KinderClans
View Post
pawn Code:
format(string, sizeof(string), "* %s (%d) has connected. Country: %s", GetName(playerid), playerid, GetPlayerCountry(playerid));
    SendAdminMessage(COLOR_ADMINMSG, string);
   
    format(string, sizeof(string), "* %s (%d) has connected.", GetName(playerid), playerid);
    SendClientMessageToAll(COLOR_GRAY, string);
That would send 2 messages to admins, no? That's why it's looping through the players. To find which one is an admin and which one is not so it sends the correct message.

Also yeah, not really happy with the current /ahelp layout (Spent a long time deciding it) so I'll work on improving it.

Quote:
Originally Posted by KinderClans
View Post
Also you're using Whirlpool without salting the passwords. Use SALT and SHA-256 to encrypt them. Better for you and better for the security of who'll use this system
Will add that as well, didn't spend enough time on the login/reg system.

Thanks for the criticism!
Reply
#6

1.0.1 - Small fixes
  • Added a basic /report command. I have future plans for it but for now it's just a simple command that sends a message to admins, saves to a file and sends a message to Discord.
  • /acmds has a new layout.
  • Couple of code changes in OnPlayerConnect.
https://github.com/ToniTurnerr/TAdmi...ases/tag/1.0.1
Reply
#7

Any script that loads permissions or sensitive information needs to check against race condition. You do not want regular players to suddenly become administrators if the query takes long enough.

Quote:
Originally Posted by KinderClans
View Post
In the account check on OnPlayerConnect you don't need LIMIT 1.

pawn Code:
mysql_format(db, query, sizeof(query), "SELECT `pPass`, `pID` FROM `accounts` WHERE `pUsername` = '%e'", GetName(playerid));
Is enough.
His initial query would stop searching if one record is found, however now it will continue searching as it expects there might be multiple rows.

If you remove it, set `pUsername` as UNIQUE column (it now knows there are no duplicates and expects ONLY one row).
Reply
#8

1.1 - Update
  • Added /checkplayer. Shows information about the player, their IP (if the admin checking is 2+) and if they're in a vehicle, it shows the vehicle information.
  • Added /changepass for players to change their password and /achangepass for level 4 admins to change passwords.
  • Also added a small /help command with player commands..
Admin jail will come in the next update

https://github.com/ToniTurnerr/TAdmin/releases/tag/1.1
Reply
#9

Is this admin system bug free? Did you test all features or any server uses this system? If its bug free I might use it in my server.
Reply
#10

Good job, I would like to see how the admin tool system looks, is it something similiar to mine?
Reply
#11

Quote:
Originally Posted by SonnyGamer
View Post
Is this admin system bug free? Did you test all features or any server uses this system? If its bug free I might use it in my server.
It should be! I did test it pretty well while developing it but its possible a bug or two slipped. If you do end up finding bugs, report them to me and I'll fix them.

Quote:
Originally Posted by willbedie
View Post
Good job, I would like to see how the admin tool system looks, is it something similiar to mine?
I took a lot of inspiration from different admin systems I found, so it's possible!
Reply
#12

look cool bro
Reply
#13

1.1.1 - Updates
  • Added admin jail system. Commands: /ajail, /aunjail and /ajailinfo (same as /muteinfo - shows info about a jailed player.)
  • Changes to the mute system code. Mute info is now stored in an enum.
  • Added /muteinfo to view information about a muted player. (reason, muted by who and time remaining)
  • Added muted/jail checks to certain admin commands.
https://github.com/ToniTurnerr/TAdmi...ases/tag/1.1.1

Open to suggestions on what to add next. Reply here, PM me or submit an issue on github!
Reply
#14

1.1.2 - Report System
  • Reports are now stored in the reports table on the database.
  • Admins can view all pending reports (/reports), accept a report (/ar), deny a report (/dr) and delete all pending reports (/delreports)
  • Players are notified when their report is accepted/denied.
https://github.com/ToniTurnerr/TAdmi...ases/tag/1.1.2

This is probably the last update for sometime as I think the system is pretty much completed. Suggestions, bugs and improvements are always appreciated.
Reply
#15

Why are you just copy-pasting every system of mine lmfao, you'll have to ask for permission to do that. I released it so people can use on their servers, not to re-release it with a little change of code here and there. Shame.
Reply
#16

Quote:
Originally Posted by willbedie
View Post
Why are you just copy-pasting every system of mine lmfao, you'll have to ask for permission to do that. I released it so people can use on their servers, not to re-release it with a little change of code here and there. Shame.
Literally no idea what you're talking about lol. I just checked your system and sure it has /dr and /ar (like pretty much all report systems) but the code is not even the same? If I did use your report system, I would have given you credit for it (just like I did with the ban system and the login/reg).
Reply
#17

Quote:
Originally Posted by M8
View Post
Literally no idea what you're talking about lol. I just checked your system and sure it has /dr and /ar (like pretty much all report systems) but the code is not even the same? If I did use your report system, I would have given you credit for it (just like I did with the ban system and the login/reg).
Yeah not talking about ban / register system, but the report code is very similiar to mine
Reply
#18

plugins streamer sscanf mysql discord-connector Whirlpool

did I forget any plugins to include because I doesnt wanna start up.
Reply
#19

When I go in game and type any commands from this filterscript it says that the cmd is unknown. What could be the problem?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)