File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
addons/source-python/packages/source-python Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,27 @@ def setup_data():
153
153
'BaseClient' ,
154
154
GameConfigObj (SP_DATA_PATH / 'client' / 'CBaseClient.ini' ))
155
155
156
+ from core .cache import CachedProperty
157
+ from memory import get_function_info
158
+ from memory .helpers import MemberFunction
159
+ players .BaseClient .fire_game_event = CachedProperty (
160
+ lambda self , info : MemberFunction (
161
+ manager ,
162
+ info .return_type ,
163
+ self .make_virtual_function (info ),
164
+ self
165
+ ),
166
+ doc = """Fires the given game event to this client.
167
+
168
+ :param GameEvent game_event:
169
+ The game event instance to fire.
170
+ """ ,
171
+ args = (get_function_info ('IGameEventListener2' , 'FireGameEvent' ),)
172
+ )
173
+ players .BaseClient .fire_game_event .__set_name__ (
174
+ players .BaseClient , 'fire_game_event'
175
+ )
176
+
156
177
import entities
157
178
entities ._BaseEntityOutput = manager .create_type_from_dict (
158
179
'BaseEntityOutput' ,
Original file line number Diff line number Diff line change 47
47
from entities .helpers import index_from_inthandle
48
48
from entities .helpers import wrap_entity_mem_func
49
49
from entities .props import SendPropType
50
+ # Events
51
+ from events .manager import game_event_manager
50
52
# Filters
51
53
from filters .entities import EntityIter
54
+ # KeyValues
55
+ from keyvalues import KeyValues
52
56
# Mathlib
53
57
from mathlib import NULL_VECTOR
54
58
from mathlib import Vector
@@ -777,6 +781,25 @@ def spawn(self, force=False):
777
781
# Spawn the player...
778
782
super ().spawn ()
779
783
784
+ def fire_game_event (self , event_name , ** kwargs ):
785
+ """Creates and fires an event to this player.
786
+
787
+ :param str event_name:
788
+ The name of the event to create and fire.
789
+ :param dict kwargs:
790
+ The variables to set to the event.
791
+ """
792
+ # Create the event
793
+ game_event = game_event_manager .create_event (event_name , True )
794
+
795
+ # Set the variables
796
+ game_event .variables .recursive_copy (
797
+ KeyValues .from_dict (event_name , kwargs )
798
+ )
799
+
800
+ # Fire the event
801
+ self .base_client .fire_game_event (game_event )
802
+
780
803
# =========================================================================
781
804
# >> PLAYER WEAPON FUNCTIONALITY
782
805
# =========================================================================
You can’t perform that action at this time.
0 commit comments