TTT Detecting Roles Help

I am trying to detect the roles of traitors and detectives so that I can create a chat print to say what their role is by using a command that is forced upon the player. I don’t want to change how it is executed but I am having trouble to detect the players and then executing the code.


hook.Add( "TTTBeginRound", function()
	for _, ply in ipairs( player.GetAll() ) do
		if( ply = IsActiveTraitor() )     
			ply:ConCommand( zkgtraitorttt ) 
		elseif( ply = (IsActiveDetective()) )
			ply:ConCommand( zkgdetectivettt )
		else 
			ply:ConCommand( zkginnottt )
		end
	end )
end )


My problem is that on if( ply = IsActiveTraitor() ) it keeps saying it expects ‘)’ near = in that code

Your syntax is incorrect – a colon is what you’re looking for to call a function on an object. Also, don’t use concommands for something deterministic like this.


hook.Add( "TTTBeginRound", function()
	for _, ply in ipairs( player.GetAll() ) do
		if( ply:IsActiveTraitor() ) then     
			ply:ChatPrint( "Traitor" ) 
		elseif( ply:IsActiveDetective() ) then
			ply:ChatPrint( "Detective" )
		elseif ( ply:IsTerror() ) then
			ply:ChatPrint( "Innocent" )
		end
	end
end )

I also want to implement a HudPrint to the traitor/deteective/innocent to tell them that They Are Innocent or whatever.

I’ve gotten the main code for it but do not know how to do it individually but know how to send to the whole server.

http://forum.facepunch.com/showthread.php?t=1547511&p=51621738#post51621738

bump

I’m on mobile so I’m sorry if I make any mistakes. If you want to print to the user only then all you have to do is



ply:PrintMessage(HUD_PRINTTALK, "You are a traitor!")


Thanks for your help but I am trying to use a HudPrint Type of Thing to Show the player what role they are.

[editline]11th January 2017[/editline]

I’ll make a new topic since I am actually talking off topic from this actual topic