• Print

Author Topic: no limits for admins.  (Read 10074 times)

0 Members and 1 Guest are viewing this topic.

Offline lyoko

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
no limits for admins.
« on: April 14, 2008, 09:42:39 pm »
i think admins should have no limit to spawn stuff. like npc's sent's props.
with the all sbox_Max cvars.
thanks.

Offline lyoko

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: no limits for admins.
« Reply #1 on: April 17, 2008, 01:41:39 am »
Please?

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: no limits for admins.
« Reply #2 on: April 17, 2008, 02:00:59 pm »
This is hard coded into Garrysmod. The only way 'around' this would be to set the sbox_limit to like.. 9999 and have a separate module that told clients they couldn't spawn after a certain limit unless they were admins. then you get into the stacker and duplicator issues.

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: no limits for admins.
« Reply #3 on: April 17, 2008, 02:21:35 pm »
This is part of the functionality of one of my half-finished projects. Here's the core of what you need, I think. Untested, so let me know if there's any problems with it. It should work fine with stacker and duplicator, and limits are reported correctly to all other clients.

Code: Lua
  1. local function LimitReachedProcess( ply, str )
  2.  
  3.         // Always allow in single player
  4.         if (SinglePlayer()) then return true end
  5.  
  6.         local c = server_settings.Int( "sbox_max"..str, 0 )
  7.  
  8.         if ply:Admin() or ply:IsSuperAdmin() then
  9.                 return true
  10.         end
  11.  
  12.         if ( ply:GetCount( str ) < c || c < 0 ) then return true end
  13.        
  14.         ply:LimitHit( str )
  15.         return false
  16.  
  17. end
  18.  
  19. local function init()
  20. /*---------------------------------------------------------
  21.    Name: gamemode:PlayerSpawnRagdoll( ply, model )
  22.    Desc: Return true if it's allowed
  23. ---------------------------------------------------------*/
  24. function GAMEMODE:PlayerSpawnRagdoll( ply, model )
  25.  
  26.         return LimitReachedProcess( ply, "ragdolls" )
  27.  
  28. end
  29.  
  30.  
  31. /*---------------------------------------------------------
  32.   Name: gamemode:PlayerSpawnProp( ply, model )
  33.   Desc: Return true if it's allowed
  34. ---------------------------------------------------------*/
  35. function GAMEMODE:PlayerSpawnProp( ply, model )
  36.  
  37.         return LimitReachedProcess( ply, "props" )
  38.  
  39. end
  40.  
  41.  
  42. /*---------------------------------------------------------
  43.    Name: gamemode:PlayerSpawnEffect( ply, model )
  44.    Desc: Return true if it's allowed
  45. ---------------------------------------------------------*/
  46. function GAMEMODE:PlayerSpawnEffect( ply, model )
  47.  
  48.         return LimitReachedProcess( ply, "effects" )
  49.  
  50. end
  51.  
  52. /*---------------------------------------------------------
  53.   Name: gamemode:PlayerSpawnVehicle( ply )
  54.   Desc: Return true if it's allowed
  55. ---------------------------------------------------------*/
  56. function GAMEMODE:PlayerSpawnVehicle( ply )
  57.  
  58.         return LimitReachedProcess( ply, "vehicles" )
  59.        
  60. end
  61.  
  62. /*---------------------------------------------------------
  63.    Name: gamemode:PlayerSpawnSENT( ply, name )
  64.    Desc: Return true if player is allowed to spawn the SENT
  65. ---------------------------------------------------------*/
  66. function GAMEMODE:PlayerSpawnSENT( ply, name )
  67.                
  68.         return LimitReachedProcess( ply, "sents" )     
  69.        
  70. end
  71.  
  72. /*---------------------------------------------------------
  73.    Name: gamemode:PlayerSpawnNPC( ply, npc_type )
  74.    Desc: Return true if player is allowed to spawn the NPC
  75. ---------------------------------------------------------*/
  76. function GAMEMODE:PlayerSpawnNPC( ply, npc_type, equipment )
  77.  
  78.         return LimitReachedProcess( ply, "npcs" )      
  79.        
  80. end
  81.  
  82. local meta = FindMetaTable( "Player" )
  83. // Return if there's nothing to add on to
  84. if (!meta) then return end
  85.  
  86. function meta:CheckLimit( str )
  87.  
  88.         // No limits in single player
  89.         if (SinglePlayer()) then return true end
  90.  
  91.         local c = server_settings.Int( "sbox_max"..str, 0 )
  92.        
  93.         if self:IsAdmin() or self:IsSuperAdmin() then
  94.                 return true
  95.         end
  96.  
  97.         if ( c < 0 ) then return true end
  98.         if ( self:GetCount( str ) > c-1 ) then self:LimitHit( str ) return false end
  99.  
  100.         return true
  101.  
  102. end
  103.  
  104. end
  105.  
  106. hook.Add( "Initialize", "LimitInitilize", init )

Sorry MrPresident :P
« Last Edit: April 17, 2008, 02:23:13 pm by Megiddo »
Experiencing God's grace one day at a time.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: no limits for admins.
« Reply #4 on: April 17, 2008, 10:51:41 pm »
Don't be sorry. You are rewritting the gamemode processes which makes it perfectly possible. =) I just never thought of that, I was thinking of the way I was doing it with the hooks.

Offline lyoko

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: no limits for admins.
« Reply #5 on: April 18, 2008, 01:11:40 am »
Thanks. i'll test it.

Offline Avien

  • Full Member
  • ***
  • Posts: 168
  • Karma: 4
Re: no limits for admins.
« Reply #6 on: April 18, 2008, 04:04:19 pm »
I thought garry removed the ability to limit sents.  I wish he hadn't cause those damned bouncy balls lag like a mother.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: no limits for admins.
« Reply #7 on: April 18, 2008, 04:11:49 pm »
I thought garry removed the ability to limit sents.  I wish he hadn't cause those damned bouncy balls lag like a mother.

Garry did. As Megiddo said, that's an old project, though I think still a very valid one.
Either way, who knows, Garry's fickle at times, especially when hundreds of people yell out in unison "WTH? Not USED??"
Perhaps Garry will put it back in.
"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: no limits for admins.
« Reply #8 on: April 19, 2008, 01:13:41 pm »
Well i am assuming we just take Meg's code and put it in a lua file and stick it is lua/autorun/?

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: no limits for admins.
« Reply #9 on: April 19, 2008, 04:07:17 pm »
Well i am assuming we just take Meg's code and put it in a lua file and stick it is lua/autorun/?

Sure, that'll work.
Experiencing God's grace one day at a time.

Offline blacksythe

  • Newbie
  • *
  • Posts: 38
  • Karma: -1
Re: no limits for admins.
« Reply #10 on: April 19, 2008, 04:38:40 pm »
Either way, who knows, Garry's fickle at times,"
Perhaps Garry will put it back in.

Fickle is an understatement cough linux cough

Offline Avien

  • Full Member
  • ***
  • Posts: 168
  • Karma: 4
Re: no limits for admins.
« Reply #11 on: April 25, 2008, 06:14:04 pm »
Been away for awhile, so sorry for the late post.  Will this script actually limit props, and if so how do I set the max limit for any one thing?  Such as 75 for props, 6 for sents, etc...

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: no limits for admins.
« Reply #12 on: April 25, 2008, 06:17:36 pm »
Avien, No worries. Welcome back.

You use normal sbox_max<blah> settings on your server.
This just throws in extra code to Garry's function to allow for Superadmin and Admin group to go past those limits.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

  • Print