post

Code

StumbleUpon Digg Reddit Technorati

Writing your first mod for Counter Strike Source

ZebraLogoSmall

Starting projects for anything new can be fairly daunting - but if you're a fan of Valve's Source games, you can be writing addons for their games within a week. Mattie's Eventscripts makes writing server addons a breeze - and if you want to see the kind of things you can create, look no further than my post on CS Source Mods.

1. Brush up on Python

If this scares you off, hold for a moment. Even if you don't know how to code in Python, it's one of the easiest languages to learn - even if you have little or no coding experience whatsoever. If you can understand simple logic, and have a passion for problem solving, you'll not have much difficulty at all getting to grips with it - and if you're looking for a place to start, check out Getting into coding in 8 steps.

Eventscripts actually comes with two languages built in - I've chosen to write about Python because in my opinion it's both easier and more readable than the inbuilt shell language - and if you're coming to it without knowing either, you might as well begin with it. If you already have experiences with interpreted languages, you'll find Python infinitely easier to follow anyway - plus it's magnitudes faster than the built in language, and has more power.

2. Set up a Source Server

If you're already an admin of a server, with FTP access, this makes things easier - but even still, you can quickly and easily set up your own dedicated server on your home PC. There are two ways of doing this - and I'd recommend the first method over the second.

or

  • Go to Steam > Tools > Dedicated Server

You can get away without a server for the most basic of scripts, but without somewhere to test what you write, you'll be in difficulty when you come to release a working version.

There is a great tutorial for everything you need to do while setting up SRCDS here, I recommend you follow this as best you can.

3. Download and set up Eventscripts 2.0 (or greater)

Crucially, it's only versions 2.0 and upwards of Eventscripts that include Python, so make sure you get a copy from here. After that you'll need to unzip it to the right location: if you're using SRCDS, you need to go to:

C:\srcds\cstrike\addons

And make sure you unzip the files to the directory structure they follow in the zip file. There is an awesome screencast with explicit instructions for how to do this here.

Don't forget to create a file called:

cstrike/cfg/autoexec.cfg

And place the line 'mattie_eventscripts 1' somewhere in there, to tell eventscripts to enable events (this is very important).

4. Write your first script!

  • First you want to create a file on your server called:

cstrike/addons/eventscripts/myscript/myscript.py

Importantly, the script name must be the same as the folder it is in

  • The first line in your script should be as follows:

import es

This is vital for interacting with the game; with the es module contains all of the functions and methods you will need for:

- Displaying outputs in the form of text messages, menus, effects, sounds

- Getting information about the server and the users on it

And a whole load of other things. It is extremely unlikely you will not need this, as without it you will be unable to interact with the server in any meaningful way.

  • Functions can act as in game 'events' - these are called when things happen in game, and let you run code when they do

For example:

def player_jump(event_var):
es.msg(event_var['es_username'] + ' has jumped')

Let's analyse each section of this:

def player_jump(event_var):

This registers the event 'player_jump' to be called by your script. Obviously, this is called whenever any player jumps. The 'event_var' is the variable eventscripts passes data about the event to, in the form of a dictionary, for example, who jumped, where did they jump, what is their name.

All of the available events can be seen here

