Entity Spawning


I’m just wondering how I can disable people spawning entities from the spawn menu, it’s quite annoying when people go around spawning the entities.


hook.Add( "PlayerSpawnSENT", "PlayerSpawnSENTStop", function( PLAYER ) 
return false//Prevents the suer from spawning any entity.

That blocks all entites from being spawned. If you want to block a certain type of entity, you could use this code:

hook.Add( "PlayerSpawnSENT", "PlayerSpawnSENTStop", function( PLAYER, sent_type ) 
if sent_type == "sent_ball" then//This checks to see if it's a bouncy ball
return false//This prevents the user from spawning it.

Thanks a bunch for your superfast reply: I think I’ll have to block certain entity’s or the Drugs Mod will falter. Thanks again!

Edit: Though however, will blocking the individual drugs mod sents stop them from being spawned through an in-game menu? As to say that drugs are bought, will this allow them to spawn on buy?

No problem at all! Glad to be of help =)

Hello again,

Please read my edit above, thanks. :slight_smile:

Depending on how the drug mods work. I would have to assume no, as they probably use “ents.create”. However, I’m not totally sure, it doesn’t hurt to try that code. =) if it doesn’t work, I’m pretty sure, you would have to edit the lua code, and remove the spawning code. sorry I can’t be more of help. If you link me to the drug mod, I could take a look at the code and see if there is an easy way to prevent it.

Ah, it does use ents.Create. Thank you again for your help, it is definitely appreciated!

Again, you are most definatly welcome. I was just glad I could help. =)