I'm using the ulx AAFK script and I'm trying to make it move the player to spectate once they are flagged as afk. This is the part that flags them as afk:
[code] if pl.afkc >= GetConVarNumber( "ulx_afk_flagminutes" ) then
if pl.afk == false then
pl.afk = true
ulx.fancyLogAdmin( pl, "#A went AFK!" )
ULib.tsayColor(_, Color(0,0,0,255), "[AAFK] ", team.GetColor(pl:Team()), pl:Nick(), Color(255,255,255), " went ", Color(255,0,0,255), "AFK.")
end
end[/code]
In the murderer game mode it uses a concommand "mu_movetospectate" to move the player to spectate. So I tried to use that command inside the aafk script, but it's not working:
[code]
if pl:Alive() && pl.afk == true then
RunConsoleCommand("mu_movetospectate", pl:EntIndex())
end[/code]
is this structure all wrong? Am I calling the right things?
Use
[lua]pl:Nick()[/lua]
Instead of
[lua]pl:EntIndex()[/lua]
[QUOTE=ZombieWizzard;45235989]Use
[lua]pl:Nick()[/lua]
Instead of
[lua]pl:EntIndex()[/lua][/QUOTE]
Tried that. It only flags them as afk it seems.
Where have you got the second bit of code placed? Try putting
[lua]RunConsoleCommand("mu_movetospectate", pl:EntIndex())[/lua]
under
[lua]ULib.tsayColor(_, Color(0,0,0,255), "[AAFK] ", team.GetColor(pl:Team()), pl:Nick(), Color(255,255,255), " went ", Color(255,0,0,255), "AFK.")[/lua]
Here's how to make a player become spectator when they first join a server:
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/spectating_players_system.lua.html[/url]
To make them become spectator in the middle of a "round", do something like this ( PlayerDeathThink should prevent the player from spawning, ):
This should work:
[code]// Spectator mid-round
local META_PLAYER = FindMetaTable( "Player" );
function META_PLAYER:MoveToSpectator( )
if ( !IsValid( self ) ) then return false; end
self:SetTeam( TEAM_SPECTATOR );
self:Spectate( OBS_MODE_ROAMING );
if ( self:Alive( ) ) then self:KillSilent( ); end
end[/code]
[QUOTE=Acecool;45236099]Here's how to make a player become spectator when they first join a server:
[URL]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/spectating_players_system.lua.html[/URL]
To make them become spectator in the middle of a "round", do something like this ( PlayerDeathThink should prevent the player from spawning, ):
This should work:
[code]// Spectator mid-round
local META_PLAYER = FindMetaTable( "Player" );
function META_PLAYER:MoveToSpectator( )
if ( !IsValid( self ) ) then return false; end
self:SetTeam( TEAM_SPECTATOR );
self:Spectate( OBS_MODE_ROAMING );
if ( self:Alive( ) ) then self:KillSilent( ); end
end[/code][/QUOTE]
I only need it to move them to spec once flagged ask afk by the afk system.
Would something like this work?
[code] if pl.afkc >= GetConVarNumber( "ulx_afk_flagminutes" ) then
if pl.afk == false then
pl.afk = true
ulx.fancyLogAdmin( pl, "#A went AFK!" )
ULib.tsayColor(_, Color(0,0,0,255), "[AAFK] ", team.GetColor(pl:Team()), pl:Nick(), Color(255,255,255), " went ", Color(255,0,0,255), "AFK.")
pl:SetTeam(TEAM_SPECTATOR)
end
end[/code]
/E Yeah this new script did something. It removed the player from the team, but didn't put them in the spectators team. Either way, I think I can figure it out myself from here. Thanks for the help everyone.
Sorry, you need to Log In to post a reply to this thread.