Hello, so I've been working in a new gamemode for Event Manager, similar to Black Ops 1's One in the Chamber, but I don't seem to able to correctly find the player's correct held weapon and change it's contents, this is my method:
Getting player held weapon:
Changing the contents:Code:BaseProjectile heldWeapon = hitinfo?.Weapon?.GetItem()?.GetHeldEntity() as BaseProjectile ?? null;
Thanks in advance!Code:heldWeapon.primaryMagazine.contents = (heldWeapon.primaryMagazine.capacity-(heldWeapon.primaryMagazine.capacity-1));
Changing held weapon contents
Discussion in 'Rust Development' started by cogu 2, May 20, 2016.
-
Wow. First of all, you're doing it far too complexly. If you're just wanting to reduce the amount,
should work, no need to do all that other stuff, just a simple int.Code:projectile.primaryMagazine.contents -= 1;
If you want to change the max it can hold,Code:projectile.primaryMagazine.capacity = 1;
-
Thank you for helping me keep my code clean and in a simple way, but I'm still having the issue where I can't change the held weapon's contents. I'm doing hooking it to OnPlayerAttack and checking if the projectile hit a player entity, if that happens the held weapon's content empties for 5 seconds and goes back to 1 again.
-
Still not changing? Hmm... What do you mean by it's not letting you? Changing it to 1 just doesn't do anything, or what exactly? You say "the held weapon's content empties for 5 seconds and goes back to 1 again." Is this intended, or is this the issue? I'm just not sure I entirely understand.
You may have to dofor it to take effect properly.Code:heldWeapon.SendNetworkUpdateImmediate();
-
The intended effect is for it to be empty for 5 seconds if the person does not hit a player, but the issue was that I wasn't even able to change the weapon's contents, will try your solution though.
