Jump to content
Sign in to follow this  
shuko

How to determine when a player opens inventory of a specific container (box/vehicle)?

Recommended Posts

Asking help from the more experienced scripters, since I have never done anything with dialogs.

I'm trying to detect when a player in an MP game opens inventory of a truck, but I can't rely on him taking or putting anything in it.

I know I can wait for the inventory display to open with:

!isnull (findDisplay 602)

But, how to determine if that's the truck inventory and not the player units?

It probably involves all kinds of black magic command of gui control, I'm a right?

Share this post


Link to post
Share on other sites

Checking for the existence of ctrl 640 will tell you whether another objects inventory is open. e.g crate, vehicle, uniform, vest or backpack

ctrl 640 is the other tab the appears next to ground when something else is open

put this in your players init as a quick test

h = [] spawn {
while {true} do {
	if (!(isnull (findDisplay 602))) then {
		if (ctrlShown ((findDisplay 602) displayCtrl 640)) then {
			hintsilent "inventory open";
		};
	}else{
		hintSilent "";
	};
	sleep 1;
};
};

Share this post


Link to post
Share on other sites

That will, unfortunately, show up at any vehicle and not just the specific truck.

Share this post


Link to post
Share on other sites

He can't rely on putting or taking something from it.

Edited by cuel

Share this post


Link to post
Share on other sites
That will, unfortunately, show up at any vehicle and not just the specific truck.

I realise that but if that listbox is present then you have inventory of something else open, this could be a vehicle, crate, groundweaponholder etc.

I tried for ages to get the text on the tab to try and whittle it down abit (as crates and vehicles say crate) but for the life of me i cant find it. So i posted the information to give you something to start from.

Crates and weaponHolders require for you to be looking at them where vehicles are just in a certain range/area of the vehicle.

So you can ..

if idc 640 is present

check cursor target for ammo crates or weapon holders

if there are none and your are within ? 3 meters of a vehicle and the vehicles VarName is the truck your after, you are most of the way there.

Just need to work out what happens if you are near multiple vehicles maybe depends what you need it for.

If its a certain type of vehicle you can work out the bounds of the inventory area offset from the vehicles [0,0,0], that would give you even more data to whittle down what inventory your looking at

Edited by Larrow

Share this post


Link to post
Share on other sites

NO, he does not want to rely on something being PUT TAKEN just that the inventory was opened.

Share this post


Link to post
Share on other sites
NO, he does not want to rely on something being PUT TAKEN just that the inventory was opened.

Oh and why is he asking to rely on Put or Take?

Asking help from the more experienced scripters, since I have never done anything with dialogs.

I'm trying to detect when a player in an MP game opens inventory of a truck, but I can't rely on him taking or putting anything in it.

I know I can wait for the inventory display to open with:

!isnull (findDisplay 602)

But, how to determine if that's the truck inventory and not the player units?

It probably involves all kinds of black magic command of gui control, I'm a right?

Share this post


Link to post
Share on other sites

You missed the three words before that

but I can't rely on him taking or putting

Share this post


Link to post
Share on other sites

No worries put the kettle on and ill have a bacon sarnie aswell :D

Shuko can you go into more detail of what your trying todo ? Locking vehicle inventory ?

Share this post


Link to post
Share on other sites

I have a task "Inspect the cargo of the truck".

I need to wait until a player does so, to complete it and give a new one.

---------- Post added at 05:25 PM ---------- Previous post was at 05:18 PM ----------

I could obviously add a distance check to find the closest vehicle, but if there was more elegant way. The vehicle info must be passed to some point since the dialog knows which cargo to display. Just how to get the info...

Share this post


Link to post
Share on other sites

So you know exactly what truck they need to goto, how about something like ....

When player is within ? 6 meters of the truck and he has opened his inventory and idc 640 is present

Grab the list size of idc 640, perform a quick action on the player of taking a random object from his inventory and placing it in the truck

Recheck size of listbox, move item back into players inventory

If listbox size increased you know hes looking at the right trucks inventory. (or quantity of item has increased, as placing a mag if that type of mag already exists the list box size is not going to change)

Sounds a little hacky and would need experimenting with see how quick the items moves back and forward (without the player noticing). Would save on all the checking i mentioned in my previous post. (or maybe change your task to he has to place something in the inventory lol then just check for an increase in size/quantity on PUT and that the right object is missing from his inventory).

Just thinking out loud of ways to try and get around the fact we dont seem to be able to know what inventory is open.

_______________

I could obviously add a distance check to find the closest vehicle, but if there was more elegant way. The vehicle info must be passed to some point since the dialog knows which cargo to display. Just how to get the info...
From all the things i checked last night im starting to think that is all handled engine side, as i said in my previous post i couldnt even find a UI element to get the TAB text from even though there is an element there named #_TAB_TEXT relating to the inventory list of what ever your looking at. Edited by Larrow

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
Sign in to follow this  

×