ULX spawn command



function ulx.spawn(calling_ply, target_plys)
	local affected_plys = {};
	for k,v in pairs(target_plys) do 
		if !v:Alive() then 
			v:Spawn();
			table.insert(affected_plys, v);
		end;
	end;
	ulx.fancyLogAdmin(calling_ply, "#A воскресил #T", affected_plys);
end;
local spawn = ulx.command("Utility", "ulx spawn", ulx.spawn, "!spawn");
spawn:addParam{type=ULib.cmds.PlayersArg};
spawn:defaultAccess(ULib.ACCESS_ADMIN);
spawn:help("Воскрешает игрока.");


This shit doesn’t work. Help. I did everything as in this topic.

http://puu.sh/8QXPY.png

Are you sure it had no updates/changes to the functions you used since 2012?

I can’t find function to spawn player in official gmod wiki, so i think that you are right. Mb you can help me?

Well, not what I meant, I meant that ULX has changed since then and the functions used to make that command might be outdated.

P.P.S I’m using jailbreak gamemode, and there are such code:



function PLAYER:Spawn()

	local oldhands = self.Player:GetHands();
	if ( IsValid( oldhands ) ) then
		oldhands:Remove();
	end;

	local hands = ents.Create( "gmod_hands" );
	if ( IsValid( hands ) ) then
		hands:DoSetup( self.Player );
		hands:Spawn();
	end;

end;


[editline]18th May 2014[/editline]

No, this command works, but problem in player spawn, because i tried to print message after spawn and it worked.

But it’s spawning hands, not player.
Try changing the gamemode for a while and test it.

It works.

Try adding self:Spawn() to that PLAYER:Spawn() function.
Don’t know if it’ll help (because it sounds like an infinite loop to me), but worth a try.

It doesn’t work.

PLAYER:Spawn is called from GM:PlayerSpawn

[editline]18th May 2014[/editline]

I am pretty sure its the gamemode that is blocking spawning ( is it killing the player? )

Also, you might want to try ply:UnSpectate() before ply:Spawn()

Doesn’t help

Here is a full system to make the player become a spectator when they join; if META_PLAYER:Unassigned( ) is FALSE meaning they’re on a team, it shows how it spawns the player. Spawn is called in PlayerDeathThink, and PlayerSpawn sets the rest up. It may help to look at it: https://dl.dropboxusercontent.com/u/26074909/tutoring/spectating_players_system.lua.html

are you looking for something like this?

[lua]

function ulx.forcerespawn( calling_ply, target_plys )

if GetConVarString("gamemode") == "terrortown" then
	for k, v in pairs( target_plys ) do
		if v:Alive() then
			v:Kill()
			v:SpawnForRound( true )
		else
			v:SpawnForRound( true )			
		end
	end
else
	for k, v in pairs( target_plys ) do
		if v:Alive() then
			v:Kill()
			v:Spawn()
		else
			v:Spawn()
		end
	end
end

ulx.fancyLogAdmin( calling_ply, "#A respawned #T", target_plys )

end
local forcerespawn = ulx.command( “Utility”, “ulx forcerespawn”, ulx.forcerespawn, { “!forcerespawn”, “!frespawn”, “!fspawn”},true )
forcerespawn:addParam{ type=ULib.cmds.PlayersArg }
forcerespawn:defaultAccess( ULib.ACCESS_ADMIN )
forcerespawn:help( “Force-respawn a player.” )

[/lua]