Hi there, I been in the process in making a gun in Trouble in Terrorist Town which kills Traitors instantly and does not harm Innocents or Detectives. I have created a base line weapon how ever I am running into a propblems with the function I created for testing the weapon. Here is the code:
[code]
function SWEP:Damage(ply)
if ply:ROLE_TRAITOR then
ply:ChatPrint("The Player you shot was a Traitor!")
return SWEP.Primary.Damage = 100
end
end
[/code]
Perharps you can tell me were I am going wrong? Here is my error I am receiving from G-mod:
[code]
[ERROR] gamemodes/terrortown/entities/weapons/goldgun.lua:40: function arguments expected near 'then'
1. unknown - gamemodes/terrortown/entities/weapons/goldgun.lua:0
[/code]
Thanks for the Help!
Your code isn't syntactically correct in a lot of places, but anyway, it would be best to use a [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/EntityTakeDamage]GM:EntityTakeDamage[/url] to scale the damage. Ex.
[code]hook.Add("EntityTakeDamage", "GoldenGun", function(pEntity, dmg)
if (pEntity:IsPlayer() and pEntity:IsTraitor()) then
local pWeapon = dmg:GetInflictor()
if (pWeapon:IsValid() and pWeapon:GetClass() == "goldgun") then
pEntity:Kill() -- Make sure they die, regardless of their health
end
end
end)[/code]
Sorry, you need to Log In to post a reply to this thread.