• Props - banned
    4 replies, posted
Sorry, I just started coding again recently and I can't remember well. How could I go about getting the props listed in the table below banned from the server and a usermessage coming up saying, "This prop has been banned." Wouldn't it be something like [lua]local bannedprops = { } bannedprops[1] = "models/prop_combine/example" for k, v in pairs (bannedprops.GetAll()) [/lua] I am not sure, my memory can't remember.
[lua]local models = { "crane_frame.mdl" } --All or part of model name. local function blockProps( ply, mdl ) for _, v in pairs( models ) do if string.find( mdl, v ) then return false end end end hook.Add( "PlayerSpawnProp", "blockProps", blockProps )[/lua] :eng101: Directly taken from the wiki! [url=http://wiki.garrysmod.com/?title=Gamemode.PlayerSpawnProp]http://wiki.garrysmod.com/?title=[/url][url=http://wiki.garrysmod.com/?title=Gamemode.PlayerSpawnProp]Gamemode.PlayerSpawnProp[/url] [url]http://wiki.garrysmod.com/?title=Gamemode_Hooks[/url]
Thank you, so it would look like this with multiple models? [lua]local models = { "crane_frame.mdl", "blame_game.mdl", "example_example.mdl", "snoggles.mdl" } local function blockProps( ply, mdl ) for _, v in pairs( models ) do if string.find( mdl, v ) then return false end end end hook.Add( "PlayerSpawnProp", "blockProps", blockProps ) [/lua]
Just try it.
[QUOTE=Justin37111;17948029]Thank you, so it would look like this with multiple models? [lua]local models = { "crane_frame.mdl", "blame_game.mdl", "example_example.mdl", "snoggles.mdl" } local function blockProps( ply, mdl ) for _, v in pairs( models ) do if string.find( mdl, v ) then return false end end end hook.Add( "PlayerSpawnProp", "blockProps", blockProps ) [/lua][/QUOTE] Yup, that's the point of having a table. It checks the model of the prop against each element of the table. If they're the same it will return false, thus stopping the prop from being spawned.
Sorry, you need to Log In to post a reply to this thread.