Author Topic: UnoLimited - No spawn limits for Admins or SuperAdmins  (Read 101784 times)

0 Members and 1 Guest are viewing this topic.

Offline Cyberuben

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: UnoLimited - No spawn limits for Admins or SuperAdmins
« Reply #105 on: July 24, 2011, 03:27:07 AM »
This is what the code contains now, before I made this post
Code: [Select]
if not ULib then Msg( "\n ** UnoLimited v2+ REQUIRES ULib v2.4+ .. Aborting\n\n") return else
Msg( "[ULIB]*** UnoLimited v2.1 Ready! *******\n")
local UNL = { }
-- ---------------------------------------------------------
--   Name: UnoLimited
--   Author: Garry 98.50% - Megiddo .75% - JamminR .75% - A "Team Ulysses idea
--   Desc: Allows defined groups to spawn past the sbox_max limits.
--   v1 release to Ulysses - v1.1 - Fixed sents (evil garry)
-- v2 Added group control - ULib 2.4+ required
-- ---------------------------------------------------------
-- The numbers are a percentage and will be multiplied to the actual sbox limit.
-- Range is 0 (0 percent) to 2 (200 percent). Setting a group to 0 will limit that group to nothing.
-- Example - Server has "sbox_maxprops 400" limit. .5 percent of that is 200 props.
-- Any group = .5 will have a 200 prop limit. However, 1.5 would give them 600
-- NOTE!!! - Any decimals will be rounded DOWN to nearest whole number.
-- If you allow sbox 1 of something...any multiplier below 1 will set that groups limit to 0. Any not 2 will be 1.
-- All groups not specified get 'standard' limit set in your server.cfg.
-- Any group set to -1 becomes unlimited
-- ==================
-- Edit the following table. Add groups as necessary. Add comma at end of previous line if additional added.

UNL.groups = {
owner = -1,
superadmin = -1,
admin = 2,
operator = 1.5
}


-- ------- Please ask for Team Ulysses assistance editing below this line ----------------

local function GetUnoLimit ( ply, str )
local gmulti = UNL.groups[ ply:GetUserGroup() ]
local a

if gmulti then
if gmulti == -1 then return gmulti end
if ( gmulti < 0 || gmulti > 2 ) then
ULib.error( string.format( "* UNoLimited - Group %q multiplier %q out of range(0 to 2)...setting to 1", ply:GetUserGroup(), gmulti ) )
gmulti = 1
end
a = math.floor( ( gmulti * server_settings.Int( "sbox_max"..str, 0 ) ) )
else
a = server_settings.Int( "sbox_max"..str, 0 )
end
return a
end


local function LimitReachedProcess( ply, str )

-- Always allow in single player
if (SinglePlayer()) then return true end

local c = GetUnoLimit ( ply, str )

-- Always allow if multiplier is -1
if c == -1 then return true end

if ( ply:GetCount( str ) < c || c < 0 ) then return true end

ply:LimitHit( str )
return false

end

local function init()
/*---------------------------------------------------------
   Name: gamemode:PlayerSpawnRagdoll( ply, model )
   Desc: Return true if it's allowed
---------------------------------------------------------*/
function GAMEMODE:PlayerSpawnRagdoll( ply, model )

return LimitReachedProcess( ply, "ragdolls" )

end


/*---------------------------------------------------------
   Name: gamemode:PlayerSpawnProp( ply, model )
   Desc: Return true if it's allowed
---------------------------------------------------------*/
function GAMEMODE:PlayerSpawnProp( ply, model )

return LimitReachedProcess( ply, "props" )

end


/*---------------------------------------------------------
   Name: gamemode:PlayerSpawnEffect( ply, model )
   Desc: Return true if it's allowed
---------------------------------------------------------*/
function GAMEMODE:PlayerSpawnEffect( ply, model )

return LimitReachedProcess( ply, "effects" )

end

/*---------------------------------------------------------
   Name: sents
   Desc: Return true if it's allowed
---------------------------------------------------------*/
function GAMEMODE:PlayerSpawnEffect( ply, name )

