I am creating a SWEP with tracers, I do not want the whole SWEP to be donator only, instead I am making only one line of the code donator only.
Here is what I have got.
[lua]
if CLIENT and ply:IsUserGroup("donator") then
bullet.TracerName = "AirboatGunHeavyTracer"
end
[/lua]
What am I doing wrong?
[B]EDIT: The problem has been solved![/B]
You need to use LocalPlayer(), not ply.
Next time, post the error you have and the whole function you're having an issue with. Not all problems are so easily solved.
(Also, consider [url=http://www.lua.org/pil/contents.html]reading this[/url]. It might help.)
[QUOTE=Lexic;40452142]You need to use LocalPlayer(), not ply.
Next time, post the error you have and the whole function you're having an issue with. Not all problems are so easily solved.
(Also, consider [url=http://www.lua.org/pil/contents.html]reading this[/url]. It might help.)[/QUOTE]
Thank you for the reply, but I have already tried that method before and it did not work.
You mentioned posting errors, but there are none, the tracers simply do not change.
Post the entire function then.
[QUOTE=Lexic;40452414]Post the entire function then.[/QUOTE]
Here ya go.
[lua]
function SWEP:ShootBullet(dmg, recoil, numbul, cone)
numbul = numbul or 1
cone = cone or 0.01
local bullet = {}
bullet.Num = num_bullets
bullet.Src = self.Owner:GetShootPos() -- Source
bullet.Dir = (self.Owner:GetAimVector():Angle() + self.Owner:GetPunchAngle()):Forward() -- Dir of bullet
bullet.Spread = Vector( aimcone, aimcone, 0 ) -- Aim Cone
bullet.Tracer = 1 -- Show a tracer on every x bullets
bullet.Force = 1 -- Amount of force to give to phys objects
bullet.Damage = damage
if CLIENT and LocalPlayer():IsUserGroup( "superadmin" ) then
bullet.TracerName = "AirboatGunHeavyTracer"
PrintMessage( HUD_PRINTTALK, "sup" )
end
-- bullet.Callback = function ( a, b, c ) BulletPenetration( 0, a, b, c ) end -- CALL THE FUNCTION BULLETPENETRATION
self.Owner:FireBullets(bullet) -- Fire the bullets
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK) -- View model animation
self.Owner:MuzzleFlash() -- Crappy muzzle light
self.Owner:SetAnimation(PLAYER_ATTACK1) -- 3rd Person Animation
end
[/lua]
Use
[lua]if (IsValid(self.Owner) and self.Owner:IsPlayer() and self.Owner:IsUserGroup('superadmin')) then[/lua]
Generally speaking, unless a function is server or client only you should call it on both.
[QUOTE=Lexic;40452822]Use
[lua]if (IsValid(self.Owner) and self.Owner:IsPlayer() and self.Owner:IsUserGroup('superadmin')) then[/lua]
Generally speaking, unless a function is server or client only you should call it on both.[/QUOTE]
Perfect, works just how I wanted it to, thank you very much for the help!
Sorry, you need to Log In to post a reply to this thread.