Hello, I need help to create a custom spanw ...

Hello, I need help to create a custom player example spanw: two team one has to give spawn in a certain place and another on another as if it were set the axes X, Y, Z, something I think help please

or if the map has certain spawn already put this in your shared.lua file for team.SetSpawnPoint


function GM:CreateTeams()
	TEAM_BLUE = 1
	team.SetUp( TEAM_BLUE, "Blue", Color( 0, 0, 255 ) )
	team.SetSpawnPoint( TEAM_BLUE, "info_player_counterterrorist" )
	
	TEAM_RED = 2
	team.SetUp( TEAM_RED, "Red", Color( 255, 0, 0 ) )
	team.SetSpawnPoint( TEAM_RED, "info_player_terrorist" )
end

but the DarkRp is not the way I think is that I wanted to define them at coordinates X, Y, Z

But DarkRP has multiple teams, do you want different spawn for every Team?

Yes, this same I want to make a spawn for multiple teams and also by reason of being multiple maps that do not have to edit

/setspawn team

-snip- Bannana Lord’s ^^^^

but I’m not using darkrp is that tou creating a gamemode propio and wanted to know how to create multiple spawn teams understand?

Try it, i’m not sure if it will work

Use a table, then have the table select out where they spawn like:
[lua]

copspawn = {}
copspawn[1] = “Numbershere,morenumbers,anothersetofnumbers”
copspawn[2] = “Numbershere,morenumbers,anothersetofnumbers”
copspawn[3] = “Numbershere,morenumbers,anothersetofnumbers”
copspawn[4] = “Numbershere,morenumbers,anothersetofnumbers”

function CopSpawn(pl)
	if pl:Team() == teamnumberhere
		pl:SetPos(Vector(table.Random(copspawn)))
	end
end
hook.Add("PlayerSpawn","CopSpawn",CopSpawn)

[/lua]

Can you explain to me how this code works you me mando, why will have multiple teams and wanted to know how Faso this code to spawn on each team in a place that’ll set via coordinates, X, Y, Z "? :slight_smile:

It’s quite simple really , you just replace the “numbershere” with numbers , example

copspawn = {}
copspawn[1] = “20,60,90”
copspawn[2] = “90,60,20”
copspawn[3] = “13,3,7”
copspawn[4] = “8,00,8”

and the copspawn function will choose a random location out of those and spawn your player there. Now inside the function you actually have to specify the team number. That is usually in your gamemodes Shared.lua file.

And if it is more of a team where I define the id of the team to spawn the 5 teams each in each place?

you just add a new table and do a elseif.

example :

[lua]
copspawn = {}
copspawn[1] = “Numbershere,morenumbers,anothersetofnumbers”
copspawn[2] = “Numbershere,morenumbers,anothersetofnumbers”
copspawn[3] = “Numbershere,morenumbers,anothersetofnumbers”
copspawn[4] = “Numbershere,morenumbers,anothersetofnumbers”

team2 = {}
team2[1] = “Numbershere,morenumbers,anothersetofnumbers”
team2[2] = “Numbershere,morenumbers,anothersetofnumbers”
team2[3] = “Numbershere,morenumbers,anothersetofnumbers”
team2[4] = “Numbershere,morenumbers,anothersetofnumbers”

function CopSpawn(pl)
    if pl:Team() == 1
        pl:SetPos(Vector(table.Random(copspawn)))
    elseif  pl:Team() == 2
        pl:SetPos(Vector(table.Random(team2)))
    end
end
hook.Add("PlayerSpawn","CopSpawn",CopSpawn)

[/lua]

Thanks

[lua]local Spawns = {}

function AddSpawn(team,x,y,z)
if !x then return false end
if (!y and !z) and (type(x) == “vector”) then
table.insert(Spawns,{team,x.x,x.y,x.z})
elseif (type(x) == “number” and type(y) == “number” and type(z) == “number”) then
table.insert(Spawns,{team,x,y,z,0})
end
end

AddSpawn(“TEAM_COP”,100,100,100)
AddSpawn(“TEAM_CITIZEN”, Vector(100,100,100))
–AddSpawn(Team,X Vector, Y Vector, Z Vector) or even
–AddSpawn(Text, Vector(X,Y,Z))

hook.Add(“PlayerSpawn”,“PlayerSpawn”, function(ply)
local _Team = ply:Team()
for k,v in pairs(Spawns) do
if string.lower(v[1]) == string.lower(_Team) then
local _Pos = Vector(v[2],v[3],v[4])
ply:SetPos(_Pos)
break
end
end
end)
[/lua]

Give me 30 mins cause im just gonna adapt this to save positions and such.

Edit, Made a few changes, i will write the text saving up tomorrow.

[lua]local TEAM_1 , TEAM_2 = 1 , 2

concommand.Add("_dev_dumppos" , function(p,c,a)
local pos = p:GetPos()
local x , y , z = pos.x,pos.y,pos.z

print("Vector("..x..","..y..","..z.."),")

end )

local spawns = {

TEAM_1 = {

},

TEAM_2 = {

},

}

hook.Add(“PlayerSpawn” , “Some hook name” , function(pl)
pl:SetPos(table.Random(spawns[pl:Team()]))
end )
[/lua]

thanks

I couldn’t make him teleport people to their base with this code you have to do for it to work the cordenas I’ve caught just missing to make it work, please help the faster possible! :slight_smile:

Don’t use science’s, use mine.