KeaganH wrote:I'm trying to make an actor that spawns a gun only obtainable by a certain class
I'm not sure why you need "
an actor that spawns a gun". Why not just put
Inventory.RestrictedTo on the gun itself? Players not using one of the matching class(es) will not be able to pick it up as a result. They will still be able to pick it up for ammo, but you can use
INVENTORY.RESTRICTABSOLUTELY to disable this behavior. A_GiveInventory will also silently fail if it detects a class mismatch, and nothing bad will happen.
If you still need another actor to spawn your gun, then I assume there must be some condition that will make it spawn the gun or something else (maybe nothing at all) depending on the outcome? In this case, what kind of condition do you want it to be? Do note that if you want to check the player's class, it is possible that there might be more than one player in the game (and players can also change their classes during a multiplayer game). Additionally, weapons and other items spawned this way will not be subject to the "weapons stay" and/or "items respawn" gameplay options unless spawned by means of an actor derived from a
RandomSpawner (or you must use ZScript to clear the DROPPED flag on the newly-spawned item).