ID:1500541
 
(See the best response by Pirion.)
Problem description: I'm honestly unsure what to call this so I called it a player type.

So I have multiple datums for players. player 1, 2,3 etc. This is an example, this could be varied from races to class type really. I want to know after the player has chosen what class/race/type, how I then assign the datum to the player. I did try client.mob = /player1/, as a tester but I kind of guessed it would be wrong from writing it.

I'm not the best at explanations, in fact I'm terrible. So if you need more information let me know. Example code I tried below.

Code:
mob
Login()
var/X = pick("player1","player2")
if(X == "player1")
//assign player1
newplayer()
..()
proc
newplayer(mob/M)

player1
parent_type = /mob/

newplayer(mob/M)
M<<"Hello world"


player2

player3




Best response
Your client.mob attempt is almost correct.

In order to assign a new client a new mob, you need to create a new instance of it, then switch the mob.client (or client.mob) to the new instance. Now in order to create these, you'll need to work with a path.

For Example:
mob/Login()
..()
var/newtype = pick("player1","player2") //these are currently strings
var/newtype_path = text2path("/[newtype]")//now it is a path
var/mob/newtype_mob = new newtype_path(src.loc) //create a new instance of the path and store it
newtype_mob.client = src.client //and now we have the mob, we can switch the client to it.

Now, there are some problems.

Because player1 inherits mob, you've created a loop here. We will call player1.Login() and start the process again. In order to prevent that, you can set world/mob = /mob/something_else and define this behavior under mob/something_else/Login().

Another problem is that we have an extra mob just hanging around in the world, not being useful. As soon as the client connects to the new mob, we can delete it.

Another example:

world/mob = /mob/beforeLogin
mob/beforeLogin/Login()
..()
var/newtype = pick("player1","player2") //these are currently strings
var/newtype_path = text2path("/[newtype]")//now it is a path
var/mob/newtype_mob = new newtype_path(src.loc) //create a new mob and store it
newtype_mob.client = src.client //and switch the client.
del src //deletes the /mob/beforeLogin
Thanks, some really helpful information here. Also never knew mobs worked like that.