• LUA - Change death station Color For Traitors (TTT) - Please Help
    4 replies, posted
Hi, I'm very new to coding, but I have been trying to learn more so I can code more custom weapons. One particular weapon that I am trying to modify is the death station. I am trying to make it so the death station appears red, but only to traitors. So far, I have tried many things, including making a client side script, multiple additions to the function at line 86 and more recently code as below. None have had any success except to color it red for everyone, which kind of defeats the purpose. My last addition to the code was (see below), but that seems to be as ineffective as anything else. Could someone please help me with this? Or direct me to somewhere else that can? (I have spent many hours on the wiki, but stringing the short lines of code together is usually where I fail) Thanks, Yrhaid [CODE]if CLIENT then ENT.Icon = "VGUI/ttt/icon_fon_death_station2" ENT.PrintName = "Death Station" ENT.Author = "Pwned (HF)" local GetPTranslation = LANG.GetParamTranslation ENT.TargetIDHint = { name = "hstation_name", hint = "hstation_hint", fmt = function(ent, txt) return GetPTranslation(txt, { usekey = Key("+use", "USE"), num = ent:GetStoredHealth() or 0 } ) end }; [B][I] for k, v in pairs(player.GetAll()) do if v:IsTraitor() and v:IsActiveTraitor() then local ds = ents.FindByName("ttt_death_station") ds:color(255, 0, 0, 255) end end[/I][/B] end [/CODE] Full code: [url]http://pastebin.com/rD7cNpNK[/url] approx 200 lines
Try changing: [code]ds:color(255, 0, 0, 255)[/code] To [code]ds:SetColor(255, 0, 0, 255) [/code]
[QUOTE=Baawss;40092880]Try changing: [code]ds:color(255, 0, 0, 255)[/code] To [code]ds:SetColor(255, 0, 0, 255) [/code][/QUOTE] Thanks for the quick reply This Was One of the things I had tried before I tried it again, and restarted the server, and nothing happened. No errors, but no color change. Any Ideas as to why?? Also, the entity seems to have unlimited health. IE you can just crowbar/shoot it for an entire round and even though damage numbers (from the addon) are appearing, it wont disappear or explode. I'm not sure if that is related, but I thought that I should include it anyway
The errors are on the server console. You need to pass a color object, not numbers. [editline]30th March 2013[/editline] ents.FindByName also returns a table, and that loop would only be called when the entity initializes. You will need to use ENT:Draw and check if LocalPlayer is a traitor or not.
ds:SetColor(Color(255, 0, 0, 255))
Sorry, you need to Log In to post a reply to this thread.