Author Topic: Custom Prop limits by group  (Read 8802 times)

0 Members and 2 Guests are viewing this topic.

Offline strategos

  • Jr. Member
  • **
  • Posts: 66
  • Karma: 2
  • I wanna be the guy
    • Community
Custom Prop limits by group
« on: September 02, 2011, 10:54:59 AM »
After being trolled off of facepunch way too many times, I decided to come here to ask my questions about ULX customizations. Below is my question:

Are ulx usergroups added into lua. For instance instead of "Ply:IsAdmin()", would "Ply:IsRespected()" work if a ulx usergroup's name was respected? I'm trying to convert this script into setting prop limits by ULX usergroup. Basically, how would I convert it to ULX usergroups to restrict props?

Currently, I'm using this script to regulate NPCs. I'm kinda a noob at lua :)



Code: [Select]
if SERVER then

local npcadmin = 20 --ADMIN NPC LIMIT
local npcelse = 0 --USER NPC LIMIT

function PlayerSpawnNPC( ply, npc_type, npc_weapon ) -- Sets default data for a player when he joins.
local gnpcs = ply:GetCount("npcs") + 1
local gmaxnpcs = 0
if ply:IsAdmin() then
gmaxnpcs = npcadmin
else
gmaxnpcs = npcelse
end
if gnpcs > gmaxnpcs then
local Text = "You have reached the NPC limit for your usergroup."
ply:SendLua("GAMEMODE:AddNotify(\""..Text.."\", NOTIFY_GENERIC, 5); surface.PlaySound(\"npc/turret_floor/active.wav\")")
return false
end
end
hook.Add( "PlayerSpawnNPC", "mppgspawnnpchook", PlayerSpawnNPC );

end

Anyone know of a way to convert it so that respected would get more props?
Thanks!

Offline Stickly Man!

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 1270
  • Karma: 164
  • What even IS software anymore?
    • XGUI
Re: Custom Prop limits by group
« Reply #1 on: September 02, 2011, 11:28:27 AM »
I believe you can do this by replacing
Code: [Select]
if ply:IsAdmin() thenwith:
Code: [Select]
if ply:IsAdmin() or ply:IsUserGroup("respected") then
Join our Team Ulysses community discord! https://discord.gg/gR4Uye6

Offline strategos

  • Jr. Member
  • **
  • Posts: 66
  • Karma: 2
  • I wanna be the guy
    • Community
Re: Custom Prop limits by group
« Reply #2 on: September 02, 2011, 11:56:41 AM »
What would I change the function and hook to to convert is to props?

Code: [Select]
function PlayerSpawnNPC( ply, npc_type, npc_weapon )
« Last Edit: September 02, 2011, 05:44:35 PM by strategos »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Custom Prop limits by group
« Reply #3 on: September 02, 2011, 02:09:12 PM »
Joking!
OMG! WHAT NOOB QUESTION!
(Feel at home just like FP now?)

Check out (old but still works?/still find instructional) UNoLimited within our release area. v2+ with ULib support would show such a way to check each standard spawn item.
URestrict also supposedly used some of the same ideas that UNoLimited did (but, was intended to be capable of more)
And, I've not used it as I've not run a server in a long time, more up to date, URS BETA in releases I think also can control spawns of items based on groups (I may be wrong on that)
Looking at the code of any one of these would show examples of how to go about spawn monitoring and prevention (or, additional allowance, in the case of some) based on group.

« Last Edit: September 02, 2011, 02:11:00 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline strategos

  • Jr. Member
  • **
  • Posts: 66
  • Karma: 2
  • I wanna be the guy
    • Community
Re: Custom Prop limits by group
« Reply #4 on: September 03, 2011, 11:16:41 AM »
Wouldn't http://forums.ulyssesmod.net/index.php/topic,5269.0.html be better? And would the tool restirction, even if I use FPP instead, be compatible with DarkRP?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Custom Prop limits by group
« Reply #5 on: September 03, 2011, 04:57:10 PM »
URS Beta was mentioned in my reply. :)
As for better, it all depends on what you are trying to do.
If you actually want to USE the releases, yes, URS Beta would probably be better.
If you actually want to look at and LEARN from the releases, I mentioned UNoLimited first because, well, that is ALL it does is control how items are spawned. It would have less code, less possibility of confusion when learning from it.
The other two, including current URS Beta, actually control more than just spawning items.

As for compatibility, sorry, no idea. DarkRP has been a mess of code for years. Though (at least) a half-way decent developer took over some of its development in the past few years, I feel it's poor origination and development in the beginnings ruined it for anyone afterwards, current developer included.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline strategos

  • Jr. Member
  • **
  • Posts: 66
  • Karma: 2
  • I wanna be the guy
    • Community
Re: Custom Prop limits by group
« Reply #6 on: September 03, 2011, 05:23:17 PM »
Ok I tested it and so far, it seems to work great!  :)
As far as learning to code lua, I would probably want to try it on less important things because an administration system should always be very versatile and powerful. Thanks for helping!