Jump to content
Soul

[TUTORIAL] Usage of CHILD 104: AdminLevel from database

Recommended Posts

This hive call whas writen to work the exact same way as how it retrieves entries from the object_data table.

CHILD 104 expects 1 parameter to be supplied when calling the HiveExt.

The needed parameter is your dayzInstance number

- PlayerUID returns as a string to support the full length of the steamID.
- AdminLevel returns as a integer.

This new functionality that i added in the custom epoch hive can be use to restrict access to anything you want.

Infact it could be used for far more then admin access if you think of it.

 

Practical usage 1: infiSTAR admin access from the database

Create a new file named: getDBAdmins.sqf
Place this file in the init folder found in your dayz_server.pbo
And put this code in it.

adminUIDs = [];
_SAdmins = [];
_HAdmins = [];
_LAdmins = [];

_key = format["CHILD:104:%1:",dayZ_instance];
_data = "HiveEXT" callExtension _key;
    diag_log format["_data: %1",_data];
_result = call compile format ["%1",_data];
    diag_log format["_result: %1",_result];
diag_log "HIVE: Request sent";
    
//Process result
_status = _result select 0;
    diag_log format["_status: %1",_status];
_myArray = [];
if (_status == "ObjectStreamStart") then {
    _val = _result select 1;
    diag_log format["%1",_val];
    //Stream Objects
    for "_i" from 1 to _val do {
        _data = "HiveEXT" callExtension _key;
        diag_log format["_data: %1",_data];
        _result = call compile format ["%1",_data];
    diag_log format["_result: %1",_result];
        _myArray set [count _myArray,_result];
    diag_log format["_myArray: %1",_myArray];
    };
    
};

{
    _playerId = _x select 0;
    diag_log format["_playerId: %1",_playerId];
    _playerIdType = typeName _playerId;
    diag_log format["TypeName _playerId: %1",_playerIdType];
    _adminLevel = _x select 1;
    diag_log format["_adminLevel: %1",_adminLevel];
    
    switch (_adminLevel) do {
            case 1: { _SAdmins = _SAdmins + [_playerId]; adminUIDs = adminUIDs + [_playerId];diag_log "Added to SA+EXT";};     //Super Admin Level + Special custom abilities
            case 2: { _SAdmins = _SAdmins + [_playerId]; diag_log "Added to SA";};        //Super Admin Level
            case 3: { _HAdmins = _HAdmins + [_playerId]; diag_log "Added to HA";};        //High Admin Level
            case 4: { _LAdmins = _LAdmins + [_playerId]; diag_log "Added to LA";};        //Low Admin Level
        };
    
} forEach _myArray;

Find and comment our like below:

/* 
if ((preProcessFileLineNumbers ("admins3_dayzpvp.sqf")) != "") then {
    _tmpLA = call compile preProcessFileLineNumbers "admins3_dayzpvp.sqf";
    _LAdmins = _LAdmins + _tmpLA;
};
if ((preProcessFileLineNumbers ("admins2_dayzpvp.sqf")) != "") then {
    _tmpNA = call compile preProcessFileLineNumbers "admins2_dayzpvp.sqf";
    _NAdmins = _NAdmins + _tmpNA;
};
if ((preProcessFileLineNumbers ("admins_dayzpvp.sqf")) != "") then {
    _tmpSA = call compile preProcessFileLineNumbers "admins_dayzpvp.sqf";
    _SAdmins = _SAdmins + _tmpSA;
}; 
*/
if ((preProcessFileLineNumbers ("blacklist.sqf")) != "") then {
    _tmpBL = call compile preProcessFileLineNumbers "blacklist.sqf";
    _BLOCKED = _BLOCKED + _tmpBL;
};

Then after the blacklisting part add this:

#include "\z\addons\dayz_server\init\getDBAdmins.sqf";

Then run this query on your database to create the newly needed table.

DROP TABLE IF EXISTS `admin_data`;
CREATE TABLE `admin_data` (
  `PlayerUID` varchar(20) NOT NULL DEFAULT '0',
  `PlayerName` varchar(128) NOT NULL DEFAULT 'Null',
  `AdminLevel` int(1) NOT NULL DEFAULT '0',
  `Instance` int(11) NOT NULL DEFAULT '11',
  PRIMARY KEY (`PlayerUID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Your all done and ready to start adding your admins steamID and admin level to your database.
No more sitting around and waiting for a restart to make changes and then miss the damn restart right [ ;)]
No more need to do manual restarts to add a admin.
All it takes for the new admin to have his rights is a server restart automated or manual.

Admin levels explained:
In the switch statement you see case 1, case 2, case 3, case 4 right

Case 1:

Super admin acces just like in infistar ah but this adds the playerid to a custom variable, i use this to give certain super admins base dome access or special markers on their maps and whatnot.
take not that the "adminUIDs" variable needs to be publicVariabled after the script is done, the reason this is not the case in the example is because i use publicVariableClient in the playerlogin.sqf file
it's just my way of making shure that jip clients have the variable to.

Case 2:

Super admin access

Case 3:

High admin access

Case 4:

Low admin access

So obviously in the database you fill in 1, 2, 3 or 4 in the "AdminLevel" field

Share this post


Link to post
Share on other sites

Hey dude, nice tool but could i clear something?

Does this mod require a server restart ?

I didnt think so as this makes infistar look at the DB for admins.

If not why do i still need to restart the server to make the change take effect ?

 

Cheer

George

Share this post


Link to post
Share on other sites
Guest

because the admin list is only generated once at restart, you could insert a command to your antihack sending a publicvariableserver and adding a serverside eventhandler to execute the getdbadmins.sqf during the game manually if you need to update the array without restart ....

Share this post


Link to post
Share on other sites

because the admin list is only generated once at restart, you could insert a command to your antihack sending a publicvariableserver and adding a serverside eventhandler to execute the getdbadmins.sqf during the game manually if you need to update the array without restart ....

 

It was made to generate once, cause hackers can now easily enter by forcing their way into the anti-hack. But with the one time gen, makes it hard cause the script will know if it changes mid-way.

 

Personally its not the best idea to edit the anti-hack. As infistar made it so that its secure. For all we know this could create a major backdoor. Not saying this is a bad idea or a script. But it just needs to be double checked is what i mean.

Share this post


Link to post
Share on other sites

dude all it does is pull the data from the database instead of the sqf files nothing more nothing less.

I know what you mean, but if you were to inject it like said in the 3 post. then it will give a better way for someone to inject their way in. But i understand you basicly changed it from a sqf to a database call.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Advertisement
  • Supporters
  • Discord

×
×
  • Create New...