Jump to content

Recommended Posts

hi,

how do I check if the player has a specific ITEM? Is this possible with a trigger? And how would the syntax look like?

thx in advance!

Share this post


Link to post
Share on other sites
this && ("NVGoggles" in (items player) || "NVGoggles" in (assigneditems player))

Should be good for the trigger condition

  • Thanks 1

Share this post


Link to post
Share on other sites

wow works phantastic but now i know i need it for Inventory and a primary weapons Check. I need to check the new Items loke Surpressors , Optics and so on. Maybe you can give me second Solution for the Weapons Check pleeaaase ? :)

thx in advance

Share this post


Link to post
Share on other sites

Can you post your solution as I am searching for the same thing. I have tried:

if ((player weaponAccessories primaryWeapon player) select 2 == "") exitWith { hint "Select an Optic for your rifle" };

---------- Post added at 00:52 ---------- Previous post was at 23:57 ----------

Figured it out:

if (primaryWeaponItems player select 2 == "") exitWith {hint "no optics"};

select 0 = suppressor

select 1 = laser

select 2 = optic

---------- Post added at 01:21 ---------- Previous post was at 00:52 ----------

This does not work, no reported script errors and no hint:

 if (primaryWeapon player == "" && primaryWeaponItems player select 2 == "") exitWith {hint "Choose a weapon and optic first."};

Edited by cobra4v320

Share this post


Link to post
Share on other sites
This does not work, no reported script errors and no hint:

Code:

if (primaryWeapon player == "" && primaryWeaponItems player select 2 == "") exitWith {hint "Choose a weapon and optic first."};

Does for me from the debug console, gives a divide by zero error, as if there is no weapon then index select 2 does not exist.

hstring = "Please choose";
if (primaryWeapon player == "") then {
hstring = hstring + " a primary weapon and";
};
if ((count (primaryWeaponItems player)) == 0 || {((primaryWeaponItems player) select 2) == ""}) then {
hstring = hstring + " an optic";
}else{
hstring = "";
};
if(hstring != "") then {
hint format["%1 first!",hstring];
};

Edited by Larrow

Share this post


Link to post
Share on other sites

Using it in the debug console gave me no hint. Forgot that I switched from DEV branch to the normal version, just added in -showscripterrors. :/

---------- Post added at 02:32 ---------- Previous post was at 02:27 ----------

I just need to make sure the player has a weapon and optic before continuing the script.

Edited by cobra4v320

Share this post


Link to post
Share on other sites

Its a dialog menu, I want the player to have both before exiting the menu.

gnff.jpg

Edited by cobra4v320

Share this post


Link to post
Share on other sites

Disable the escape key & those insertion method buttons until the weapons condition is met. Assuming those buttons close the dialog & spawn the unit somewhere. This will prevent the dialog from closing & the player having no loadout. Or you can simply set a default weapon and optics. So even if the dialog is closed, they have those things.

example:

DisableSerialization;
noesckey = (findDisplay 3000) displayAddEventHandler ["KeyDown", "if ((_this select 1) == 1) then {True}"];
{ctrlEnable [_x, False]} ForEach [6100,6101,6102,6103,6104];

WaitUntil { ... Weapon conditions ... };

(findDisplay 3000) displayRemoveEventHandler ["KeyDown", noesckey];
{ctrlEnable [_x, true]} ForEach [6100,6101,6102,6103,6104];

Edited by Pac Man

Share this post


Link to post
Share on other sites

:eek:

Please don't disable player input for something you can default to effortlessly. If you want someone to have a gun with a scope give them one. Then let them change the scope or the gun if they don't want that one. Don't turn off their control of their client. That's insane. :)

Open dialog, give 'em a weapon and a scope then say "This is your weapon now, like it? No? Pick something else then".

  • Like 1

Share this post


Link to post
Share on other sites

Yup, I agree. But sometimes those commands are very useful & can't be avoided in certain circumstances. This isn't one of them :). Very good commands to know though. In this case, I'd simply have a default weapon & optics.

Edited by Pac Man

Share this post


Link to post
Share on other sites

Insert menu buttons are disabled until you pick a weapon.

if (primaryWeapon Player == "") exitWith {hint "Choose a weapon first."};
closedialog 0;

Thanks for the ideas, I will figure something out.

Share this post


Link to post
Share on other sites

Could give me some sample on creating a object detector present in the inventory?

Thanks.

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

×