HL2/HL2DM weapon laser

A place for requesting new Source.Python plugins to be made for your server.

Please request only one plugin per thread.
User avatar
daren adler
Senior Member
Posts: 348
Joined: Sat May 18, 2019 7:42 pm

HL2/HL2DM weapon laser

Postby daren adler » Thu Jul 11, 2024 5:48 pm

Was wondering if a scripter could make a laser pistol, using (weapon_pistol) for a lasergun in my hl2 server ?, Thank you and have a great day. :cool:
cssbestrpg
Senior Member
Posts: 310
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: HL2/HL2DM weapon laser

Postby cssbestrpg » Thu Jul 11, 2024 8:54 pm

Tomorrow(after work) or saturday i will make it.
Should the user who is wearing weapon: weapon_pistol only see the laser or everyone?
Also should it also make damage to victim(where the laser aims at)?
If makes damage, how much it would make damage then?
User avatar
daren adler
Senior Member
Posts: 348
Joined: Sat May 18, 2019 7:42 pm

Re: HL2/HL2DM weapon laser

Postby daren adler » Thu Jul 11, 2024 8:58 pm

cssbestrpg wrote:Tomorrow(after work) or saturday i will make it.
Should the user who is wearing weapon: weapon_pistol only see the laser or everyone?


Everyone if you can please. and yes right where it points at, and the damage i would like just like the pistol (i think its damage is 15) :cool:
cssbestrpg
Senior Member
Posts: 310
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: HL2/HL2DM weapon laser

Postby cssbestrpg » Fri Jul 12, 2024 9:41 am

Try this(Untested):

Syntax: Select all

from effects import TempEntity
from engines.precache import Model
from entities.entity import Entity
from filters.players import PlayerIter
from listeners.tick import Repeat

def load():
laser_aiming.start(repeat_timer)

def unload():
laser_aiming.stop()

repeat_timer = 1.0 # How often timer is executed
laser_damage = 15 # How much damage does laser hit

laser_model = Model('sprites/laser.vmt')

laser_beam = TempEntity('BeamPoints')
laser_beam.red = 128
laser_beam.green = 0
laser_beam.blue = 0
laser_beam.alpha = 255
laser_beam.life_time = repeat_timer
laser_beam.start_width = 3
laser_beam.end_width = 3
laser_beam.amplitude = 2
laser_beam.halo_index = laser_model
laser_beam.model_index = laser_model

@Repeat
def laser_aiming():
for player in PlayerIter('alive'):
weapon = player.get_active_weapon()
if weapon is None:
return

classname = weapon.classname
if classname != 'weapon_pistol':
continue

laser_beam.start_point = player.eye_location + player.view_vector
laser_beam.end_point = player.get_view_coordinates()
laser_beam.create()

target = player.view_player
if target is None:
continue

target.take_damage(damage=laser_damage, attacker_index=player.index, weapon_index=Entity.create_or_find('point_hurt').index)
User avatar
daren adler
Senior Member
Posts: 348
Joined: Sat May 18, 2019 7:42 pm

Re: HL2/HL2DM weapon laser

Postby daren adler » Fri Jul 12, 2024 12:49 pm

Thank you very much but not working, i got this error

Code: Select all

2024-07-12 08:43:07 - sp.hooks.exceptions   -   EXCEPTION   [Source.Python]
[SP] Caught an Exception:
Traceback (most recent call last):
  File "../addons/source-python/packages/source-python/plugins/command.py", line 164, in load_plugin
    plugin = self.manager.load(plugin_name)
  File "../addons/source-python/packages/source-python/plugins/manager.py", line 209, in load
    plugin._load()
  File "../addons/source-python/packages/source-python/plugins/instance.py", line 74, in _load
    self.module = import_module(self.import_name)
  File "../addons/source-python/plugins/laserpistol/laserpistol.py", line 27, in <module>
    laser_beam.halo_index   = laser_model
  File "../addons/source-python/packages/source-python/effects/base.py", line 307, in __setattr__
    self._set_property(prop_name, prop.type, value)
  File "../addons/source-python/packages/source-python/effects/base.py", line 493, in _set_property
    value, offset)

Boost.Python.ArgumentError: Python argument types in
    Pointer.set_int(Pointer, Model, int)
did not match C++ signature:
    set_int(CPointer {lvalue}, int, int offset=0)
