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

Sign in to follow this  
Wh1teQueen

ItemPreview Client Side

Recommended Posts

Hey guys,

I Made an Ui which loads all Item Names now I want a ItemPreviewWidget to display the selected item.

My problem is that I need to pass an EntityAI to the widget since it is Client side I don't know how I would give it a Item the Client don't have and can't just create.

I tried GetGame().CreateItem with local param which doesn't seem to work I also tried g_Game same result also I tried sending rpc to server create Item send to back with param EntityAI what does not seem to be possible since the server crashes without any log

I mean it would maybe work if I create Item in inventory pass it to preview and delete it after something else is selected or closed but that doesn't seems right + if no space ?

I am really stuck at this 

Maybe someone has an idea

Edited by Wh1teQueen

Share this post


Link to post
Share on other sites

You can look into Akensors offline mode. He made this kind of preview and maybe you find out how he did it.

LBmaster

Share this post


Link to post
Share on other sites

Yes I did but it's offline he does g_Game create object that does not work on server 

That is why I tried sending rpc  to create the object 

Edited by Wh1teQueen

Share this post


Link to post
Share on other sites

Yep tried but that's server side client can't do it (i think )also while setting create local to true/false  

Didn't work after that i tried with rpc and could not find a way to give the Client the item even if the server created it

 

At least I think it did not work can't say for sure since I can not be 100% certain that ItemPreview is working correct but I can't see why it should not it's the same from inventory inspect (offline mode uses panelwidget but seem to work the same way from what I can tell)

Edited by Wh1teQueen

Share this post


Link to post
Share on other sites
bool OnItemSelect( Widget w, int x, int y, int row, int column, int oldRow, int oldColumn)
	{
		
			Message("OnItemSelect");
			if ( w == m_classList ) 
			{
				Message("OnItemSelect classlist" + GetCurrentSelection());
				EntityAI item;
				item = g_game.CreateObject( GetCurrentSelection(), vector.Zero, false, false, false );
				//GetGame().RPCSingleParam( NULL, M_RPCs.M_Menu_Spawn_ItemPrev, new Param1<string>( GetCurrentSelection() ), false, NULL ); <-- Does not work
				if (item) <--  is not !
				{
					//InspectMenuNew.UpdateItemInfo(m_Root, item);
				Message("OnItemSelect is item : "); <-- Wont Trigger
					if (!m_item_widget)
					{
						Widget preview_frame = m_Root.FindAnyWidget("ItemPrev");
						if (preview_frame)
						{
							float l;
							float h;
							preview_frame.GetSize(l, h);
							m_item_widget = ItemPreviewWidget.Cast( GetGame().GetWorkspace().CreateWidget(ItemPreviewWidgetTypeID, 0, 0, 1, 1, 								WidgetFlags.VISIBLE, ARGB(255, 255, 255, 255), 10, preview_frame) );
						}
					}
					
					m_item_widget.SetItem(item);
					m_item_widget.SetView( item.GetViewIndex() );
					m_item_widget.SetModelPosition(Vector(0,0,1));
					
					float v, c;		
					m_item_widget.GetPos(v, c);

					m_item_widget.SetSize( 1.75, 1.75 );
				
					// align to center 
					m_item_widget.SetPos( -0.375, -0.375 );
					
					//m_item_widget.SetModelOrientation
					//PPEffects.SetBlurInventory(1);
				}
				return true;
			}
		return true;
		
	}
...

Message("OnItemSelect");
			if ( w == m_classList ) 
			{
				Message("OnItemSelect classlist");
				EntityAI item;
				item = GetGame().CreateObject( GetCurrentSelection(), vector.Zero, false, false, false ); <-- GetGame()
				//GetGame().RPCSingleParam( NULL, M_RPCs.M_Menu_Spawn_ItemPrev, new Param1<string>( GetCurrentSelection() ), false, NULL );
				if (item) <-- same
				{
					//InspectMenuNew.UpdateItemInfo(m_Root, item);
				Message("OnItemSelect is item : "); <-- same wont trigger
                  
                  
...                  

Any Idea?

Edited by Wh1teQueen

Share this post


Link to post
Share on other sites
Sign in to follow this  

×