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
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:
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: