My First Addon
|
[edit] Tutorial: My First AddonRequires: ES 2.x [edit] Tutorial Overview[edit] Table of Contents
[edit] DescriptionIn this Tutorial, we will create an extremely simple addon for Counter-Strike: Source using EventScripts 2.0 in Python (ESP / ESPy). This tutorial will help you create a simple Hello World . If you do not know the basics of Python, take a look at the Python for Beginners tutorial. [edit] Tutorial Content[edit] Start offOpen your favorite Python editor, if you don't have one, I recommend Notepad++ or PSPad; or, if you have enough money ActiveState Komodo. You can also just use Notepad or any text editor you like. Create a new document, import EventScripts: import es
[edit] Start the main script[edit] player_jump event handlingAfter adding the import lines, we will start by defining the player_jump function, by telling Python we are going to create a function called player_jump: def player_jump(event_var): After adding that line, add the following code: es.msg('You jumped!') Note the indentation at the start of the line, this is vital or Python won't know that you want that line of code to execute when player_jump is ran. In python indentations are usually a single tab or 4 spaces per indent - Mattie recommends you use 4 spaces in your scripts (although tabs will work). [edit] Save the addonNow we have completed the addon, save it as firstaddon.py under: ../cstrike/addons/eventscripts/firstaddon/ Load up srcds, and enter: es_load firstaddon You should get in the console: Loaded: firstaddon Now, join the server and jump! [edit] ConclusionYou will now hopefully have a vague understanding of how EventScripts works with Python. Take a look at My_Second_Addon for a more sophisticated, purposeful addon tutorial. [edit] Thanks for reading |
|
