Are you trying to modify a weapon or remove it? And are you trying to make all these changes before the start of the mission, or on the go?
I think
SetClassProperty() works for modifying weapons, but you put in the name of the weapon odf to change a weapon's properties. That would modify the weapons for any units which haven't spawned yet (change the class at the spawn screen) but it doesn't change the weapons for units which are already spawned/alive. To swap weapons, then you might be able to use
SetClassProperty() with the character class and
"WeaponName1",
"WeaponAmmo1",
"WeaponChannel1" etc.
SetProperty() is designed for units which are spawned, but I don't know how you would use it on a weapon, because weapons don't have instances (
reference) and
SetProperty() is supposed to take
userdata. I'm not sure how you find a spawned weapon's
userdata, if it even has any.
The easiest way to change/add/remove weapons is just to make a new unit properly, with a side mod. If you're in the mission lua anyway, then it's the normal way to do things. Though if you're doing something like a
custom user script, and aren't changing the mission lua directly, then you could hack code into
AddUnitClass() and do some trickery with that.
If you want to change weapons on the go, there was someone who made a Gun Game mod a while back and I think I remember it changing your character model and weapon loadouts while you were playing (ie without forcing you to respawn). That suggests that it's possible but I have no idea how it was made.
Edit: Does it not work when you use
SetClassProperty("Put the character class name here", "WeaponName4", "")? Same question for
SetProperty(charUnit, "WeaponName4", ""), though in that case I half expect the weapon to only disappear when you switch away and try to switch back, like when you lock weapons for awards. Or maybe it could crash. The empty string might be important in case it tries to read
"-" as
-.odf
Edit2: Also, in that reference post above, Zerted pointed out that changing some weapon properties crashes multiplayer. It really depends on if you need to figure out how to make changes mid mission. Otherwise you should just make a side mod.