Ulysses
General => Developers Corner => Topic started by: blackfire88 on August 08, 2012, 07:02:46 PM
-
Hey there,
I am coding a gamemode, and i kinda need some help regarding spectating.
I have two problems.
1. When I use ply:Spectate( OBS_MODE_ROAMING ) or OBS_MODE_CHASE it still just spawns them as a normal player.
2. When I use ply:SetColor(Color(255,255,255,0) it doesnt make them invisible.
Here is my code:
function GM:PlayerInitialSpawn( ply )
ply:SetTeam( TEAM_SPEC )
ply:Spectate( OBS_MODE_CHASE )
timer.Create("Timer.Initspawn."..ply:SteamID(), 1, 1, function()
ply:SetMoveType( MOVETYPE_NOCLIP )
ply:SetColor(Color(255,255,255,0))
end)
ply:Respawn()
end
EDIT: The movetype_noclip movetype is my terrible fix for the spectating.
-
When you use player:Spectate(mode) you have to set an entity for the player to spectate.
player:SpectateEntity(ent)
Try that.
*edit* Also, try without the Respawn code too. i think that runs the GAMEMODE:PlayerSpawn() hook which will spawn the players entity at a spawn point which I don't think you want. You'll need to call that later when you want the player to stop spectating.
-
Thanks for the help :)
It works now.
Do you by any chance know how to disable team damage (friendly fire)?
-
use the PlayerShouldTakeDamage gamemode hook..
http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index148c.html
One of the examples on the wiki addresses exactly what you want.