ID:2869880
 
Code:
/obj/spawnpoint/player
icon_state = "player"

var/totalspawnpoints = 0
/obj/spawnpoint/player/var/spawnpointid = 0

/obj/spawnpoint/player/New()
if(src.spawnpointid==0)
totalspawnpoints = totalspawnpoints + 1
src.spawnpointid=totalspawnpoints

/mob/lobby_player/verb/
join()
view() << "Joining the Game!"
var/spawnpointid = 0
var/spawnpointidchosen = rand(1,totalspawnpoints)
var/turf/spawnpointidloc = locate(/obj/spawnpoint/player, spawnpointid == spawnpointidchosen)
loc = locate(spawnpointidloc.x, spawnpointidloc.y, spawnpointidloc.z)


Problem description:
i am trying to locate a "/obj/spawnpoint/player" with a certain var called spawnpointid that is equal to spawnpointidchosen. how would i do this?
Check out the tag variable in the reference
obj/location
tag = "location A"

var obj/location/l = locate("location A")


One thing to keep in mind is that object won't be GC'd until the tag variable is cleared or del is used.
can a tag be a number?
In response to Cannibal Hunter
Cannibal Hunter wrote:
can a tag be a number?

You could do

var obj/location/l = locate("location [ID]")
In response to Cannibal Hunter
Cannibal Hunter wrote:
can a tag be a number?

No, but it doesn't matter because tags are text, and converting a number to text is trivial.

/obj/spawnpoint/player
var
global/totalspawnpoints
spawnpointid = 0

New()
if(!spawnpointid)
spawnpointid = ++totalspawnpoints
tag = "playerspawn[spawnpointid]"
..()

/mob/lobby_player/verb/join()
view() << "Joining the Game!"
var/obj/spawnpointidloc = locate("playerspawn[rand(1,totalspawnpoints)]")
loc = locate(spawnpointidloc.x, spawnpointidloc.y, spawnpointidloc.z)
One important thing to be aware of is that a tag will prevent soft deletion by the garbage collector. Probably not relevant to the case of creating a spawn point, but it's worth keeping in mind for anything you might use tags for.

Tags effectively act like putting the object in an internal associative list. The exact same structure is used.