SWEP Issue D:

I’m making a poison dart gun from scratch for TTT and I need some help. How would I set a player (other than the user/weapon-holder) to have a completely green screen?

P.S. I have a way of doing the green screen
P.P.S. I also was thinking about using usermessages but am not sure how to do it.

Thanks!

So you’ve solved your question?

I don’t get what you’re saying. Elaborate on what you mean by your P.S. and what you’re on about regarding usermessages.

If you “have a way of doing the green screen”, what help can anyone provide in regards to helping you “set a player … to have a completely green screen”?

Like I mean how can I tell the server to give a specific player the green screen? I meant I have a way of MAKING the green screen, but not how to give it to that player.

[editline]12th January 2012[/editline]

Oh and it appears I have another issue: My weapon insists on targeting the world for some reason when I hit someone:

[lua]
function SWEP:traceent()
local pos = self.Owner:GetShootPos()
local ang = self.Owner:GetAimVector()
local hp=self.Owner:GetEyeTrace().HitPos
local tracedata = {}
tracedata.start = pos
tracedata.endpos = hp
tracedata.filter = self.Owner
local trace = util.TraceLine(tracedata)
target = trace.Entity

if target==nil or not target:IsValid() then
	target="world"
elseif target:IsWorld() then
	target = "world"
elseif target:IsValid() then
	
	if target:GetClass()=="prop_dynamic" then
		target="world"
	end
	
end

return target

end

SWEP:PrimaryAttack()
targ=self:traceent()
print(targ)

	if targ~="world" then
		
		if targ:IsPlayer() then
			timer.Simple(20,function ()
				
				if targ~=nil then
					if targ:IsValid() and targ~="world" then
						targ:Kill()

					end

				end

			end)
			
		end
	end

end
[/lua]

Since it’s a gun, just pull the player someone is looking at from a trace.

serverside.lua
[lua]
if SERVER then
concommand.Add(“gsplayer”, function(ply, cmd, args)
for _, v in pairs(players.GetAll()) do
if tostring(v:UniqueID()) == args[1] and args[1] != tostring(ply:UniqueID()) then
// Put your green screen thing here
end
end
end)
end
[/lua]

clientside.lua – Don’t use this exactly as is, it’s an example. If you use this as is, anyone you look at will have the green screen effect affected on them.
[lua]
if CLIENT then
local trace = LocalPlayer():GetEyeTraceNoCursor()
local ent = nil
if trace.Hit and trace.Entity:IsPlayer() then
ent = trace.Entity
RunConsoleCommand(“gsplayer”, tostring(ent:UniqueID()))
end
end
[/lua]

Haven’t tested it, but I think that could work. I’ll look at the SWEP thing in a bit or maybe someone else will get it.

In GAMEMODE:ScalePlayerDamage(), you could check for the weapon (or entity the weapon creates, etc.), then change the damage type to DMG_POISON. Note that the damage will be healed back after a while, even if the player’s suit is 0 and even if he isn’t wearing the HEV suit. Also, sounds will be played saying he’s been poisoned and an antidote is being administered. But for the most part, it will behave like a normal poison, dealing damage over time (100% of the damage over two half second ticks,) and the damage eventually gets healed back (the player recovers from the poison.)

serverside.lua
[lua]
hook.Add( “ScalePlayerDamage”, “Our Little Poison Damage Hook”, function( ply, hitgroup, dmginfo )
if ply:GetActiveWeapon():GetClass() == “weapon_poisondartgun” then – Or whatever the name of your weapon is…
dmginfo:SetDamageType( DMG_POISON )
end
end )
[/lua]

Do you know how I could make it so it doesn’t regenerate and / or is delayed 20 seconds (timer.Simple)?

[editline]12th January 2012[/editline]

I thought of an idea… instead of DMG_POISON could I use DMG_ACID and do the dmginfo:SetDamageType( DMG_ACID ) inside a timer of 20 seconds?

[editline]12th January 2012[/editline]

1 more thing. The way I did it is that the actual gun does 1 dmg and the poison does 100

Yeah, my way is all engine based. Meaning it’s very limited.

HOWEVER, you could have it create a point_hurt, pass the victim’s entity over to the targetentity keyvalue (I think it may work like that.) For the delay keyvalue, set it to every 1 second, and for the damage keyvalue set it to how much damage you want to do each [delay] seconds (remember that poison deals its damage over 2 half second intervals,) and then set a timer to get rid of the point hurt. You’ll probably want to parent the point hurt to the player, or have it just create the entity at the player’s position when hit, then set its radius to the maximum distance the player can run in the time until the entity is removed.

Something like that. Of course you can do all this with Lua, it’s just my preference to use engine stuff if I can.

Could you make me an example, please? I’m very new to Lua.