I have a script using "giveWeapon" but every time I get the weapon while I have 2 weapons already, it tries to give me 3 and of course Samantha curses me. How can I fix this to make it have the normal behavior of replacing a weapon if I have 2? I will put some of my script in just in case it helps, but not the whole script, because it's quite large.
Code Snippet
Plaintext
workbench waittill("trigger",player);
player thread do_knuckle_crack(); wait(2.7); player playLocalSound("zmb_cha_ching"); player giveWeapon(getWeapon(level.weaponGiven)); player switchtoweapon(level.weaponGiven);
Before you give the weapon your going to want to take the players current weapon. Here is a nice and simple play to do it.
Code Snippet
Plaintext
workbench waittill("trigger",player);
player thread do_knuckle_crack(); wait(2.7); player playLocalSound("zmb_cha_ching"); player takeWeapon( player getCurrentWeapon() ); // new player giveWeapon(getWeapon(level.weaponGiven)); player switchtoweapon(level.weaponGiven);
On my phone so check the ref to make sure those function names are right.
Last Edit: November 28, 2016, 07:20:43 am by AoKMiKeY
Thanks, but what if he has 1 gun? Will it give another or replace it? How can I check how many weapons he has for that. One last thing, where do you find these functions?
It does a lot more checks, and I think one of them will handle mule kick and if player has max weapons.
And are you using the do_knucke_crack from _zm_pack_a_punch.gsc? I would assume they have compensated for that issue in there, most likely using the zm_utility::increment_is_drinking() function, and the zm_utility::decrement_is_drinking() one.
Code Snippet
Plaintext
workbench waittill("trigger",player);
player thread _zm_pack_a_punch::do_knuckle_crack(); wait(2.7); player playLocalSound("zmb_cha_ching"); player zm_weapons::weapon_give(getWeapon(level.weaponGiven)); player switchtoweapon(getweapon(level.weaponGiven));
For your original issue, if this stuff ^ doesn't help, you can just check the primary size, something like this:
Code Snippet
Plaintext
if ( player HasPerk( "specialty_additionalprimaryweapon" ) ) { if(player GetWeaponsListPrimaries().size > 2) { player TakeWeapon(player GetCurrentWeapon()); } } else { if(player GetWeaponsListPrimaries().size > 1) { player TakeWeapon(player GetCurrentWeapon()); } } player GiveWeapon(getweapon(weapon)); player SwitchToWeapon(getweapon(weapon));
But there will be other concerns, like the minigun powerup and laststand and so on...
Last Edit: November 29, 2016, 02:50:38 am by MakeCents
It does a lot more checks, and I think one of them will handle mule kick and if player has max weapons.
And are you using the do_knucke_crack from _zm_pack_a_punch.gsc? I would assume they have compensated for that issue in there, most likely using the zm_utility::increment_is_drinking() function, and the zm_utility::decrement_is_drinking() one.
Code Snippet
Plaintext
workbench waittill("trigger",player);
player thread _zm_pack_a_punch::do_knuckle_crack(); wait(2.7); player playLocalSound("zmb_cha_ching"); player zm_weapons::weapon_give(getWeapon(level.weaponGiven)); player switchtoweapon(getweapon(level.weaponGiven));
You won't be able to do so since all functions in '_zm_pack_a_punch' are private, atleast I think so (and it also #namespace isn't used)