General > Developers Corner

Custom Prop limits by group

(1/2) > >>

strategos:
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: ---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
--- End code ---

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

Stickly Man!:
I believe you can do this by replacing

--- Code: ---if ply:IsAdmin() then
--- End code ---
with:

--- Code: ---if ply:IsAdmin() or ply:IsUserGroup("respected") then
--- End code ---

strategos:
What would I change the function and hook to to convert is to props?


--- Code: ---function PlayerSpawnNPC( ply, npc_type, npc_weapon )
--- End code ---

JamminR:
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.

strategos:
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?

Navigation

[0] Message Index

[#] Next page

Go to full version