HL2/HL2DM weapon laser
- daren adler
- Senior Member
- Posts: 348
- Joined: Sat May 18, 2019 7:42 pm
HL2/HL2DM weapon laser
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.
-
- Senior Member
- Posts: 310
- Joined: Sun May 17, 2020 7:56 am
- Location: Finland
- Contact:
Re: HL2/HL2DM weapon laser
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?
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?
- daren adler
- Senior Member
- Posts: 348
- Joined: Sat May 18, 2019 7:42 pm
Re: HL2/HL2DM weapon laser
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)
-
- Senior Member
- Posts: 310
- Joined: Sun May 17, 2020 7:56 am
- Location: Finland
- Contact:
Re: HL2/HL2DM weapon laser
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)
- daren adler
- Senior Member
- Posts: 348
- Joined: Sat May 18, 2019 7:42 pm
Re: HL2/HL2DM weapon laser
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)
-
- Senior Member
- Posts: 310
- Joined: Sun May 17, 2020 7:56 am
- Location: Finland
- Contact:
Re: HL2/HL2DM weapon laser
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)
- daren adler
- Senior Member
- Posts: 348
- Joined: Sat May 18, 2019 7:42 pm
Re: HL2/HL2DM weapon laser
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.
-
- Senior Member
- Posts: 310
- Joined: Sun May 17, 2020 7:56 am
- Location: Finland
- Contact:
Re: HL2/HL2DM weapon laser
try load it after server is on
- daren adler
- Senior Member
- Posts: 348
- Joined: Sat May 18, 2019 7:42 pm
Re: HL2/HL2DM weapon laser
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
-
- Senior Member
- Posts: 310
- Joined: Sun May 17, 2020 7:56 am
- Location: Finland
- Contact:
Re: HL2/HL2DM weapon laser
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)
- daren adler
- Senior Member
- Posts: 348
- Joined: Sat May 18, 2019 7:42 pm
Re: HL2/HL2DM weapon laser
Ok, works,, thank you very much.
Who is online
Users browsing this forum: No registered users and 0 guests