Personal tools


From JC2-MP Documentation

< Lua
Jump to: navigation, search
Name    PlayerSpawn
Arguments (in table)    Player player
Return option    Return false to block default spawn


Fired when a player spawns. Players can spawn after they join and after they die.

By default, players spawn at the default position set in config.lua. If you want to provide your own spawn position, you must return false. If you return false but don't set their position, they respawn at the same place they died.


function Foo(args)
	print(args.player:GetName().." spawned at "..tostring(args.player:GetPosition()))
Events:Subscribe("PlayerSpawn", Foo)

Overriding the default spawn

function Foo(args)
	-- Respawn them 2km above Origin Town.
	args.player:SetPosition(Vector3(0, 2200, 0))
	return false
Events:Subscribe("PlayerSpawn", Foo)