Hey developers I searched in google and lua fucntion and I'm realy did not find how to add spark effect to the stun stick weapon.
The stun stuck code is
[CODE]
AddCSLuaFile();
SWEP.Base = "weapon_cc_base";
SWEP.PrintName = "Stunbaton";
SWEP.Slot = 2;
SWEP.SlotPos = 1;
SWEP.UseHands = true;
SWEP.ViewModel = "models/weapons/c_stunstick.mdl";
SWEP.WorldModel = "models/weapons/w_stunbaton.mdl";
SWEP.Firearm = false;
SWEP.Primary.ClipSize = 1;
SWEP.Primary.DefaultClip = 1;
SWEP.Primary.Ammo = "cc_none";
SWEP.Primary.Automatic = true;
SWEP.HoldType = "melee";
SWEP.HoldTypeHolster = "normal";
SWEP.Holsterable = true;
SWEP.HolsterUseAnim = true;
SWEP.HolsterPos = Vector();
SWEP.HolsterAng = Vector();
SWEP.AimPos = Vector( -18.21, 6.34, -2.16 );
SWEP.AimAng = Vector( 7.24, 0, -71.13 );
SWEP.SecondaryBlock = true;
SWEP.BlockMul = 0.3;
SWEP.Itemize = true;
SWEP.ItemDescription = "A stunstick. Crowd-control bludgeon of choice of the Combine Civil Authority.";
SWEP.ItemWeight = 2;
SWEP.ItemFOV = 14;
SWEP.ItemCamPos = Vector( 50, 50, 50 );
SWEP.ItemLookAt = Vector( 0, 0, 0 );
SWEP.ItemBulkPrice = 1000;
SWEP.ItemLicense = LICENSE_BLACK;
SWEP.InfoText = [[Holstered - Primary: Nothing.
Holstered - Secondary: Nothing.
Unholstered - Primary: Swing.
Unholstered - Secondary: Block.]];
SWEP.HitSounds = {
"weapons/stunstick/stunstick_fleshhit1.wav",
"weapons/stunstick/stunstick_fleshhit2.wav"
}
SWEP.SwingSounds = {
"weapons/stunstick/stunstick_swing1.wav",
"weapons/stunstick/stunstick_swing2.wav"
}
function SWEP:Precache()
for _, v in pairs( self.HitSounds ) do
util.PrecacheSound( v );
end
for _, v in pairs( self.SwingSounds ) do
util.PrecacheSound( v );
end
end
function SWEP:PrimaryUnholstered()
self:SetNextPrimaryFire( CurTime() + 0.6 );
if( self.Owner:KeyDown( IN_ATTACK2 ) ) then return end
self:PlaySound( table.Random( self.SwingSounds ), 74, math.random( 90, 110 ) );
self.Owner:SetAnimation( PLAYER_ATTACK1 );
local trace = { };
trace.start = self.Owner:GetShootPos();
trace.endpos = trace.start + self.Owner:GetAimVector() * 50;
trace.filter = self.Owner;
trace.mins = Vector( -8, -8, -8 );
trace.maxs = Vector( 8, 8, 8 );
local tr = util.TraceHull( trace );
if( tr.Hit ) then
self:SendWeaponAnimShared( ACT_VM_HITCENTER );
else
self:SendWeaponAnimShared( ACT_VM_MISSCENTER );
end
self:Idle();
self.Owner:ViewPunch( Angle( 9, 6, 0 ) );
self:HitDamage();
end
function SWEP:DoFlash(ply)
if not IsValid(ply) or not ply:IsPlayer() then return end
ply:ScreenFade(SCREENFADE.IN, color_white, 1.2, 0)
end
function SWEP:HitDamage()
if( CLIENT ) then return end
local trace = { };
trace.start = self.Owner:GetShootPos();
trace.endpos = trace.start + self.Owner:GetAimVector() * 50;
trace.filter = self.Owner;
trace.mins = Vector( -8, -8, -8 );
trace.maxs = Vector( 8, 8, 8 );
local tr = util.TraceHull( trace );
if( tr.Hit ) then
self:PlaySound( table.Random( self.HitSounds ), 74, math.random( 90, 110 ) );
if( tr.Entity and tr.Entity:IsValid() ) then
if( !self.Owner.NextStrength ) then self.Owner.NextStrength = 0 end
if( CurTime() >= self.Owner.NextStrength ) then
self.Owner:SetStrength( math.Clamp( self.Owner:Strength() + GAMEMODE:ScaledStatIncrease( self.Owner, self.Owner:Strength() ) * 0.05, 0, 100 ) );
self.Owner:UpdateCharacterField( "StatStrength", tostring( self.Owner:Strength() ), true );
self.Owner.NextStrength = CurTime() + 10;
end
local blockmul = 1;
if( tr.Entity:IsPlayer() ) then
if( tr.Entity:GetActiveWeapon() and tr.Entity:GetActiveWeapon():IsValid() ) then
if( tr.Entity:GetActiveWeapon().IsBlocking and tr.Entity:GetActiveWeapon():IsBlocking() ) then
blockmul = tr.Entity:GetActiveWeapon().BlockMul;
end
end
end
if( tr.Entity:IsPlayer() ) then
self:DoFlash(tr.Entity);
local dmg = ( 25 + math.Round( self.Owner:Strength() * 0.2 ) ) * blockmul;
if( tr.Entity:HasTrait( TRAIT_CONDUCTOR ) ) then dmg = dmg * 1.25; end
if( tr.Entity:HasTrait( TRAIT_ROCKY ) ) then dmg = dmg * 0.75; end
if( tr.Entity:HasTrait( TRAIT_LOYALIST ) ) then dmg = dmg * 2; end
tr.Entity:TakeCDamage( math.floor( dmg ) );
local dmg = DamageInfo();
dmg:SetAttacker( self.Owner );
dmg:SetDamage( 0 );
dmg:SetDamageForce( tr.Normal * 100 );
dmg:SetDamagePosition( tr.HitPos );
dmg:SetDamageType( DMG_SHOCK );
dmg:SetInflictor( self );
tr.Entity:DispatchTraceAttack( dmg, tr );
net.Start( "nFlashRed" );
net.Send( tr.Entity );
elseif( tr.Entity:GetClass() == "prop_ragdoll" and tr.Entity:PropFakePlayer() and tr.Entity:PropFakePlayer():IsValid() ) then
local dmg = ( 25 + math.Round( self.Owner:Strength() * 0.2 ) ) * blockmul;
if( tr.Entity:PropFakePlayer():HasTrait( TRAIT_CONDUCTOR ) ) then dmg = dmg * 1.25; end
if( tr.Entity:PropFakePlayer():HasTrait( TRAIT_ROCKY ) ) then dmg = dmg * 0.75; end
if( tr.Entity:PropFakePlayer():HasTrait( TRAIT_LOYALIST ) ) then dmg = dmg * 2; end
tr.Entity:PropFakePlayer():TakeCDamage( math.floor( dmg ) );
elseif( tr.Entity:IsVehicle() and tr.Entity:GetDriver() and tr.Entity:GetDriver():IsValid() ) then
local dmg = ( 25 + math.Round( self.Owner:Strength() * 0.2 ) ) * blockmul;
if( tr.Entity:GetDriver():HasTrait( TRAIT_CONDUCTOR ) ) then dmg = dmg * 1.25; end
if( tr.Entity:GetDriver():HasTrait( TRAIT_ROCKY ) ) then dmg = dmg * 0.75; end
if( tr.Entity:GetDriver():HasTrait( TRAIT_LOYALIST ) ) then dmg = dmg * 2; end
tr.Entity:GetDriver():TakeCDamage( math.floor( dmg ) );
else
local dmg = DamageInfo();
dmg:SetAttacker( self.Owner );
dmg:SetDamage( 10 * blockmul );
dmg:SetDamageForce( tr.Normal * 100 );
dmg:SetDamagePosition( tr.HitPos );
dmg:SetDamageType( DMG_SHOCK );
dmg:SetInflictor( self );
if( tr.Entity.DispatchTraceAttack ) then
tr.Entity:DispatchTraceAttack( dmg, tr );
end
end
end
end
end
function SWEP:AddViewKick()
self.Owner:ViewPunch( Angle( math.Rand( 1, 2 ), math.Rand( -2, -1 ), 0 ) );
end
[/CODE]
I want to add the spark effect to PrimaryUnholstered when I unholdster the weapon I mean.
Thank you all.
I realy need this help..
Create a [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/ParticleEmitter]Global.ParticleEmitter[/url] and find the position of where you want it to spawn, then use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/CLuaEmitter/Add]CLuaEmitter:Add[/url] to create some spark particles, and on that particle set the velocity and angles to something random.
[editline]13th March 2015[/editline]
[url=https://github.com/ValveSoftware/source-sdk-2013/blob/56accfdb9c4abd32ae1dc26b2e4cc87898cf4dc1/mp/src/game/client/hl2/c_weapon_stunstick.cpp]This could be useful[/url]
Go here [url]http://facepunch.com/showthread.php?t=1417037[/url]
[QUOTE=sabadyCZ;47314396]Go here [url]http://facepunch.com/showthread.php?t=1417037[/url][/QUOTE]
Hey I checked your script when I attack with the weapon I get this lua error
[QUOTE]
[ERROR] gamemodes/combinecontrol/entities/weapons/weapon_cc_stunstick.lua:86: bad argument #2 to 'Effect' (CEffectData expected, got no value)
1. Effect - [C]:-1
2. PrimaryUnholstered - gamemodes/combinecontrol/entities/weapons/weapon_cc_stunstick.lua:86
3. unknown - gamemodes/combinecontrol/entities/weapons/weapon_cc_base/shared.lua:716
[/QUOTE]
Line 716 from cc base :
[QUOTE]
self:PrimaryUnholstered();
[/QUOTE]
Where I need to put your code ?
I need to spark will be when I unholdster the weapon and not anytime
I need view and world effect
[QUOTE=hanm13;47314574]Hey I checked your script when I attack with the weapon I get this lua error
Line 716 from cc base :
Where I need to put your code ?
I need to spark will be when I unholdster the weapon and not anytime
I need view and world effect[/QUOTE]
When you ll finish it, could you release it ? Cause i need it too...?
[QUOTE=sifly_04;47314598]When you ll finish it, could you release it ? Cause i need it too...?[/QUOTE]
Sure, why not ? :)
It says line 86 is erroring, not 716.
[QUOTE=LUModder;47314779]It says line 86 is erroring, not 716.[/QUOTE]
I didnt touch the weapon, I only added effect with his lua code from the link
Anyone can help me?
Bump....
BUMP
I made a simple effect which shows in first-person and third-person for my admin baton when weapons > stun-stick are selected. It also plays the sound when the weapon is selected ( for turning on and off )..
I've shared the code before, but here it is again...
[code]function admin:SetActiveTool( _p, _tool )
local _w = _p:GetActiveWeapon( );
if ( !IsValid( _w ) || _w:GetClass( ) != "admin_baton" ) then return; end
// Prevent the same tool from being selected again, no point...
if ( _tool == admin:GetActiveTool( _p ) ) then return; end
// Stun-Stick sound.. ( Will change this in the released version of the admin system to that there will be OnSelected / OnDeselected callbacks for each tool for specifics like this )
if ( _tool == STUN_STICK_WEAPON ) then
// Turn it on
_p:EmitSound( "Weapon_StunStick.Activate" );
elseif ( admin:GetActiveTool( _p ) == STUN_STICK_WEAPON ) then
// Turn it off
-- self:EmitSound( "weapons/stunstick/spark" .. math.random( 1, 3 ) .. ".wav" );
_p:EmitSound( "Weapon_StunStick.Deactivate" );
else
// Play a simple sound...
surface.PlaySound( "buttons/blip1.wav" );
end
networking:SyncFlag( "active_tool", _p, _w, _tool, false, FLAG_ADMIN );
end[/code]
[code]local STUN_STICK = Material( "effects/stunstick" );
function StunStickEffect( _p, _pos, _mat, _tab )
local _e = LocalPlayer( ):GetEmitter( _pos );
local p = _e:Add( _mat, _pos )
p:SetLifeTime( 0 );
p:SetDieTime( math.Rand( 0.10, 0.25 ) );
p:SetEndSize( 35 );
p:SetStartSize( _tab.startsize );
p:SetStartAlpha( _tab.alpha );
p:SetEndAlpha( 0 );
p:SetStartLength( 1 );
p:SetEndLength( 0 );
p:SetVelocity( Vector( 0, 0, 5 ) + ( VectorRand( ) * 15 ) );
-- p:SetGravity( Vector( 0, 0, -100 ) )
end
// First-Person
hook.Add( "PostDrawViewModel", "AdminStick:StunStickFirstPerson", function( _vm, _p, _w )
if ( !_p:IsAdmin( ) ) then return; end
if ( !IsValid( _w ) || _w:GetClass( ) != "admin_baton" ) then return; end
local _active_tool = _w:GetFlag( "active_tool", 1, false, FLAG_ADMIN );
if ( IsValid( _p:GetVehicle( ) ) ) then return; end
if ( _w:GetClass( ) == "admin_baton" ) then
local _attachment = _vm:GetAttachment( 2 );
if ( !_attachment ) then return; end
local _pos = _attachment.Pos + _attachment.Ang:Forward( ) * -2.5 + _attachment.Ang:Up( ) * -2 + _attachment.Ang:Right( ) * 0.9;
local _e = LocalPlayer( ):GetEmitter( _pos ); -- Custom: https://dl.dropboxusercontent.com/u/26074909/tutoring/_utilities/particle_emitter_fix.lua
local _sin = math.sinwave( 25, 3, true ); -- https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/core/ext_math.lua?at=master#cl-31
local _angs = _vm:GetAngles( );
local _yaw = math.rotate( 360 ); -- custom: https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/core/ext_math.lua?at=master#cl-23
local _pos = _attachment.Pos + _attachment.Ang:Forward( ) * -1.25 + _attachment.Ang:Up( ) * -1.75 + _attachment.Ang:Right( ) * 0.6;
if ( _active_tool == STUN_STICK_WEAPON ) then
-- render.ClientsideModel( "models/maxofs2d/hover_rings.mdl", _pos, _w:GetAngles( ), 0.35, 0, _p:GetPlayerColor( ) )
-- render.ClientsideModel( "models/roller_spikes.mdl", _pos, _vm:GetAngles( ), 0.25, 0 )
render.SetMaterial( STUN_STICK );
// Custom, not out yet but will be in next update, simple draw rect textured uv - these are the "glow"
render.DrawSprite( _pos, 5 + _sin, 5 + _sin, Color( 255, 255, 255, 155 ) )
render.DrawSprite( _pos, 20 + _sin, 20 + _sin, Color( 255, 255, 255, 10 ) )
// If moving faster than 10 MPH, get conversion off of gamemode/shared/_definitions/ dir - don't show the effects below because they trail...
if ( _p:GetVelocity( ):Length( ) / CONVERSION_UNITS_TO_MPH > 10 ) then return; end
StunStickEffect( _p, _pos, "effects/stunstick", { startsize = 10, alpha = 75 } );
StunStickEffect( _p, _pos, "trails/physbeam", { startsize = 10, alpha = 235 } );
StunStickEffect( _p, _pos, "effects/tool_tracer", { startsize = 5, alpha = 75 } );
StunStickEffect( _p, _pos, "sprites/tp_beam001", { startsize = 5, alpha = 75 } );
StunStickEffect( _p, _pos, "trails/electric", { startsize = 5, alpha = 75 } );
-- _e:Finish( ); -- not needed with custom system, although could easily be used without an issue with custom system. Max of 2 particle-emitters can be created but they can be moved unlimited times per frame and unlimited effects can be added so no need in more than 2....
end
end
end );
// Thirdperson
hook.Add( "PostPlayerDraw", "AdminStick:StunStick", function( _p )
if ( !IsValid( _p ) ) then return; end
if ( !_p:IsPlayer( ) ) then return; end
if ( !_p:IsAdmin( ) ) then return; end
if ( IsValid( _p:GetVehicle( ) ) ) then return; end
local _w = _p:GetActiveWeapon( );
if ( !IsValid( _w ) || _w:GetClass( ) != "admin_baton" ) then return; end
local _active_tool = _w:GetFlag( "active_tool", 1, false, FLAG_ADMIN );
if ( !IsValid( _w ) ) then return; end
if ( _w:GetClass( ) == "admin_baton" ) then
_muzzle = _w:LookupAttachment( "1" );
local _attachment = _w:GetAttachment( _muzzle );
if ( !_attachment ) then return; end
local _pos = _attachment.Pos + _attachment.Ang:Forward() * 2.4
local _e = LocalPlayer( ):GetEmitter( _pos );
local _sin = math.sinwave( 25, 3, true )
local _yaw = math.rotate( 360 )
if ( _active_tool == STUN_STICK_WEAPON ) then
render.SetMaterial( STUN_STICK );
render.DrawSprite( _pos, 5 + _sin, 5 + _sin, Color( 255, 255, 255, 155 ) );
render.DrawSprite( _pos, 20 + _sin, 20 + _sin, Color( 255, 255, 255, 10 ) );
if ( _p:GetVelocity( ):Length( ) / CONVERSION_UNITS_TO_MPH > 10 ) then return; end
_e:SetPos( _pos );
StunStickEffect( _p, _pos, "effects/stunstick", { startsize = 10, alpha = 75 } );
StunStickEffect( _p, _pos, "trails/physbeam", { startsize = 10, alpha = 235 } );
StunStickEffect( _p, _pos, "effects/tool_tracer", { startsize = 5, alpha = 75 } );
StunStickEffect( _p, _pos, "sprites/tp_beam001", { startsize = 5, alpha = 75 } );
StunStickEffect( _p, _pos, "trails/electric", { startsize = 5, alpha = 75 } );
end
end
end );[/code]
There is a lot of crap to wade through... but it's easy enough to draw a sprite. The helpers will be out in next update. I will actually also look at re-creating the original effect in Lua without custom sparks and sparkles... for those that want it.
This effect glows all the time, and sparkles when not moving or moving slowly ( so they don't trail ). This may not be exactly what you want, but hopefully it helps get you started... My weapon name, as noted is admin_baton. It uses my networking system / data system ( which is what GetFlag / SetFlag is about; storing and retrieving data, SyncFlag to network ) so _active_tool is likely not needed if you only have a stand-alone weapon...
I never really updated this code to beautify it or slim it down a whole lot because I've been busy working on other things with the little time I have ( injury leaves me with very little time that I can actually do something... ); I did remove a lot of crap while posting this though so it should be the minimum ( actually, a little more than minimum because you won't need to check active tool, etc... ) needed for it all to work after you either use some of my functions, or change to use default functions.. And, as I said, I'll be releasing a lua stun-stick very soon.
[QUOTE=Acecool;47338010]I made a simple effect which shows in first-person and third-person for my admin baton when weapons > stun-stick are selected. It also plays the sound when the weapon is selected ( for turning on and off )..
I've shared the code before, but here it is again...
[code]function admin:SetActiveTool( _p, _tool )
local _w = _p:GetActiveWeapon( );
if ( !IsValid( _w ) || _w:GetClass( ) != "admin_baton" ) then return; end
// Prevent the same tool from being selected again, no point...
if ( _tool == admin:GetActiveTool( _p ) ) then return; end
// Stun-Stick sound.. ( Will change this in the released version of the admin system to that there will be OnSelected / OnDeselected callbacks for each tool for specifics like this )
if ( _tool == STUN_STICK_WEAPON ) then
// Turn it on
_p:EmitSound( "Weapon_StunStick.Activate" );
elseif ( admin:GetActiveTool( _p ) == STUN_STICK_WEAPON ) then
// Turn it off
-- self:EmitSound( "weapons/stunstick/spark" .. math.random( 1, 3 ) .. ".wav" );
_p:EmitSound( "Weapon_StunStick.Deactivate" );
else
// Play a simple sound...
surface.PlaySound( "buttons/blip1.wav" );
end
networking:SyncFlag( "active_tool", _p, _w, _tool, false, FLAG_ADMIN );
end[/code]
[code]local STUN_STICK = Material( "effects/stunstick" );
function StunStickEffect( _p, _pos, _mat, _tab )
local _e = LocalPlayer( ):GetEmitter( _pos );
local p = _e:Add( _mat, _pos )
p:SetLifeTime( 0 );
p:SetDieTime( math.Rand( 0.10, 0.25 ) );
p:SetEndSize( 35 );
p:SetStartSize( _tab.startsize );
p:SetStartAlpha( _tab.alpha );
p:SetEndAlpha( 0 );
p:SetStartLength( 1 );
p:SetEndLength( 0 );
p:SetVelocity( Vector( 0, 0, 5 ) + ( VectorRand( ) * 15 ) );
-- p:SetGravity( Vector( 0, 0, -100 ) )
end
// First-Person
hook.Add( "PostDrawViewModel", "AdminStick:StunStickFirstPerson", function( _vm, _p, _w )
if ( !_p:IsAdmin( ) ) then return; end
if ( !IsValid( _w ) || _w:GetClass( ) != "admin_baton" ) then return; end
local _active_tool = _w:GetFlag( "active_tool", 1, false, FLAG_ADMIN );
if ( IsValid( _p:GetVehicle( ) ) ) then return; end
if ( _w:GetClass( ) == "admin_baton" ) then
local _attachment = _vm:GetAttachment( 2 );
if ( !_attachment ) then return; end
local _pos = _attachment.Pos + _attachment.Ang:Forward( ) * -2.5 + _attachment.Ang:Up( ) * -2 + _attachment.Ang:Right( ) * 0.9;
local _e = LocalPlayer( ):GetEmitter( _pos ); -- Custom: https://dl.dropboxusercontent.com/u/26074909/tutoring/_utilities/particle_emitter_fix.lua
local _sin = math.sinwave( 25, 3, true ); -- https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/core/ext_math.lua?at=master#cl-31
local _angs = _vm:GetAngles( );
local _yaw = math.rotate( 360 ); -- custom: https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/core/ext_math.lua?at=master#cl-23
local _pos = _attachment.Pos + _attachment.Ang:Forward( ) * -1.25 + _attachment.Ang:Up( ) * -1.75 + _attachment.Ang:Right( ) * 0.6;
if ( _active_tool == STUN_STICK_WEAPON ) then
-- render.ClientsideModel( "models/maxofs2d/hover_rings.mdl", _pos, _w:GetAngles( ), 0.35, 0, _p:GetPlayerColor( ) )
-- render.ClientsideModel( "models/roller_spikes.mdl", _pos, _vm:GetAngles( ), 0.25, 0 )
render.SetMaterial( STUN_STICK );
// Custom, not out yet but will be in next update, simple draw rect textured uv - these are the "glow"
render.DrawSprite( _pos, 5 + _sin, 5 + _sin, Color( 255, 255, 255, 155 ) )
render.DrawSprite( _pos, 20 + _sin, 20 + _sin, Color( 255, 255, 255, 10 ) )
// If moving faster than 10 MPH, get conversion off of gamemode/shared/_definitions/ dir - don't show the effects below because they trail...
if ( _p:GetVelocity( ):Length( ) / CONVERSION_UNITS_TO_MPH > 10 ) then return; end
StunStickEffect( _p, _pos, "effects/stunstick", { startsize = 10, alpha = 75 } );
StunStickEffect( _p, _pos, "trails/physbeam", { startsize = 10, alpha = 235 } );
StunStickEffect( _p, _pos, "effects/tool_tracer", { startsize = 5, alpha = 75 } );
StunStickEffect( _p, _pos, "sprites/tp_beam001", { startsize = 5, alpha = 75 } );
StunStickEffect( _p, _pos, "trails/electric", { startsize = 5, alpha = 75 } );
-- _e:Finish( ); -- not needed with custom system, although could easily be used without an issue with custom system. Max of 2 particle-emitters can be created but they can be moved unlimited times per frame and unlimited effects can be added so no need in more than 2....
end
end
end );
// Thirdperson
hook.Add( "PostPlayerDraw", "AdminStick:StunStick", function( _p )
if ( !IsValid( _p ) ) then return; end
if ( !_p:IsPlayer( ) ) then return; end
if ( !_p:IsAdmin( ) ) then return; end
if ( IsValid( _p:GetVehicle( ) ) ) then return; end
local _w = _p:GetActiveWeapon( );
if ( !IsValid( _w ) || _w:GetClass( ) != "admin_baton" ) then return; end
local _active_tool = _w:GetFlag( "active_tool", 1, false, FLAG_ADMIN );
if ( !IsValid( _w ) ) then return; end
if ( _w:GetClass( ) == "admin_baton" ) then
_muzzle = _w:LookupAttachment( "1" );
local _attachment = _w:GetAttachment( _muzzle );
if ( !_attachment ) then return; end
local _pos = _attachment.Pos + _attachment.Ang:Forward() * 2.4
local _e = LocalPlayer( ):GetEmitter( _pos );
local _sin = math.sinwave( 25, 3, true )
local _yaw = math.rotate( 360 )
if ( _active_tool == STUN_STICK_WEAPON ) then
render.SetMaterial( STUN_STICK );
render.DrawSprite( _pos, 5 + _sin, 5 + _sin, Color( 255, 255, 255, 155 ) );
render.DrawSprite( _pos, 20 + _sin, 20 + _sin, Color( 255, 255, 255, 10 ) );
if ( _p:GetVelocity( ):Length( ) / CONVERSION_UNITS_TO_MPH > 10 ) then return; end
_e:SetPos( _pos );
StunStickEffect( _p, _pos, "effects/stunstick", { startsize = 10, alpha = 75 } );
StunStickEffect( _p, _pos, "trails/physbeam", { startsize = 10, alpha = 235 } );
StunStickEffect( _p, _pos, "effects/tool_tracer", { startsize = 5, alpha = 75 } );
StunStickEffect( _p, _pos, "sprites/tp_beam001", { startsize = 5, alpha = 75 } );
StunStickEffect( _p, _pos, "trails/electric", { startsize = 5, alpha = 75 } );
end
end
end );[/code]
There is a lot of crap to wade through... but it's easy enough to draw a sprite. The helpers will be out in next update. I will actually also look at re-creating the original effect in Lua without custom sparks and sparkles... for those that want it.
This effect glows all the time, and sparkles when not moving or moving slowly ( so they don't trail ). This may not be exactly what you want, but hopefully it helps get you started... My weapon name, as noted is admin_baton. It uses my networking system / data system ( which is what GetFlag / SetFlag is about; storing and retrieving data, SyncFlag to network ) so _active_tool is likely not needed if you only have a stand-alone weapon...
I never really updated this code to beautify it or slim it down a whole lot because I've been busy working on other things with the little time I have ( injury leaves me with very little time that I can actually do something... ); I did remove a lot of crap while posting this though so it should be the minimum ( actually, a little more than minimum because you won't need to check active tool, etc... ) needed for it all to work after you either use some of my functions, or change to use default functions.. And, as I said, I'll be releasing a lua stun-stick very soon.[/QUOTE]
Thank you I will wait to the release.
Sorry, you need to Log In to post a reply to this thread.