Jump to content
The Dark Mod Forums

[SOLVED] How to 'remove' blackjack and sword?

Recommended Posts

HMart -
I followed your helpful outline, though my thread function was somewhat simplified:

void player::DiscardWeaponThread(entity weapon) {
    sys.wait(3); // possibly redundant    
    discardthreadNumber = 0; // Tell caller we're done

My version of DiscardWeaponThread() has these differences:

  • I added the ...Thread suffix - that's just me.
  • It's a void function, since the "thread" keyword on the call takes care of returning the thread ID.
  • Wrapping the body in "eachFrame" didn't seem to buy anything other than making my head hurt. By not having an endless loop, I can end the thread just by ending the function, so don't need a sys.terminate
  • Instead of your gui method, I used an atdm_gui_message... element in the map to put a message up for 4 seconds.  This works fine.
  • weapon.weaponHolstered() is a void function, so was not meaningful to test by an "if". And its presence or absence didn't seem to make a difference.
  • I don't know if waitFor(weapon) works (I added "sys." before it), so I did sys.wait(3) too to be safe.

This is an OK if imperfect solution. A problem with using disableWeapon is that, while it puts the weapon down, it leaves it selected in the GUI, and you can't unselect with TAB. Nor can the user raise it (and see my message) again. I tried putting an enableWeapon() at the end of the thread, but that undesirably raises the weapon again.

I also tried, in place of the disableWeapon() call, these functions -

  • LowerWeapon(); // w or w/o "self."
  • selectWeapon("atdm:weapon_unarmed");

Neither exhibited the necessary lowering response (although getting rid of disableWeapon did mean you could lower the weapon with the normal keystroke, and when you re-raised it with the normal keystroke, the gui message would re-appear).

Finally, I considered trying .Lower(), that is available for certain weapons, e.g.:

#include "script/tdm_weapon_blackjack.script"
    // replace "disableWeapon()" with code that checks if weapon is blackjack (not shown) and if so:
    weapon_blackjack jack = weapon; // cast so "Lower" is available. BAD SYNTAX

But I don't know how to do the required cast/conversion in this scripting language.

Link to post
Share on other sites

Among my problems with disableWeapon() is that it disables ALL weapons, not just the current one, by essentially freezing the weapons part of the user interface. This may work for grayman's use case (the player put in jail) but not mine... I want to be more selective. (Not shown: my filtering of weapon type so that DisarmWeaponThread gets called only for blackjack and shortsword).

[SOLVED] I finally have a solution for my needs. Instead of using "disableWeapon()" in the above function, I use:

Note carefully the argument here. It is not either of these:
    selectWeapon("player1_weapon"); // Name returned by weapon.GetName() when player unarmed.

FYI, grayman gives the otherwise-undocumented list of selectWeapons strings here as:


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...