A few questions according for scripts
A few questions according for scripts
I've read a few topics with scripts etc,
Does all the events that were in ES apply here to? and i saw somewhere a script that imported es are there es functions implented and if so witch once ?
Does all the events that were in ES apply here to? and i saw somewhere a script that imported es are there es functions implented and if so witch once ?
-Tuck
We plan to provide all the events that are currently included with eventscripts. As for the es functions, we have since renamed the project to Source.Python so it will be sp now. We plan to provide libraries to mimic a lot of the es functionality in time, however we cannot guarantee that everything will be available right away.
The script that imports es is broken. es is not a module within Source.Python.
All of the events are definitely still available. Whenever the Engine itself calls an event, Source.Python calls the function within ../addons/source-python/sp.py called "event_fire". The API then uses this to check if any modules have registered for that event, and if so, call them.
To register for an event, you can do one of 2 things. First (and highly recommended for all scripts), is to use the Event Decorator system:Using this method, when your addon is unloaded, all instances of the "event" class within your script (including any other modules within the script) will automatically be unregistered for their given events.
The second option is using the Event Registration directly. If you choose to use this, you will need to unregister the events directly when the script is unloaded:Satoon
All of the events are definitely still available. Whenever the Engine itself calls an event, Source.Python calls the function within ../addons/source-python/sp.py called "event_fire". The API then uses this to check if any modules have registered for that event, and if so, call them.
To register for an event, you can do one of 2 things. First (and highly recommended for all scripts), is to use the Event Decorator system:
Syntax: Select all
# Import the decorator class
from events.decorator import event
# Declare the function as an event
@event
def some_event_name(game_event):
print('This event just fired!!!')
The second option is using the Event Registration directly. If you choose to use this, you will need to unregister the events directly when the script is unloaded:
Syntax: Select all
from events.manager import EventRegistry
def some_event_name_function(game_event):
print('This event just fired!!!')
# Register the "some_event_name" event to the function some_event_name_function
EventRegistry.register_for_event('some_event_name', some_event_name_function)
# Unregister the event on unload
def unload():
EventRegistry.register_for_event('some_event_name', some_event_name_function)
Commands to load/unload/reload are:
The path to a script should be ../addons/source-python/<scriptname>/<scriptname>.py That is for the "main" file for the script. All other (Python) files for the given script should be within that directory as well.
Satoon
- sp_load <scriptname>
- sp_unload <scriptname>
- sp_reload <scriptname>
The path to a script should be ../addons/source-python/<scriptname>/<scriptname>.py That is for the "main" file for the script. All other (Python) files for the given script should be within that directory as well.
Satoon
The "engines" folder houses all of the Python3.3 included modules. The "bin" folder houses the "core.dll" file. The "_libs" folder is where the API is going to be housed (currently already has addons and events base modules). The __pycache__ is a folder that Python creates when a Python module within that folder is loaded into memory. Python2 created compiled (.pyc) files within the original directory, which caused those directories to become very cluttered.
Satoon
Satoon
For some reason i can't get it to load or show any errors O_o

Code: Select all
def load()
print('Plugin, Loaded.')
def unload()
print('Plugin, Unloaded.')
def player_disconnect(ev):
# Get the player's steam ID
steamid = ev.GetString('networkid')
# Set the reason to the steam ID
ev.SetString('reason', steamid)
def player_say(ev):
if not ev.IsEmpty('text'):
text = ev.GetString('text')
print('player (%s) :: \'%s\'' % (ev.GetInt('userid'), text))

-Tuck
Well, the addon system is still a work in progress. The error is being encountered, but no message is being sent. I'll look into why that is in a few. The error you are getting is that you are missing : at the end of your load and unload functions.
Also, you might take a look again at this post:
http://www.sourcepython.com/forums/showthread.php?29-A-few-questions-according-for-scripts&p=141&viewfull=1#post141
You are not registering your events.
Satoon
Also, you might take a look again at this post:
http://www.sourcepython.com/forums/showthread.php?29-A-few-questions-according-for-scripts&p=141&viewfull=1#post141
You are not registering your events.
Satoon
Source.Python is still in developement, so some things may change with a new revision. I guess the script you saw was made before the idea with decorators. However here is an example.
Syntax: Select all
from events.decorators import event
@event
def player_say(game_event):
pass
The "name" of the event is player_say. Using @event prior to a function will cause that function to be registered for the event with the same name as it. Therefor, when using:
We are registering the "player_say" event to call our "player_say" function. So, when the game engine calls player_say, all functions registered for the player_say event will be fired.
For a list of events within CS:S (we need to get a page going on here for CS:GO), look at this page:
http://www.eventscripts.com/pages/Category:Valve_Events
You can use any of those, as long as they are called by the engine, along with a number of new one's for CS:GO. Some of those events (like player_score and player_shoot, both of which I "believe" might work on HL2:DM) are not fired for CS:GO, so you would not want to use them.
Satoon
Syntax: Select all
from events.decorator import event
@event
def player_say(game_event):
pass
We are registering the "player_say" event to call our "player_say" function. So, when the game engine calls player_say, all functions registered for the player_say event will be fired.
For a list of events within CS:S (we need to get a page going on here for CS:GO), look at this page:
http://www.eventscripts.com/pages/Category:Valve_Events
You can use any of those, as long as they are called by the engine, along with a number of new one's for CS:GO. Some of those events (like player_score and player_shoot, both of which I "believe" might work on HL2:DM) are not fired for CS:GO, so you would not want to use them.
Satoon
edited my post, your-name-here also wrote how to here: http://www.sourcepython.com/forums/showthread.php?70-Installation-of-plugin-Server-not-starting&p=328&viewfull=1#post328
-Tuck
You might be able to use something like this: (not sure if this will work)
Syntax: Select all
IVEngineServer.ServerCommand('echo We loaded our first addon! (Hello World!)')
Return to “General Discussion”
Who is online
Users browsing this forum: Bing [Bot] and 92 guests