Liberty Unleashed

Scripting => Scripting Discussion => Topic started by: xxxMDjxxx on October 10, 2011, 05:00:42 pm

Title: Spawn point by player name?
Post by: xxxMDjxxx on October 10, 2011, 05:00:42 pm
How could i make a player always spawn at a certain coordinate?

Lets say there is a player with a name "testplayer123"

So when this player joins the server or dies, he will spawn at a certain coordinate?

Other players will spawn at default spawnpoints...
Title: Re: Spawn point by player name?
Post by: Thijn on October 10, 2011, 07:50:02 pm
You can check the player name with player.Name;
So on spawn you could do this:
Code: [Select]
function onPlayerSpawn( player, spawn )
{
if ( player.Name == "testplayer123" ) player.Pos = Vector( x, y, z );
}
Title: Re: Spawn point by player name?
Post by: xxxMDjxxx on October 15, 2011, 02:35:17 pm
You can check the player name with player.Name;
So on spawn you could do this:
Code: [Select]
function onPlayerSpawn( player, spawn )
{
if ( player.Name == "testplayer123" ) player.Pos = Vector( x, y, z );
}


The code is not working...

Code: [Select]
function onPlayerSpawn( player, spawn )
 if ( player.Name == "xXxMDjxXx" )
 {
  player.Pos = Vector( -812.2, 355.7, 51.32 );
  return 1;
 }

Have i done something wrong?
Title: Re: Spawn point by player name?
Post by: Force on October 15, 2011, 04:31:49 pm
Err yes..

Code: [Select]
function onPlayerSpawn( player, spawn )
{
if ( player.Name.tolower() == "xxxmdjxxx" ) player.Pos = Vector( 0.0, 0.0, 0.0 );
return 1;
}
Title: Re: Spawn point by player name?
Post by: xxxMDjxxx on October 15, 2011, 06:58:33 pm
Err yes..

Code: [Select]
function onPlayerSpawn( player, spawn )
{
if ( player.Name.tolower() == "xxxmdjxxx" ) player.Pos = Vector( 0.0, 0.0, 0.0 );
return 1;
}


hmm, still not working, changed my name to xxxmdjxxx and still nothing.
Title: Re: Spawn point by player name?
Post by: Force on October 15, 2011, 07:01:06 pm
Any errors from the server console?
Title: Re: Spawn point by player name?
Post by: xxxMDjxxx on October 16, 2011, 09:10:03 am
no erors in the console...
Title: Re: Spawn point by player name?
Post by: stormeus on October 16, 2011, 05:34:28 pm
If there are multiple instances of onPlayerSpawn, it likely won't work, so you might want to check that. Same with having onPlayerSpawn in multiple script files.