ULX

Author Topic: Groups, Props, and Tools  (Read 11883 times)

0 Members and 3 Guests are viewing this topic.

Offline Avien

  • Full Member
  • ***
  • Posts: 168
  • Karma: 4
Groups, Props, and Tools
« on: May 11, 2007, 08:52:08 PM »
Before you say use the search function, i already have and included the threads i have found useful.  I am just unsure how to make the 3 things fit together.  I want to be able to make certain props and tools be blocked to certain groups.  Respectably, nothing limited to superadmins, and most of my things are directed toward clients.

I read the following threads:
http://forums.ulyssesmod.net/index.php/topic,682.0.html
http://forums.ulyssesmod.net/index.php/topic,858.0.html
http://forums.ulyssesmod.net/index.php/topic,721.0.html

My question is how do i put these things together in to one file, along with blocking ignite, paint, and other spammable tools to be blocked from regular clients?  I have no experience with lua and don't want to mess things up.

I know i am asking for someone to figure out what to do, but i included the threads in which the stuff i am looking for, i am just not sure how to go about putting them together and having them work the way they should

As for limiting props, do i just add the other things i want blocked after the comma in this code:
Code: [Select]
{ "models/Effects/splode.mdl", }
This is mainly to block TNT barrels to clients so people wont crash server with the bufferoverflow message.


I greatly appreciate any help given, as i am a total noob in lua.
« Last Edit: May 11, 2007, 08:55:05 PM by Avien »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Groups, Props, and Tools
« Reply #1 on: May 12, 2007, 09:24:02 AM »

As for limiting props, do i just add the other things i want blocked after the comma in this code:
Code: [Select]
{ "models/Effects/splode.mdl", }
This is mainly to block TNT barrels to clients so people wont crash server with the bufferoverflow message.

Avien,
Look at page 2 of your first posted link regarding blocking larger props. It has more 'final' working code bits, and includes some example answer to your question.
Which, by the way, is yes. :)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Avien

  • Full Member
  • ***
  • Posts: 168
  • Karma: 4
Re: Groups, Props, and Tools
« Reply #2 on: May 12, 2007, 11:22:29 AM »
I saw all of this, but i want to put all the code together in one file.  Having groups where i block props for clients, such as TNT barrels, phx explosive barrels, along with the ignite tool and paint tool.  But all the examples i have included are for either props, or groups, and i have no idea how to put them together.  So i am asking for help in doing that, since i know nothing about lua.


This would work:
Code: [Select]
if not SERVER then return end

local groups = { "superadmin", "admin", "opperator" } --Add your groups here

local function block_build( ply )
    for _,v in ipairs( groups ) do
        if ply:IsUserGroup( v ) then
            return
        end
    end
    ULib.tsay( ply, "You are not allowed to build." )
    return false
end
hook.Add( "PlayerSpawnProp", "block_prop", block_build )
hook.Add( "PlayerSpawnEffect", "block_effect", block_build )
hook.Add( "PlayerSpawnVehicle", "block_vehicle", block_build )
hook.Add( "PlayerSpawnSENT", "block_sent", block_build )
hook.Add( "CanTool", "block_tool", block_build )

I see the block_prop, effect, vehicle, tool, etc... but i dont know where to put the things i want to block.  Do i replace the ply in
Code: [Select]
block_build( ply )with the location for props, and the tools?
« Last Edit: May 12, 2007, 11:25:14 AM by Avien »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Groups, Props, and Tools
« Reply #3 on: May 12, 2007, 05:29:56 PM »
Avien, ply is the player passed to the function.
Replacing it will not help you reach your goal of banning certain players from certain props.
Adding on however might.

I'm sorry I don't have time to rewrite the code you wish.

I recommend attempting to teach yourself Lua.
www.lua.org and Google are great places to learn about lua, especially "for" loops and "tables", which, are much of what you're trying to work with for the player grouptables, and the prop list tables you don't want spawned.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Avien

  • Full Member
  • ***
  • Posts: 168
  • Karma: 4
Re: Groups, Props, and Tools
« Reply #4 on: May 13, 2007, 08:25:55 PM »
I tried asking for help on the facepunch forums, but as of now noone seems to have any idea.

Offline Golden-Death

  • Hero Member
  • *****
  • Posts: 751
  • Karma: 0
  • Honored Lua Scripter
    • BlueFire
Re: Groups, Props, and Tools
« Reply #5 on: May 13, 2007, 10:38:59 PM »
Tried combining some code, untested, see if it works.

Code: [Select]
if not SERVER then return end

local groups = { "superadmin", "admin", "opperator" } --Add your groups here
local models = { "models/Effects/splode.mdl", "crane_frame.mdl" } --All or part of model name.



local function block_build( ply, mdl )
for _, v in pairs( models ) do
if string.find( mdl, v ) then
    for _,v in ipairs( groups ) do
        if ply:IsUserGroup( v ) then
            return
        end
    end
end
    ULib.tsay( ply, "You are not allowed to spawn this prop." )
    return false