es.msg(

This is a function which displays text in the chat area of the screen for all players.

All of the available funtions can be seen here.

event_var['es_username']

This is, very simply, the player name associated with the event.

  • Variables exist for the full duration of the time a script is loaded

This means that they are ideal for small data storage: global variables exist until a script is unloaded or the server is rebooted or shut down. Gobal variable scope, as would be expected, is limited to the script itself.

  • Scripts must be 'loaded' before they take effect.

Very simply, this is so that Eventscripts can tell which scripts to call, which events to register, and so on. To load a script, simple type 'es_load myscript' into your SRCDS console; or, if you want a script to load every time you run your server, create a file called:

cstrike/cfg/autoexec.cfg

And place the line 'es_load myscript' somewhere in there.

5. Documentation and Examples

There's only so much that can be said in the space of one post: in order to fully realise the potential of eventscripts, you need to read up on the forums, see some examples, and understand how everything ties in. I recommend the following links as a means of getting started:

http://eventscripts.com/

http://python.eventscripts.com/

http://forums.mattie.info/

http://addons.eventscripts.com/

Popularity: 6%

1 Star2 Stars3 Stars4 Stars5 Stars
4 votes, average: 4.5 out of 5
Loading ... Loading ...

  • Using Eventscripts to mod CS Source
  • Eventscripts 2.0 - now with Python
  • Greasemonkey Reddit Filter
  • Discussion

    9 comments for “Writing your first mod for Counter Strike Source”

    1. If you want to beef up the content:

      Step 4.5

      Please show the standard contents of an event var. This will give a first clue as to the available functionality.

      Also, are there other forms to the API? (i.e. not `def event_name(event_var))

      Posted by Rick Hull | November 16, 2007, 1:27 am
    2. Hello…Thanks for the nice read, keep up the interesting posts..what a nice Friday

      Posted by Brad Garrett | November 16, 2007, 7:08 am
    3. Rick: the contents of each event_var for a given event are documented here:

      http://www.eventscripts.com/pages/Category:Valve_Events

      The only way to register events in espython is to create a function with the event name; there is another included language known as ESShell, but it's pretty much superseded by python in every way, which is why I chose not to write about it.

      Posted by Daniel | November 16, 2007, 9:25 am
    4. wow nice! thanks

      Posted by mike | January 23, 2008, 6:28 am
    5. This code wouldn't work…I had to indent like so:

      def player_jump(event_var):
      es.msg(event_var['es_username'] + ' has jumped')

      else it won't work. Don't know if thats just me or what, but great tutorial i must say

      Posted by mike | January 24, 2008, 12:14 am
    6. Yeah, mike - sorry about that, I've yet to get indentation working properly for code on the site.

      I posted up a second guide with a bit more detail and extra examples, if anyone is interested in learning more:

      http://bluesuncorp.co.uk/2007/12/16/using-eventscripts-to-mod-cs-source

      Posted by Daniel | January 24, 2008, 12:51 pm
    7. Thanks :P Very Nice :)

      Posted by SoMeOnE | June 6, 2008, 6:37 pm
    8. it worked ty

      Posted by infoman | July 2, 2008, 11:52 pm

    Post a comment

    Categories




    starbucks mug free shipping
    far cry singe player
    free downloadable games for my pc
    funny mp3 s free to download
    100 web download freeware sites
    jump start flat belly diet
    invalid login attempts facebook
    fable 2 xbox walkthrough for chests
    download s club 7 songs free
    download snes music
    free downloads of girls
    sms on diwali
    debenhams taunton
    shelley sprague celebrity rehab
    robbs celeb news
    buy thanksgiving promise video
    definition of skin cancer
    where to buy euros in connecticut
    buy online professional books
    song lyrics for misery business
    books on mystery schools
    cracked norton anti virus 2008
    keygen nod32
    old version downloads microsoft word
    microsoft works 4.0 free downloads
    mcafee shredder send to
    macrovision software manager uninstall
    instrumental music legal free mp3 download
    kaspersky 6.0 code free
    eset nod32 antivirus crack
    download adobe photoshop 7.0 for free
    need password to uninstall nod32
    eset nod32 reviews
    eset nod32 antivirus v3.0.636 serials
    windows xp downloadable music
    software free download telephone chat webcam
    video conferencing software for home use
    ubuntu 8.1 download
    the best key generators for software
    pc spyware doctor license
    free download of photoshop cs3
    serial panda titanium antivirus 3.00
    microsoft office word 2000 download
    young girl old man youporn
    websites like youporn
    tube8 similar web sites
    fuckface tube8
    sex on youtube like websites
    streamsex cum movies
    like sites redtube
    dark sex porn
    websites like youporn and pornhub
    sites like empornium
    websights like pornhub
    free 3 min porn videos
    pornographic myspace emocations
    myspace sex videos
    sexy myspace mini clips
    home made latina porn
    halloween porn witch
    free ipod rip software for mac
    adult finder friend personals single dating
    real sex facebook
    british mother facebook porn site
    program to download videos from megarotic
    downloading video from panasonic pv-gs39
    adultfriendfinder asutralia
    free adult sex partner finder
    adult and children dental partners
    adult friends finder free cam
    boyfriend adult chat rooms betrayed trust
    adult dating services marsing idaho
    free office tools drawing download
    panda software antivirus onlione
    free photoshop 7.0 download
    free key generators for antivirus
    download ubuntu 8.10
    review pc tools spyware doctor
    download videos no software
    for ever nod32
    nod32 actualizado
    free downloads to fix windows xp
    nod32 3.0 cracked
    software webcam broadcast website chat
    eset nod32 freezes start menu
    download free adobe photoshop cs3 extended
    avast bart license
    antivirus program avg
    kaspersky versus bitdefender chart
    download goggle earth plus
    freewares windows
    free download microsoft office word 2000
    adobe photoshop cs4 download
    duke on facebook
    free checkbook software palm os
    great free antivirus
    free java chat applets software
    mp3 editing free software
    shareware free sims 2 downloads
    arc software freeware shareware free download
    free ware spyware removal tool
    panasonic free software video editing pv-dv103d
    what about spybot kaspersky doesnt like
    free legal music mp3 downloads
    download free microsoft word processor
    macrovision software manager
    mcafee privacy shield
    free download of microsoft word2000 tutorial
    nod32 security
    christopher norton
    free trial download microsoft office 2000
    spyware doctor key reg
    photoshop downloads in korea
    panda antivirus software online scan
    Keygen Crack
    ubuntu 8.10 download
    free nokia 7650 software video recorder
    webcam software chatrooms
    free windows 98 software downloads
    microsoft works windows me download
    nod32 free
    nod32 trouble
    update virus definitions antivirus nod32
    nod32 v3.0.642 full serial
    free download adobe photoshop cs
    kolweb-n trojan warning avast
    avg antivirus 7.0.143
    bitdefender internet security 2008 trial download
    download microsoft office professional plus 2007
    free goggle earth download
    download photoshop cs3 trial
    adobe photoshop cs4 free download
    ciara jenner uk facebook
    free buisness forms shareware downloads
    golf handicap software free
    free download new version kasper antivirus
    free mp3 file editing software
    free desktop chat monitoring software
    free pda ble software demo shareware
    ad aware lavasoft free spyware removal
    free video conversion software forum
    cantasia freewares
    kaspersky website
    mp3downloadnet and legal
    zonealarm macrovision software manager agent
    mcafee antivirus for sale london ontario
    download for microsoft professional office 2000
    nod32 full free download
    download microsoft word addins
    pop up blockers or norton
    program to download videos from megarotic
    adultfriendfinder cindy paradise
    sexy facebook pictures
    free full length home made pornos
    facebook porn video
    porno halloween costumes
    myspace bi-sexual
    myspace las vegas porn videos
    myspace sex peeps and videos
    hookers free porn videos
    adult partners
    gresham adult friends finder
    adult sex partner finder
    download video from msn
    adultfriendfinder 3
    program to download videos from megarotic
    misadventures in sex facebook
    facebook porn
    adult finder friend personals single dating
    halloween porn pictures
    mac free software web
    home made porn movvies
    millionaires who give money for free
    how to download songs onto an ipod
    porn videos japanese free model
    porn stars that have myspace
    myspace sex peeps and videos
    sexy guy myspace layout codes
    sites like pornorama
    websights like pornhub
    porn websites like redtube
    other sites like pornhub
    porn stories of seniors having sex
    sites like all that jazz
    free streamsex videos
    tube8 nice teen fuck movie
    sites similar to tube8
    where you can get the free paris hilton video
    sites like youporn redtube badjojo
    youporn perky tits
    download microsoft office outlook 2002
    cannot remove panda antivirus
    adobe photoshop tasuta download
    spyware doctor purpose
    Keygen 2008
    download ubuntu 8.10
    hires video call software
    webcam software chat rooms
    windows xp optimizer download
    free download photoshop cs3 extended
    free download of adobe photoshop cs4
    john luke hargis facebook
    free antivirus protection plus
    free chat video software
    mp3 editing software free
    free shareware pop up blocker downloads
    free shareware business card software
    8830 free software
    free spyware download and removal
    free archos video software
    flash freewares
    sims 2 free time torrent
    downloadable mobile games for xda atom
    gitex shoppers 2006
    Google Chrome Process Manager
    auburn and blonde hair
    halloween giraffe costumes
    happy diwali quotes
    Paris Hilton Sex Pics
    how to download songs onto an ipod
    how to create users in li
    how to make shareaza download faster
    how to earn money for 10
    how to earn extre money
    how to eat sushi and sashimi
    tell me how to get pregnant
    how to get rid of bee's
    how to install a rain chain
    how to kiss a womans foot
    learn how to breath easyer
    how to make money legally
    fitness how to lose stomach fat
    hows to lose weight fast
    how to make homade bombs
    how to make website your background
    how to make quick money online
    how to remove radio 1997 accord
    how to access toshiba restore partition
    how to save media streams
    how to secure the internet
    how to seduce your neighbours mom
    learn how to sell colorado
    how to tie a sari
    how to uninstall spywarehunter
    how to upload a 2meg video
    how to use gameboy gameshark
    how to watch a baseball game
    Ariel Perazzoli And Ground And Fernando Picon dowland Baltak download Blackdeath music download Brian Simpson top mp3 Dark Latin Groove instrumental Delicatessen download Des Esseintes and Negru Voda buy mp3 Dr. Dooom mp3 downloads Eclipse download songs Foetus Corruptus mp3 songs Gilberto Santa Rosa music downloading John Serrie and Gary Stroutsos mp3 online Kaysha mp3s La Sonora Dinamita download songs Loony Tunes and Noriega music Matt Berry dowland Mercado Negro mp3 online Michael Brook, U.Shrinivas mp3 song Morley Grey new mp3 N.E.R.D. mp3 downloads Patti Labelle And The Blue Belles review Piano Room pop Pony Up! english mp3 Raymond Scott downloads S.C.A.R.D. all mp3 Seeed instrumental Steve Forbert mp3 song Tractors download mp3 Victoria Abril mp3 online Yeasayer review All Natural music downloading Anorganik mp3s Billie Holiday mp3 online Don Byas albums Earl Hines With Paul Gonsalves songs Foreign Beggars pop Lady Antebellum mp3 downloads Linda Ronstadt and Aaron Neville mp3 song Los Straitjackets music to download Metal Majesty mp3 songs Mick Karn get mp3 Nova new mp3 Ocultan pop Onmyouza pop Pati Yang pop Patrick Hernandez mp3 downloads Peter Kater and Nawang Khechog album Saimir Pirgu music Staatskapelle Dresden, con. Eugen Jochum get mp3 Stakka and Hochi music search Sunn O))) downloadable music Uncle Kracker song downloads Anton Nikkila download songs Avec Tristesse downloadable music Bakflip english mp3 Claudionor Germano mp3 online Cristina Dona music DJ Honda feat. Jeru the Damaja mp3s dot(.) mp3 music Earl Fatha Hines and His Orchestra get mp3 Francesco Tristano And Danton Eeprom dowland Fyyralyyra music search Jaga Jazzist downloadable music Keyo new mp3 Lisa Gerrard and Pieter Bourke music search Pop Levi song downloads Princess Superstar and Alexander Technique mp3 online Red Roses For A Blue Lady albums Ronny Jordan Meets DJ Krush music downloading Sean Hayes best mp3 Shimon and Sonic mp3s Skid Row music Spirit and Jennifer Bolton downloadable music Sun Kil Moon mp3s Zeki Muren download mp3 Abbie Gale music Adrian Enescu albums Alex Kidd review Bernard Wright mp3s Beyonce new mp3 Clancy Brothers and Tommy Makem download mp3 David Nichtern and Steve Gorn song downloads Death By Stereo mp3 search Die Zipfelbuben new mp3 Emou music search Joe Cocker downloads Johnny Griffin - Eddie Lockjaw Davis downloads Kim Thayil and Jello Biafra mp3 music Lorien music download Los Temerarios mp3 downloads Mu 330 downloads Nelson Hawk downloadable music Ozma mp3 song Scolohofo mp3 search Silver review Soha mp3 online Starecase music download Stone Roses pop Theodor Zox mp3s Troggs mp3 music