cssbestrpg
Senior Member
Posts: 310
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: HL2/HL2DM weapon laser

Postby cssbestrpg » Fri Jul 12, 2024 7:29 pm

This should fix the error

Syntax: Select all

from effects import TempEntity
from engines.server import engine_server
from entities.entity import Entity
from filters.players import PlayerIter
from listeners.tick import Repeat

def load():
laser_aiming.start(repeat_timer)

def unload():
laser_aiming.stop()

repeat_timer = 1.0 # How often timer is executed
laser_damage = 15 # How much damage does laser hit

laser_model = engine_server.precache_model('sprites/laser.vmt')

laser_beam = TempEntity('BeamPoints')
laser_beam.red = 128
laser_beam.green = 0
laser_beam.blue = 0
laser_beam.alpha = 255
laser_beam.life_time = repeat_timer
laser_beam.start_width = 3
laser_beam.end_width = 3
laser_beam.amplitude = 2
laser_beam.halo_index = laser_model
laser_beam.model_index = laser_model

@Repeat
def laser_aiming():
for player in PlayerIter('alive'):
weapon = player.get_active_weapon()
if weapon is None:
return

classname = weapon.classname
if classname != 'weapon_pistol':
continue

looking_at = player.get_view_coordinates()
laser_beam.start_point = player.eye_location + player.view_vector
laser_beam.end_point = looking_at
laser_beam.create()

target = player.view_player
if target is None:
continue

target.take_damage(damage=laser_damage, attacker_index=player.index, weapon_index=Entity.create_or_find('point_hurt').index)
User avatar
daren adler
Senior Member
Posts: 348
Joined: Sat May 18, 2019 7:42 pm

Re: HL2/HL2DM weapon laser

Postby daren adler » Fri Jul 12, 2024 8:15 pm

No error, but this time it will not let the server come on, So i // blocked it or remove it and the server would start up.
cssbestrpg
Senior Member
Posts: 310
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: HL2/HL2DM weapon laser

Postby cssbestrpg » Fri Jul 12, 2024 8:16 pm

try load it after server is on
User avatar
daren adler
Senior Member
Posts: 348
Joined: Sat May 18, 2019 7:42 pm

Re: HL2/HL2DM weapon laser

Postby daren adler » Fri Jul 12, 2024 8:20 pm

I understand what you are saying, but this is a rent server and not a home server, So i would not be able to do it that way, i only use WinSCP to add files and folders
cssbestrpg
Senior Member
Posts: 310
Joined: Sun May 17, 2020 7:56 am
Location: Finland
Contact:

Re: HL2/HL2DM weapon laser

Postby cssbestrpg » Fri Jul 12, 2024 8:42 pm

my guess would be precaching vmt as global causes the problem, try this one:

Syntax: Select all

from effects import TempEntity
from engines.server import engine_server
from entities.entity import Entity
from filters.players import PlayerIter
from listeners.tick import Repeat

def load():
laser_aiming.start(repeat_timer)

def unload():
laser_aiming.stop()

repeat_timer = 1.0 # How often timer is executed
laser_damage = 15 # How much damage does laser hit


laser_beam = TempEntity('BeamPoints')
laser_beam.red = 128
laser_beam.green = 0
laser_beam.blue = 0
laser_beam.alpha = 255
laser_beam.life_time = repeat_timer
laser_beam.start_width = 3
laser_beam.end_width = 3
laser_beam.amplitude = 2

@Repeat
def laser_aiming():
laser_model = engine_server.precache_model('sprites/laser.vmt')
for player in PlayerIter('alive'):
weapon = player.get_active_weapon()
if weapon is None:
return

classname = weapon.classname
if classname != 'weapon_pistol':
continue

laser_beam.start_point = player.eye_location + player.view_vector
laser_beam.end_point = player.get_view_coordinates()
laser_beam.halo_index = laser_model
laser_beam.model_index = laser_model
laser_beam.create()

target = player.view_player
if target is None:
continue

target.take_damage(damage=laser_damage, attacker_index=player.index, weapon_index=Entity.create_or_find('point_hurt').index)
User avatar
daren adler
Senior Member
Posts: 348
Joined: Sat May 18, 2019 7:42 pm

Re: HL2/HL2DM weapon laser

Postby daren adler » Fri Jul 12, 2024 8:50 pm

Ok, works,, thank you very much. :cool: :cool: :cool:

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 0 guests