Jump to content

Forums Announcement

Read-Only Mode for Announcements & Changelogs

Dear Survivors, we'd like to inform you that this forum will transition to read-only mode. From now on, it will serve exclusively as a platform for official announcements and changelogs.

For all community discussions, debates, and engagement, we encourage you to join us on our social media platforms: Discord, Twitter/X, Facebook.

Thank you for being a valued part of our community. We look forward to connecting with you on our other channels!

Stay safe out there,
Your DayZ Team

Mizev

Modding standard features

Recommended Posts

In creating my mod, I need to redefine the standard feature.

modded class PlayerBase
{	
	
	override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
	{................

For the experiment, I first took a fully standard function from OnRPC.

But this led to the crash of the game client.

 

Then I began to remove some of the string functions until the only thing left:

 

modded class PlayerBase
{	
	
	override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
	{
		super.OnRPC(sender, rpc_type, ctx);
		
		switch(rpc_type)
		{
			case ERPCs.RPC_SYNC_DISPLAY_STATUS:
			
				if( GetDisplayStatus() ) 
				{
					//GetDisplayStatus().OnRPC(ctx);
				}
			break;
	
		}

	}

}

This does not result in a game client error.

If you uncomment a line:

//GetDisplayStatus().OnRPC(ctx);

Then the game client crash happens again.

 

Can someone tell me what I did wrong?

 

p.s. Sorry about my English.

 

Share this post


Link to post
Share on other sites
On 21.10.2018 at 10:48 AM, Mizev said:

For the experiment, I first took a fully standard function from OnRPC.

modded class PlayerBase
    {
        override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
            {
                super.OnRPC(sender, rpc_type, ctx);
                
                if ( (rpc_type >= 10000) && (rpc_type <= 10100) )
                    {
                        
                        Print("["+ GetGame().GetTime().ToString() +"]: [#Ultima]: [RPC]: Пришел пакет от сервера.");
                        Print(string.Format("Тип: %1. Данные: %2.", rpc_type, ctx));
                                
                        Param1<string> v_ctx    =    new Param1<string>("");
                        ctx.Read(v_ctx);
                                
                        string    v_pckData    =    v_ctx.param1;
                                
                        Ultima_Client_Class_Admins.ParsePacket(rpc_type, v_pckData);
                        return;
                    }
            }
    }

работает норм. мб у тебя крашит не из-за этого?

Edited by hftrade

Share this post


Link to post
Share on other sites

Да твой пример будет работать нормально. Дело не в этом. Я не хочу полностью переопределять OnRPC, а оставить классическую + добавить что-то свое. И вот тут начинается проблема. Если мы создадим класс modded class PlayerBase и добавим в нем стандартную функцию OnRPC(..., то два класса class PlayerBase и modded class PlayerBase не будут корректно как бы работать. modded class PlayerBase не видит остальные функции class PlayerBase, которые я не модифицирую.

Я бы хотел добиться нечто похожего как с классами CustomMission и MissionServer.

Share this post


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

Да твой пример будет работать нормально. Дело не в этом. Я не хочу полностью переопределять OnRPC, а оставить классическую + добавить что-то свое. И вот тут начинается проблема. Если мы создадим класс modded class PlayerBase и добавим в нем стандартную функцию OnRPC(..., то два класса class PlayerBase и modded class PlayerBase не будут корректно как бы работать. modded class PlayerBase не видит остальные функции class PlayerBase, которые я не модифицирую.

Я бы хотел добиться нечто похожего как с классами CustomMission и MissionServer.

The super.function(); call will allow you to still call the original function you are overriding. Removing it will result in your function completely replacing the parent one.

Share this post


Link to post
Share on other sites

Thank you! Now I understand how it works!

Share this post


Link to post
Share on other sites

Все они видят. ты super не вызывай, из базы, и полностью переопределишь.

Share this post


Link to post
Share on other sites

Try to use a translation service like Google if you are going to post in russian.

Попробуйте использовать службу перевода, такую как Google, если вы собираетесь публиковать ее на русском языке.

Share this post


Link to post
Share on other sites

×