end
end


Offline spbogie

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 456
  • Karma: 41
Re: Groups, Props, and Tools
« Reply #6 on: May 14, 2007, 01:02:43 PM »
GD you forgot your hook.
I have not failed. I've just found 10,000 ways that won't work. - Thomas A. Edison
I reject your reality and substitute my own. - Adam Savage

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Groups, Props, and Tools
« Reply #7 on: May 14, 2007, 03:45:07 PM »
GD you forgot your hook.

What? He's a pirate? Oh. Fisherman perhaps?
:P
* JamminR gives benefit of doubt and hopes that perhaps GD is leaving some code vague, and hoping that Avien will learn and place in some on his own.

In all honesty, Done right, I could really see a decent release module for ULib coming out of this.
The idea of combining did come to mind when I was making the 'Code Bits' posts.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Avien

  • Full Member
  • ***
  • Posts: 168
  • Karma: 4
Re: Groups, Props, and Tools
« Reply #8 on: May 14, 2007, 05:32:33 PM »
Hopefully something like this will work in the future.  I would try this new code by GoldenDeath, but i am unsure how to put in the server and have it get called, plus someone said it is missing hooks.  Isn't it operator, not opperator?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Groups, Props, and Tools
« Reply #9 on: May 14, 2007, 06:17:15 PM »
Avien.
Re: Missing hooks.
Think about it. Seriously.
Look at the code you posted.
Look at the code GD posted.
Then, look at the BIG CLUE that Spbogie said is missing.
Notice any key lua words missing from the first that aren't in the second?

You've been asking us to make it for you since you asked for 'help'.
If you'd placed your request in the suggestion forum, and left it there, we probably wouldn't have gone this far.
However, you asked for help. I moved the forum to developers corner.
We like helping. We like developing.
But, I don't think we're going to make it THAT easy on you.
I think most of us have gone farther than normal.

You're not dumb. You had a good idea.
Now, think about it, and learn to do it yourself. :)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Avien

  • Full Member
  • ***
  • Posts: 168
  • Karma: 4
Re: Groups, Props, and Tools
« Reply #10 on: May 14, 2007, 06:48:03 PM »
Alright fine.  I start to use my brain a little.  I applicate all that you guys have done, don't get me wrong.  I get in a mood when i get home after fixing a game server all day, i just get tired of working.  I will start to work on it, and hopefully learn lua while i am at it.  Thanks for your help guys, i mean it.

Offline Golden-Death

  • Hero Member
  • *****
  • Posts: 751
  • Karma: 0
  • Honored Lua Scripter
    • BlueFire
Re: Groups, Props, and Tools
« Reply #11 on: May 14, 2007, 09:13:17 PM »
Ok, here you go, tested.

Also made it come with a cvar you can use to turn it on and off, gd_propblock. Set to 1 for on, 0 for off.

Code: [Select]
--Prop Blocker by Golden-Death--


local groups = { "superadmin", "admin" } --These groups here are allowed to spawn anything, defined in gmod/settings/users.txt
local models = { ""} --All or part of model name that is to be banned



local function block_build( ply, mdl )
if GetConVarString("gd_propblock") == "0" then return; end
for _, v in pairs( models ) do
if string.find( mdl, v ) then
    for _,v in ipairs( groups ) do
        if ply:IsUserGroup( v ) then
            return
        end
    end
    ULib.tsay( ply, "Non-admins are not allowed to spawn this prop. ("..mdl..")." )
    return false
end
    end
end


hook.Add( "PlayerSpawnProp", "block_prop", block_build )
ULib.convar("gd_propblock", 1, "1 = Prop Block On, 0 = Prop Block Off", ULib.ACCESS_ADMIN)


Offline Avien

  • Full Member
  • ***
  • Posts: 168
  • Karma: 4
Re: Groups, Props, and Tools
« Reply #12 on: May 15, 2007, 02:04:04 PM »
I am assuming we just put into a .lua and place that file in garrysmod/lua/includes/modules/?
« Last Edit: May 15, 2007, 02:06:46 PM by Avien »

Offline Golden-Death

  • Hero Member
  • *****
  • Posts: 751
  • Karma: 0
  • Honored Lua Scripter
    • BlueFire
Re: Groups, Props, and Tools
« Reply #13 on: May 15, 2007, 03:17:38 PM »
addons/ulib/lua/ulib/modules or something to that effect, i dont remember exactly :P


Offline Avien

  • Full Member
  • ***
  • Posts: 168
  • Karma: 4
Re: Groups, Props, and Tools
« Reply #14 on: May 16, 2007, 03:44:04 PM »
Well i added it to where i said earlier and to the lua/ulib/modules but now i get an error when i start the server:


This server is running ULib version 2.04.
-- Error running file ------------------------------------
- File: ULib/modules/blocker.lua
- ULib/modules/blocker.lua:26: attempt to call field 'convar' (a nil value)
----------------------------------------------------------
ULX version 3.10 loaded.

Thought you should know.