ULX

Author Topic: Requests - Set Spawn Point and Admin-Only NPC spawn  (Read 3083 times)

0 Members and 1 Guest are viewing this topic.

Offline johnlukeg

  • Newbie
  • *
  • Posts: 27
  • Karma: -1
Requests - Set Spawn Point and Admin-Only NPC spawn
« on: February 02, 2008, 06:14:03 PM »
I think it would be a useful tool in ULX if an Admin could set a new spawn point for an individual (or everyone).  For example - instead of having the ULX jail clogging up a building you could make an unruly person spawn in your own jail cell, or use it to play a game someone has made that would benefit from a new spawn point.

Secondly

This is probably hard to do or you would have done it already, but it would be very helpful if you could set a different value for admin NPC spawns versus client NPC spawns (Or handle it some other way)  so that admins could spawn NPCs without worrying about clients taking advantage of quick value changes.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Requests - Set Spawn Point and Admin-Only NPC spawn
« Reply #1 on: February 02, 2008, 06:45:21 PM »
the second part is not hard to do, I've already done it. I will give you a version of my script that will have a seperate npc limit for users and admins.
Give me 5 minutes.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Requests - Set Spawn Point and Admin-Only NPC spawn
« Reply #2 on: February 02, 2008, 07:04:23 PM »
Here you go..

Take this..

Code: [Select]
if SERVER then

local npcadmin = 10 --ADMIN NPC LIMIT
local npcelse = 2 --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

And put it in a file called npclimit.lua in Addons\ULib\lua\ULib\modules

The 2 lines at the top are where you set the limits.. it's pretty well documented there =)
Also, make sure your server npc limit is set to 1 more than your admin limit. (sbox_maxnpcs <value>)

Offline johnlukeg

  • Newbie
  • *
  • Posts: 27
  • Karma: -1
Re: Requests - Set Spawn Point and Admin-Only NPC spawn
« Reply #3 on: February 02, 2008, 08:55:53 PM »
Thanks for that, I'll go and test that out.