TTT Radar

So I’ve been editing the cl_radar.lua for TTT and I’m trying to make it if a detective has a radar then the time is 15, but if it’s a traitor then the time is 20. I’ve tried to do this multiple times, like

if client:IsActiveTraitor() then
RADAR.duration = 20
elseif client:IsActiveDetective() then
RADAR.duration = 15
end

or LocalPlayer() or GetRole( ROLE_TRAITOR ) or GetRole() == ROLE_TRAITOR, etc. and a combination of all of it… But when I have a check in the code then it errors and the hud dissapears etc. but if i remove the check it works fine. Help?

[editline]3rd July 2011[/editline]

NVM, I realized this is only how long the radar lasts…

[editline]3rd July 2011[/editline]

Okay can anyone help me here? This is how BKU’s radar code works…

endtime = current time… (say it’s 10)

remaining = endtime - current time ( 10 - 10 )
So it’s 0 and it scans.

endtime = current time + duration ( 10 + 30 )
So it goes back to the remaining…

remaining = endtime - current time ( 40 - 10 )
So it has 30 seconds left till next scan.

But whenyou change the duration to say 10, it thinks it has 20 more seconds b4 u can scan again… It thinks it is charging, but I cannot find a code ANYWHERE in TTT talking about radars charging.

Post the lua code you currently have changed, Lua Errors, and What you want it to do. :wink:

http://www.trippnordic.se/img/heart_small.gif

The code is really long so imma upload it to pastebin…

I want it so if the player is a traitor then it scans every 20 seconds, but if he is a detective then it scans every 15 seconds.

Maybe add 2 different time-out timers one for Det one for Traitor.
RADAR.TimeoutT = 20
RADAR.TimeoutT = 15
No, thats duration. Change timeout to duration

aurum that’s what I had originally but it kept giving me an error or something that would remove the HUD.

[lua]
RADAR.duration = RADAR.duration or 20 // Def
if LocalPlayer():IsActiveTraitor() then
RADAR.duration = 20
elseif LocalPlayer():IsActiveDetective() then
RADAR.duration = 15
end[/lua]

Oh. Good idea with setting it as default. Let me test it out :stuck_out_tongue:

[editline]4th July 2011[/editline]

Yah, still giving me the spam of the HUD…

[editline]4th July 2011[/editline]

This comes right before I get the spam of the hud error: (When I become a traitor/detective)
[terrortown\gamemode\cl_init.lua:88] attempt to call method ‘Clear’ (a nil value)

[terrortown\gamemode\cl_hud.lua:327] attempt to call method ‘Draw’ (a nil value)(Hook: HUDPaint)

Line 327:
RADAR:Draw(client)

Try to avoid adding it into the TTT gamemode files

OH I see it has it’s own file

Fixed

Radar.lua

[lua]local chargetime; // at top

if ply:IsTraitor() then
chargetime = 20
else
chargetime = 15
end
// ^^ goes above ply.radar_charge = CurTime() + chargetime
[/lua]

cl_Radar.lua
[lua]
RADAR.duration = 2 // Default On Radar Time out then it’ll use that instead
// VV replace this function with the other one
function RADAR:Timeout()
self:EndScan()

if LocalPlayer():IsActiveTraitor() then
	RADAR.duration = 20
elseif LocalPlayer():IsActiveDetective() then
	RADAR.duration = 15
end

if self.repeating and LocalPlayer() and (LocalPlayer():IsActiveTraitor() or LocalPlayer():IsActiveDetective()) then
	RunConsoleCommand("ttt_radar_scan")
end

end[/lua]

K, the RADAR.duration goes where it is normally? I got everything else.

[editline]4th July 2011[/editline]

K it works now, thanks :slight_smile:

Good now give me a lau king rating.

One for each of your posts. Happy? :stuck_out_tongue:

Thanks

http://www.trippnordic.se/img/heart_small.gif

http://www.trippnordic.se/img/heart_small.gif