return LimitReachedProcess( ply, "sents" )

end

/*---------------------------------------------------------
   Name: gamemode:PlayerSpawnVehicle( ply, model, vname, vtable )
   Desc: Return true if it's allowed
---------------------------------------------------------*/
function GAMEMODE:PlayerSpawnVehicle( ply, model, vname, vtable )

return LimitReachedProcess( ply, "vehicles" )

end

/*---------------------------------------------------------
   Name: gamemode:PlayerSpawnNPC( ply, npc_type )
   Desc: Return true if player is allowed to spawn the NPC
---------------------------------------------------------*/
function GAMEMODE:PlayerSpawnNPC( ply, npc_type, equipment )

return LimitReachedProcess( ply, "npcs" )

end

local meta = FindMetaTable( "Player" )
// Return if there's nothing to add on to
if (!meta) then return end

function meta:CheckLimit( str )

// No limits in single player
if (SinglePlayer()) then return true end

local c = GetUnoLimit ( self, str )


if ( c < 0 ) then return true end
if ( self:GetCount( str ) > c-1 ) then self:LimitHit( str ) return false end

return true

end

end

hook.Add( "Initialize", "LimitInitilize", init )

end

But this doesn't seem to work.
If you might want to try what happens, add me to Steam, steam://friends/add/cyberuben (copy link and paste in browser), and then you can see what happens yourself.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: UnoLimited - No spawn limits for Admins or SuperAdmins
« Reply #106 on: July 24, 2011, 08:35:25 AM »
In my previous post I gave specific code for you to add.
You've apparently edited on your own and now have function gamemode:PlayerSpawnEffect twice.
Don't add your own, add what example I gave.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: UnoLimited - No spawn limits for Admins or SuperAdmins
« Reply #107 on: July 24, 2011, 03:34:37 PM »
All, please don't PM me. So far, my inbox is full of questions that will help everyone. I dare say the only reason I've ever gotten a private that should have been private was to research what the author believed to be a possible ULX exploit (it wasn't, turned out to be the game mode they were using)

A concerned citizen writes;
hi im currently working on making a server am using Exsto for admin control and so on , i was wondering if UnoLimited 1.1 would work with the current admin mod so i can set limits for superadmins and myself the owner. please pm me or send me an email with your answer. thanks in advance!

First; Our condolences that you are using another admin mod. Your choice, but still, our condolences :)

Second; UnoLimited v1 uses Garry's IsSuperadmin and IsAdmin for its group checks.
These are standard functions written for every developer to use for any mod/code.
If Exsto's owner isn't detected by either one of those functions, then no, it won't detect the owner group. As for Exsto's admin group, as long as it is a actual group name and not a team name, then yes, it will detect admin.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Glider

  • Newbie
  • *
  • Posts: 6
  • Karma: -1
Re: UnoLimited - No spawn limits for Admins or SuperAdmins
« Reply #108 on: November 13, 2012, 07:35:30 AM »
This comes up when I try to use it on my server:

[ERROR] addons/unolimited_v2/lua/ulib/modules/unolimited.lua:52: attempt to call global 'SinglePlayer' (a nil value)
  1. Call - addons/unolimited_v2/lua/ulib/modules/unolimited.lua:52
   2. Spawn_NPC - gamemodes/sandbox/gamemode/commands.lua:406
    3. unknown - gamemodes/sandbox/gamemode/commands.lua:454
     4. unknown - lua/includes/modules/concommand.lua:69

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: UnoLimited - No spawn limits for Admins or SuperAdmins
« Reply #109 on: November 13, 2012, 01:57:04 PM »
Someone else is more than welcome to convert this to Gmod13.
I won't be in the foreseeable future.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: UnoLimited - No spawn limits for Admins or SuperAdmins
« Reply #110 on: October 13, 2013, 09:09:22 AM »
NOTE - NexBR converted to GM13 and (at the time) modern ULib format.
Please see update in our releases section. I split the topic from his post here to a new thread.
http://forums.ulyssesmod.net/index.php/topic,6720.0.html

Thanks Nexbr!
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming