Dorkslayz Mini Scripts #1 - Custom Spawn Points

Every week, ill release a new Mini Script, whether it be in the form of a Serverside/Gamemode script or a Singleplayer Script.

This week im releasing a Custom Spawn Point Script, This will allow you to define points (all over the map!) for your players to spawn. At the moment it only supports up to 10 Spawn Points but can be easily modified to have more.

All install instructions are in the zip file, its not hard to miss.

This is a gamemode script and ive tested it on sandbox and it works fine; I dont know about any other gamemode though.


If you have any suggestions, bugs or questions - Let me know.

Great to see a good coder releasing free scripts for the community :slight_smile:

I wouldnt call myself a good coder.

It’s always nice seeing people try accomplishing and learning to code lua. I’m not near being good, but I desided to try and clean the code a bit. And I hope you’ll let me post it here, so you can learn from it. (;

So, do you give me permission to post it here?

Go ahead.

I also added some comments, which I hope will explain the stuff I did a bit. It’s also tested on Sandbox, and works.

– cspawn.lua –

– Dorkslayz MiniScripts - Custom Spawn

include( ‘cspawn_config.lua’ )

function SpawnEnt( )
for _, v in pairs( Spawns ) do – Instead of having lots of those, which are under us, lets loop through the spawns instead.
local LocalSpawns = ents.Create( “info_player_cspawn” ) – We’ll create the ent
LocalSpawns:SetPos( v ) – Now we’ll use the v from the table “Spawns” which is in cspawn_config
LocalSpawns:Spawn( ) – Spawn it
LocalSpawns:Activate( ) – Activate it
hook.Add( “InitPostEntity”, “MapSpawn”, SpawnEnt )

function PlayerSpawning( pl ) – I personally never like to hook anything to GM as I usually use hook.Add

local LocalSpawns = { }
LocalSpawns = ents.FindByClass( “info_player_cspawn” )

if ( table.Count( LocalSpawns ) > 0 ) then return table.Random( LocalSpawns ) end

hook.Add( “PlayerSelectSpawn”, “SpawnSelection”, PlayerSpawning )

– cspawn_config.lua –

– Dorkslayz MiniScripts - Custom Spawn Config

– These are the spawn point positions; type getpos in console to get your player position.

Spawns = {}

Spawns[1] = Vector( -3055.968750, 124.272644, 208.031250 )
Spawns[2] = Vector( -3055.968750, 124.272644, 208.031250 )
Spawns[3] = Vector( -3055.968750, 124.272644, 208.031250 )
Spawns[4] = Vector( -3055.968750, 124.272644, 208.031250 )
Spawns[5] = Vector( -3055.968750, 124.272644, 208.031250 )
Spawns[6] = Vector( -3055.968750, 124.272644, 208.031250 )
Spawns[7] = Vector( -3055.968750, 124.272644, 208.031250 )
Spawns[8] = Vector( -3055.968750, 124.272644, 208.031250 )
Spawns[9] = Vector( -3055.968750, 124.272644, 208.031250 )
Spawns[10] = Vector( -3055.968750, 124.272644, 208.031250 )

I think it’d be better if they weren’t manual added spots like that, and the custom spawn points were stored somewhere so you can change them dynamically.

Ie, in a txt file or on a sql database.

Yeah, that’s also possible. So you can like type “savespawn” and it’d append to a txt file, which you could string.Explode afterwards to add them.

But I’m sure he’ll get into it sometimes.

Ill update the OP with your code Persious and ill add come concommands only available to superadmins.

EDIT - Updated it to Persious’s code, however I wont add concommands due to the possibility of it not being suitable to some users and some security issues.

Do whatever you want, hopefully it helped you. There’s still other way easier ways than mine, but I hope you got a point of a loop tho, and how it works (;

Yeah, thanks.

Sometimes I dont code the optimal way.

if you make them correctly then they don’t cause “security issues”

But to prevent security issues, you got to learn (;

Whats with all the dumb ratings the OP got? Am i missing something?

he’s not the most popular fellow in the Lua section

He uses SethHack and likes to devnull servers, garry permabanned him once.

“Hate is too great a burden to bear. It injures the hater more than it injures the hated.”

I’ve got nothing against him personally, until he does something against me. I will gladly help him no matter what, still tho I’ve also read about him using SethHack which I see no reason to use, which only points to a immature way of gaming.

That’s a dumb-founded assumption that everybody who own’s a copy of sethhack uses it and owns devnull.

I haven’t injected it for months and I dont own devnull.

[editline]18th February 2012[/editline]

Because people are too immature to actually use the rating system properly and rate a user on that post, not on their history or their other posts.

It might be because you half-arsed the script.