Jump to content
mrwolv

Admin For Dayz Standalone (Works)

Recommended Posts

RESOLVED

@5andysalive, THANKS FOR YOUR HELP

================================================

I'm probably missing something obvious, i'm a bit of a noob,  but this is the compile error i'm getting:

"Can't compile mission init script'!

$CurrentDir:mpmissions\dayzOffline.chernarusplus\init.c(83): Broken expression (missing ';'?)"

 

here is the code from line 83 ( I added line numbers for reference) :

77  Mission CreateCustomMission(string path)
78 {
79  bool verify_admins = false; // true=verify presence of BI UID in admin list
80    string cmd_prefix = "/"; // Must be special character
81    ref TStringArray admins = {ID Removed}; // Add your BI UID or SteamID

83    bool IsPlayerAnAdmin(PlayerBase player) {
84       bool found = false;
        for ( int i = 0; i < admins.Count(); ++i ) {
            if(player.GetIdentity().GetId() == admins || player.GetIdentity().GetPlainId() == admins) { found=true; break; }
        }
        return found;
    }

 

Thanks in advance!

Edited by Ranger Tango

Share this post


Link to post
Share on other sites

Does anyone have a copy of the init.c? 

I tried to put the admin script, but later hack when I click to connect to the server.

Coz it seems like, the github version not useable anymore

Can anyone share it here?

Edited by Icye_OV

Share this post


Link to post
Share on other sites

void main()
{

    Hive ce = CreateHive();
    if ( ce )
        ce.InitOffline();

    Weather weather = g_Game.GetWeather();

    weather.GetOvercast().SetLimits( 0.1 , 0.7 );
    weather.GetRain().SetLimits( 0.0 , 0.2 );

....................  Rest of the weather stuff

}

 

class CustomMission: MissionServer
{
bool verify_admins = false; // true=verify presence of BI UID in admin list
    string cmd_prefix = "/"; // Must be special character
    ref TStringArray admins = {"xxxxxxxxxx"}; // Add your STEAM64 ID
 
    bool IsPlayerAnAdmin(PlayerBase player) {
        bool found = false;
        for ( int i = 0; i < admins.Count(); ++i ) {
            if(player.GetIdentity().GetId() == admins) { found=true; break; }
        }
        return found;
    }
 
    void SendMessageToPlayer(PlayerBase player, string message) {
        Param1<string> param = new Param1<string>( message );
        GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, param, true, player.GetIdentity());
    }
 
    bool IsPlayer(string name) {
        PlayerBase p;
        array<Man> players = new array<Man>; GetGame().GetPlayers(players);
        for ( int i = 0; i < players.Count(); ++i ) {
            p = players.Get(i);
            if(p.GetIdentity().GetName() == name) return true;
        }
        return false;
    }
 
    PlayerBase GetPlayer(string name) {
        PlayerBase p;
        array<Man> players = new array<Man>; GetGame().GetPlayers(players);
        for ( int i = 0; i < players.Count(); ++i ) {
            p = players.Get(i);
            if(p.GetIdentity().GetName() == name) return p;
        }
        return NULL;
    }
 
    override void OnEvent(EventType eventTypeId, Param params)  
   
    {
        super.OnEvent(eventTypeId,params);
        int i;
        PlayerBase player, temp_player;
        array<Man> players = new array<Man>; GetGame().GetPlayers(players);
        if(eventTypeId != ChatMessageEventTypeID) return; // Is chat message
        ChatMessageEventParams chat_params = ChatMessageEventParams.Cast( params );
        if(chat_params.param1 != 0 || chat_params.param2 == "") return;
        player = GetPlayer(chat_params.param2);
        if(player == NULL) return;
        if(verify_admins && !IsPlayerAnAdmin(player)) { GetGame().AdminLog("[ADMCMD] (Unauthorized) " + player.GetIdentity().GetName() +" ("+player.GetIdentity().GetPlainId()+", "+player.GetIdentity().GetId()+") tried to execute "+ chat_params.param3); return; }
        string message = chat_params.param3, prefix, param0, command;
        TStringArray tokens = new TStringArray;
        message.Split(" ", tokens); int count = tokens.Count();
        param0 = tokens.Get(0);
        param0.ParseStringEx(prefix); if(prefix != cmd_prefix) return;
        param0.ParseStringEx(command);
        GetGame().AdminLog("[ADMCMD] PLAYER: "+ player.GetIdentity().GetName() +" ("+player.GetIdentity().GetPlainId()+", "+player.GetIdentity().GetId()+") CMD: "+ command);
        switch(command) {
            case "spawn": {
                if(count != 2) { SendMessageToPlayer(player, "/spawn [object]"); return; }
                GetGame().CreateObject(tokens[1], player.GetPosition(), false, true );
                SendMessageToPlayer(player, "[ObjectSpawn] Object spawned: " + tokens[1]);
                break;
            }

 

..................................  All the other cases  make sure every case opens closes all brackets.

then the last case and the end:

 

case "refuel": {
                ref array<Object> nearest_objects = new array<Object>;
                ref array<CargoBase> proxy_cargos = new array<CargoBase>;
                Car toBeFilled;
                vector position = player.GetPosition();
                GetGame().GetObjectsAtPosition ( position, 10, nearest_objects, proxy_cargos );
        
                for (i = 0; i < nearest_objects.Count(); i++) {
                    if (nearest_objects.IsKindOf("CarScript")) {
                        SendMessageToPlayer(player, "[Refuel] Found car: '"+nearest_objects+"'");
                        toBeFilled = Car.Cast(nearest_objects);
                        float fuelReq = toBeFilled.GetFluidCapacity( CarFluid.FUEL ) - (toBeFilled.GetFluidCapacity( CarFluid.FUEL ) * toBeFilled.GetFluidFraction( CarFluid.FUEL ));
                        float oilReq = toBeFilled.GetFluidCapacity( CarFluid.OIL ) - (toBeFilled.GetFluidCapacity( CarFluid.OIL ) * toBeFilled.GetFluidFraction( CarFluid.OIL ));
                        float coolantReq = toBeFilled.GetFluidCapacity( CarFluid.COOLANT ) - (toBeFilled.GetFluidCapacity( CarFluid.COOLANT ) * toBeFilled.GetFluidFraction( CarFluid.COOLANT ));
                        float brakeReq = toBeFilled.GetFluidCapacity( CarFluid.BRAKE ) - (toBeFilled.GetFluidCapacity( CarFluid.BRAKE ) * toBeFilled.GetFluidFraction( CarFluid.BRAKE ));
                        toBeFilled.Fill( CarFluid.FUEL, fuelReq );
                        toBeFilled.Fill( CarFluid.OIL, oilReq );
                        toBeFilled.Fill( CarFluid.COOLANT, coolantReq );
                        toBeFilled.Fill( CarFluid.BRAKE, brakeReq );
                        SendMessageToPlayer(player, "[Refuel] "+fuelReq+"L added, all fluids maxed");
                    }
                }
                
                break;
            }
           
            default: {
                SendMessageToPlayer(player, "Unknown command: " + command);
                break;
            }
        }
    }      

.........................................then is the  normal rest. the override playerbase, character creation and loadout.

 override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
    {
.........................

Edited by 5andysalive
  • Thanks 1

Share this post


Link to post
Share on other sites

Does anyone have the latest command?

Seems like some of the commands won't work. eg. /here, /goto, /allgoto, /topos

How to make players in my server, don't see my commands?

Edited by Icye_OV

Share this post


Link to post
Share on other sites
On 27/11/2018 at 3:10 AM, 5andysalive said:

well i copied the thing as it is above and it doesnt.  I added some cases but the beginning is the same.

dont know why it does that for you.

it dose it for all people i have had 10 people try on there servers with  this admin scrip and it all shows globaly for them so unless your using some modded mission file that explains why you dont see it :D

Share this post


Link to post
Share on other sites

One way would be to check only for admin guid in file, not for login. If you dont have to login, youre not in global chat. So it would only show in your direct vicinity.  Also several admins could be using it same time.

I'm not competent enough to change the script in that..

I tried searching scripts.pbo to disable admin login auto joining global chat (pretty annoying anyway) but nothing worked. You coud send serverwide by rcon anyway.

Second idea, probably impossible, commands with # instead of /. The game hides those automatically.

Edited by 5andysalive

Share this post


Link to post
Share on other sites

dayz only lets 1 person login to admin at any time and no other admins can login untill the prev admin logs out so im really unsure why it global calls out what a admin is doing its not a big deal but yeah will have to cope with it

Share this post


Link to post
Share on other sites
51 minutes ago, mrwolv said:

dayz only lets 1 person login to admin at any time and no other admins can login untill the prev admin logs out so im really unsure why it global calls out what a admin is doing its not a big deal but yeah will have to cope with it

That's my point. No need to login as admin. There is a text file on the server which lists all possible admin ids. If yours in there,. you can use it. If not, not.  Effect: no global chat.

They all do that but ALSO require login.

Edited by 5andysalive

Share this post


Link to post
Share on other sites

so do you have this version then as its not the same as mine from the sound of it lol

Share this post


Link to post
Share on other sites

I'm not sure what is happening here but i keep getting a message that says

 

"Can't compile mission init script'!

$CurrentDir:momissions/dayzOffline.chernarusplus/init.c(181): Function

'OnEvent' is marked as override, but there is no function with this name in the base class"

Share this post


Link to post
Share on other sites
5 hours ago, Groolsh said:

I'm not sure what is happening here but i keep getting a message that says

 

"Can't compile mission init script'!

$CurrentDir:momissions/dayzOffline.chernarusplus/init.c(181): Function

'OnEvent' is marked as override, but there is no function with this name in the base class"

It's probably just a syntax error -- check for a missing semicolon or typo on or around line 181.

Share this post


Link to post
Share on other sites
42 minutes ago, drgullen said:

It's probably just a syntax error -- check for a missing semicolon or typo on or around line 181.

No, i figured it out it was me who placed the script at the wrong place i didn't read carefully enough. Thanks for taking your time to answer

!

Edited by Groolsh
misspelling

Share this post


Link to post
Share on other sites
3 hours ago, CaptainFist said:

@Groolsh

I Have the same issue... Can you upload or Post the correct init.c ?

open your init.c up find the line that says      

class CustomMission: MissionServer
{   

 

then press enter 2 time then just paste in the code and change your steam id to enable admin then just login in game so it should look like this below

 

class CustomMission: MissionServer
{    
    //Admin Start//
    bool verify_admins = false; // true=verify presence of BI UID in admin list
    string cmd_prefix = "/"; // Must be special character
    ref TStringArray admins = {"               "}; // Add your BI UID
 
    bool IsPlayerAnAdmin(PlayerBase player) {
        bool found = false;
        for ( int i = 0; i < admins.Count(); ++i ) {
            if(player.GetIdentity().GetId() == admins) { found=true; break; }

 

//Admin Start//
    bool verify_admins = false; // true=verify presence of BI UID in admin list
    string cmd_prefix = "/"; // Must be special character
    ref TStringArray admins = {"     "}; // Add your BI UID
 
    bool IsPlayerAnAdmin(PlayerBase player) {
        bool found = false;
        for ( int i = 0; i < admins.Count(); ++i ) {
            if(player.GetIdentity().GetId() == admins[i]) { found=true; break; }
        }
        return found;
    }
 
    void SendMessageToPlayer(PlayerBase player, string message) {
        Param1<string> param = new Param1<string>( message );
        GetGame().RPCSingleParam(player, ERPCs.RPC_USER_ACTION_MESSAGE, param, true, player.GetIdentity());
    }
 
    bool IsPlayer(string name) {
        PlayerBase p;
        array<Man> players = new array<Man>; GetGame().GetPlayers(players);
        for ( int i = 0; i < players.Count(); ++i ) {
            p = players.Get(i);
            if(p.GetIdentity().GetName() == name) return true;
        }
        return false;
    }
 
    PlayerBase GetPlayer(string name) {
        PlayerBase p;
        array<Man> players = new array<Man>; GetGame().GetPlayers(players);
        for ( int i = 0; i < players.Count(); ++i ) {
            p = players.Get(i);
            if(p.GetIdentity().GetName() == name) return p;
        }
        return NULL;
    }
 
    override void OnEvent(EventType eventTypeId, Param params)  
   
    {
        super.OnEvent(eventTypeId,params);
        int i;
        PlayerBase player, temp_player;
        array<Man> players = new array<Man>; GetGame().GetPlayers(players);
        if(eventTypeId != ChatMessageEventTypeID) return; // Is chat message
        ChatMessageEventParams chat_params = ChatMessageEventParams.Cast( params );
        if(chat_params.param1 != 0 || chat_params.param2 == "") return;
        player = GetPlayer(chat_params.param2);
        if(player == NULL) return;
        if(verify_admins && !IsPlayerAnAdmin(player)) { GetGame().AdminLog("[ADMCMD] (Unauthorized) " + player.GetIdentity().GetName() +" ("+player.GetIdentity().GetPlainId()+", "+player.GetIdentity().GetId()+") tried to execute "+ chat_params.param3); return; }
        string message = chat_params.param3, prefix, param0, command;
        TStringArray tokens = new TStringArray;
        message.Split(" ", tokens); int count = tokens.Count();
        param0 = tokens.Get(0);
        param0.ParseStringEx(prefix); if(prefix != cmd_prefix) return;
        param0.ParseStringEx(command);
        GetGame().AdminLog("[ADMCMD] PLAYER: "+ player.GetIdentity().GetName() +" ("+player.GetIdentity().GetPlainId()+", "+player.GetIdentity().GetId()+") CMD: "+ command);
        switch(command) {
            case "spawn": {
                if(count != 2) { SendMessageToPlayer(player, "/spawn [object]"); return; }
                GetGame().CreateObject(tokens[1], player.GetPosition(), false, true );
                SendMessageToPlayer(player, "[ObjectSpawn] Object spawned: " + tokens[1]); //Removed Global Chat Call//
                break;
            }
 
            case "goto": {
                if(count != 2) { SendMessageToPlayer(player, "/goto [player]"); return; }
                temp_player = GetPlayer(tokens[1]);
                if(temp_player == NULL) {
                    SendMessageToPlayer(player, "[Teleport] Can't find player called: '"+tokens[1]+"'");
                } else {
                    player.SetPosition(temp_player.GetPosition());
                    SendMessageToPlayer(player, "[Teleport] You teleported to " + temp_player.GetIdentity().GetName());
                }
                break;
            }
 
            case "allgoto": {
                PlayerBase allgoto_target;
                if(count != 2) { SendMessageToPlayer(player, "/allgoto [player]"); return; }
                allgoto_target = GetPlayer(tokens[1]);
                if(allgoto_target == NULL) {
                    SendMessageToPlayer(player, "[Teleport] Can't find player called: '"+tokens[1]+"'");
                } else {
                    SendMessageToPlayer(player, "[Teleport] You teleported everyone to your location");
                    for (i = 0; i < players.Count(); i++) {
                        temp_player = players.Get(i);
                        SendMessageToPlayer(temp_player, "[Teleport] You have been teleported to player " + allgoto_target.GetIdentity().GetName());
                        temp_player.SetPosition(allgoto_target.GetPosition());
                    }
                }
                break;
            }
 
            case "here": {
                if(count != 2) { SendMessageToPlayer(player, "/here [player]"); return; }
                temp_player = GetPlayer(tokens[1]);
                if(temp_player == NULL) {
                    SendMessageToPlayer(player, "[Teleport] Can't find player called: '"+tokens[1]+"'"); //Removed Global Chat Call//
                } else {
                    temp_player.SetPosition(player.GetPosition());
                    SendMessageToPlayer(temp_player, "[Teleport] You have been teleported to admin " + player.GetIdentity().GetName());
                    SendMessageToPlayer(player, "[Teleport] You teleported " + temp_player.GetIdentity().GetName() + " to your location");
                }
                break;
            }
 
            case "allhere": {
                SendMessageToPlayer(player, "[Teleport] You teleported everyone to your location");
                for (i = 0; i < players.Count(); i++) {
                    temp_player = players.Get(i);
                    SendMessageToPlayer(temp_player, "[Teleport] You have been teleported to admin " + player.GetIdentity().GetName());
                    temp_player.SetPosition(player.GetPosition());
                }
                break;
            }
 
            case "time": {
                if(count != 3) { SendMessageToPlayer(player, "/time [hour] [minute]"); return; }
                GetGame().GetWorld().SetDate( 2018, 1, 7, tokens[1].ToInt(), tokens[2].ToInt());
                SendMessageToPlayer(player, "[Servertime] You have set the servertime to " + tokens[1] + ":"+tokens[2]);
                break;
            }
 
            case "kill": {
                if(count == 2) {
                    temp_player = GetPlayer(tokens[1]);
                    if(temp_player == NULL) {
                        SendMessageToPlayer(player, "[Kill] Can't find player called: '"+tokens[1]+"'");
                    } else {
                        temp_player.SetHealth(0);
                        SendMessageToPlayer(player, "[Kill] You killed " + temp_player.GetIdentity().GetName());
                    }
                } else {
                    player.SetHealth(0);
                    SendMessageToPlayer(player, "[Kill] You killed yourself");
                }
                break;
            }
 
            case "killall": {
                SendMessageToPlayer(player, "[Kill] You killed everyone");
                for (i = 0; i < players.Count(); i++) {
                    temp_player = players.Get(i);
                    if(temp_player.GetIdentity().GetId() == player.GetIdentity().GetId()) continue;
                    temp_player.SetHealth(0);
                }
                break;
            }
 
            case "heal": {
                PlayerBase heal_target;
                if(count == 2) {
                    heal_target = GetPlayer(tokens[1]);
                    if(heal_target == NULL) {
                        SendMessageToPlayer(player, "[Heal] Can't find player called: '"+tokens[1]+"'");
                    } else {
                        SendMessageToPlayer(player, "[Heal] You healed " + heal_target.GetIdentity().GetName());
                    }
                } else {
                    heal_target = player;
                    SendMessageToPlayer(player, "[Heal] You healed yourself");
                }
                if(heal_target != NULL) {
                    heal_target.SetHealth(heal_target.GetMaxHealth("", ""));
                    heal_target.SetHealth("", "Blood", heal_target.GetMaxHealth("", "Blood"));
                    heal_target.GetStatStamina().Set(1000);
                    heal_target.GetStatEnergy().Set(1000);
                    heal_target.GetStatWater().Set(1000);
                }
                break;
            }
 
            case "offroad": {
                SendMessageToPlayer(player, "[Offroad] Vehicled spawned"); //Removed Global Chat Call//
                EntityAI v;
                v = GetGame().CreateObject( "OffroadHatchback", player.GetPosition() + "1.5 0 1.5");          
                v.GetInventory().CreateAttachment("SparkPlug");
                v.GetInventory().CreateAttachment("CarBattery");
				v.GetInventory().CreateAttachment("CarRadiator");
                v.GetInventory().CreateAttachment("HatchbackHood");
                v.GetInventory().CreateAttachment("HatchbackTrunk");
                v.GetInventory().CreateAttachment("HatchbackDoors_CoDriver");
				v.GetInventory().CreateAttachment("HatchbackDoors_Driver");
                v.GetInventory().CreateAttachment("HatchbackWheel");
                v.GetInventory().CreateAttachment("HatchbackWheel");
                v.GetInventory().CreateAttachment("HatchbackWheel");
                v.GetInventory().CreateAttachment("HatchbackWheel");
                v.GetInventory().CreateAttachment("HatchbackWheel"); // Spare Wheel
				v.GetInventory().CreateInInventory("CanisterGasoline"); // Gas
				
                break;
            }
           
            default: {
                SendMessageToPlayer(player, "Unknown command: " + command);
                break;
            }
        }
    }
	//Admin End//

 

 

 

Edited by mrwolv
  • Like 1

Share this post


Link to post
Share on other sites

Ok works with latest version. Multiple Admins Possible?  

 

ref TStringArray admins = {"Uid1xxxxxxxxxxxx;Uid2xxxxxxxxxxxxxx"}; // Add your BI UID    ???

Share this post


Link to post
Share on other sites
20 minutes ago, CaptainFist said:

Ok works with latest version. Multiple Admins Possible?  

 

ref TStringArray admins = {"Uid1xxxxxxxxxxxx;Uid2xxxxxxxxxxxxxx"}; // Add your BI UID    ???

yes but if admin 1 is login in admin 2 wont beable to so admin 1 would have to logout and yeah "2342342","234234","3424234" just reg steam ids

Edited by mrwolv

Share this post


Link to post
Share on other sites

I dont get it why you guys dont use a mod for it ^^
The Tomato mod on steam is very good and works like a charm

Share this post


Link to post
Share on other sites
On 23/01/2019 at 5:48 PM, JediKing1937 said:

Hello, all player see the message in chat, we have the solution for this problem?

nope no solution for this script atm but if you run a modded server youc an simply add the admin mod from there but your server will become modded

 

On 24/01/2019 at 10:43 AM, JediKing1937 said:

Hello, how to teleport when the survivors have a number ??

Example : /goto Survivor (5) Doesn't work

you will have problems with that you need to tell all players to change there name via steam -name=playername

 

On 23/01/2019 at 2:56 PM, G0ndalf said:

I dont get it why you guys dont use a mod for it ^^
The Tomato mod on steam is very good and works like a charm

lol i posted this before modding was a thing still works great tho :D

 

On 23/01/2019 at 5:00 AM, JediKing1937 said:

Master i need help.

when i change script.pbo them 

admin commander not work anymore ? how i can fix,pls~i need you

you dont need to change your script.pbo this needs to be placed in the init.c in your mission files

Share this post


Link to post
Share on other sites

is this (github version) script still works?

Share this post


Link to post
Share on other sites
On 4/11/2019 at 9:53 PM, ZOMBIESYRD said:

works fine for me at stable 1.02 version

Out of curiosity, tried the Github version. Works with exp.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×