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

heizung124

Catch Key press in Mod

Recommended Posts

The key pressing and corresponding actions/update on server are done via rpc from what I've read.

Corey on Discord shared the following as a quick example how can you send an RPC on key press, way over my head but maybe helpful for you.

This goes into your missionGameplay onKeypress

if ( key == KeyCode.KC_O )
        {
            ScriptRPC rpc = new ScriptRPC();
            rpc.Write("string");
            rpc.Write(1);
            rpc.Write(12.5);
            rpc.Send(null, M_RPCs.M_TEST, true);
        }

so if you press O, it will forge the RPC, fill with desired data then send it to the server

  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, smasht said:

The key pressing and corresponding actions/update on server are done via rpc from what I've read.

Corey on Discord shared the following as a quick example how can you send an RPC on key press, way over my head but maybe helpful for you.

This goes into your missionGameplay onKeypress


if ( key == KeyCode.KC_O )
        {
            ScriptRPC rpc = new ScriptRPC();
            rpc.Write("string");
            rpc.Write(1);
            rpc.Write(12.5);
            rpc.Send(null, M_RPCs.M_TEST, true);
        }

so if you press O, it will forge the RPC, fill with desired data then send it to the server

Nice exactly what i was looking for
thanks

 

Edit but does not work

 

override void OnKeyPress( int key )
	{
		Print("key releae" + key) // does not print
		super.OnKeyRelease( key );

		if ( key == KeyCode.KC_T ) 
		{
			Print("key press" + key + "t") // surly does not print
			GetPlayer().MessageStatus( "Key pressed" ); //same
		}
	}

Any Idea?

Edited by heizung124

Share this post


Link to post
Share on other sites

×