Ads keep us online. Without them, we wouldn't exist. We don't have paywalls or sell mods - we never will. But every month we have large bills and running ads is our only way to cover them. Please consider unblocking us. Thank you from GameBanana <3

Learning Eventscripts Pt1: Basics.

A Tutorial for Counter-Strike: Source

Members see zero ads. Membership is 100% free

learning Eventscripts

Hey all. I have nothing to do and sleep is never an option, so I thought I might post a few quick tutorials on the website, teaching you all how to read and write in Event scripts. [b][u]What can ES (Event Scripts) be used for?[/b][/u] Pretty much anything, to put it blunt. Event Scripts whether it be ES or PY (Python) can be used to create almost anything you can imagine, whether it be a floating Disco ball that shoots out lasers, plays music and has coloured lighting and smoke all through the map (my favorite), or whether it be a simple Welcome script that welcomes a player to the server. First of all, I will show you a key starting points, and when/why commands are executed by these. [b][u]Block Load[/b][/u] - This executes commands when the script is loaded. This is where you would set most of your variables (we will get into that later). [b][u]Block Unload[/b][/u] - This is executed when the script is unloaded. This is where you would delete content you don't want up (popups, keygroups etc). [b][u]Event player_spawn[/b][/u] - This is executed when a player spawns. [b][u]Event player_death[/b][/u] - This is executed when a player dies. [b][u]Event es_map_start[/b][/u] - This is executed when a new map is started. [b][u]Event round_start[/b][/u] - This is executed when a round is started. [b][u]Event round_end[/b][/u] - This is executed when a round ends (note for later: you have to manually get the userID, steamID and username in this) There are LOADS more, but I won't get into it. [b][u]So What the hell is the above commands used for?[/b][/u] Yeah it does seem rather strange. These are pretty much triggers. If you wanted your commands to start when a player spawns for example, you would put them under the event player_spawn group. Here is an example of a welcome script. This script will welcome a player to the server, quoting their name after they choose a team. [code] Block load { es_xmsg #multi #greenWelcome Script Loaded! } event player_team { es_xmsg #multi #green Welcome to our server#lightgreen event_var(es_username) #greenEnjoy your stay! } Block Unload { es_xmsg #multi #greenWelcome Script UnLoaded! } [/code] Ok, now look at the first part: Block Load. You will see a simple line saying: [code]es_xmsg #multi #greenWelcome Script Loaded![/code]. This will display a multi coloured message to everyone telling them the script is loaded. Any letters after [color="#006400"]#green[/color] will be a dark green colour, any letters after [color="#00FF00"]#lightgreen[/color] will be a light-green colour, and letters after [code][color="#FFFF00"]#default[/color][/code] will be a default yellow colour. NOTE: If you want multiple colours in your line, always put #multi before your text. Example: [code] es_xmsg #multi #greenHello, #lightgreenMy name is #defaultDaniel.[code] Hello will be in dark green. My name is will be in light green. Daniel will be in yellow. Now look at the second part: Event player_team. This triggers when the player joins a team. [code]es_xmsg #multi #green Welcome to our server#lightgreen event_var(es_username) #greenEnjoy your stay![/code] As you can see there is a new command here: [code]event_var(es_username)[/code]. This is pretty much getting the username of the player who joined the team, and adding it into the line. So if I joined the server, it would look like this: [code]Welcome to our server I'm The New Guy, Go Easy :D Enjoy your stay![/code] It just gets your username and replaces itself with that. Simple. And again, block unload was unnecessary, but i thought I mite add it to show you what it is. It will display the text when the script is unloaded. Another example of User Variables is as follows: [code] event player_spawn { es_give event_var(userid) weapon_awp es_tell event_var(userid) #multi #greenYou were given an awp es_tell event_var(userid) #multi #greenYour STEAMID is:#lightgreen event_var(es_steamid). } [/code] This is pretty much giving the player an awp, telling them they received an awp, and then telling them their steamid. [code]Event_var(userid)[/code] This is the ID given to you when you join a server. If you type status into console, you will see something like this: [code]# 89 "Tosser | AZZAR" STEAM_0:1:22174748 07:19 85 0 active[/code] The User ID in this one would be 89. [code]88 "derp" STEAM_0:1:22174748 07:22 81 0 active[/code] The User ID in this one would be 88 You get the idea. Now look at the other variable: event_var(es_steamid). This one is pretty self explanatory, it gets the players steam id: STEAM_0:1:22174748 This can be used for many things: verifying a player before they can execute a command (admin only commands etc), identifying a players KeyGroup (advanced stuff, don't worry about it if your still learning) and loads more! So concludes part one of this series. I will leave you with a test, to find out your understanding. Just post your answer in a reply below. Make a script, that tells me its loaded when it loads, and that its unloaded when it unloads. Make the script welcome the player to the server when he chooses a team. Make the script change the sv_gravity to 280 sv_gravity 280 when the round starts. Make the script issue a player a weapon when he spawns. Good luck!

Comments

Sign up to access this!
  • im_the_new_guy avatar
    im_the_new_guy username pic Joined 11y ago
    Offline
    15,815 points Ranked 348th
    24 medals 2 legendary 3 rare
    • Submitted 50 Maps Medal icon
    • 10 years a member Medal icon
    • 6 years a member Medal icon
    • Returned 1000 times Medal icon
    • Submitted 20 Maps Medal icon
    • Mapper of the Month, November 2013 Medal icon
    access_time 7y
    > **Posted by DillonNProductions** > block load { es_xmsg #multi #default Script Loaded! } > > Event playerteam { esxmsg #multi #defaultWelcome to #greenDNPServers, #default eventvar(esusername) #defaultThanks for visiting! } > > Event roundstart { es_set svgravity 280 } > > Event playerspawn { esgive eventvar(userid) weaponp90 estell eventvar(userid) #multi #greenYou have recieved a P90! estell eventvar(userid) #multi #greenYour STEAMID is eventvar(essteamid). } > > block unload { es_xmsg #multi #defaultAddon has been unloaded. } > > this is mine, let me know if theres errors. i hope there isnt. and how would i load this on my server? also, great tutorial! Hey mate thanks for reading. I have gone through your script. For the most part you have done really well. A few things you will need to fix up though. Now Under block load (i didnt explain this in tutorial) you can use: es_xmsg Script Loaded without the #multi and #default. #multi means that you are going to add multiple colours to the text, and #default is simply the default colour (yellow). Otherwise its looking great. Under event player_team (sorry the BB code change has stuffed how everything is displayed..) you have used es_xmsg on that line. Again, something I didn't explain in tutorial, the main difference between es_xmsg and es_msg is xmsg loads quicker because it displays everything as text and takes no notice of variables where as es_msg will read variables for what they are. An example of that is: es_xmsg "This is myname" Will display - This is a test es_xmsg This is event_var(es_username) will display - This is a Event_var(es_username) es_msg This is event_var(es_username) Will display - This is -- meaning this one works :D The main reason we use es_xmsg is to display raw text messages with pretty colours, otherwise es_msg will work fine. With the event Round_start block. The only required text on the line is: sv_gravity 280. If we wanted to add the gravity as a variable. we would do the following: es_set gravity 340 (anywhere on the script) Then under round_start we would simply put es sv_gravity server_var(gravity) The event player_spawn is perfect (except for the missing _'s but we can blame game banana for that :P) Block unload is also good as well, except for the #multi #default I mentioned about in block load. All in all it is a nice attempt. This tutorial is real old and I haven't laid eyes on it in a while so I apologies if some stuff is misleading. If you every have scripting questions though, shoot me through a PM. Might be a while before I reply, but I reply in detail :D
    Creator of Hide N Seek mod
    URL to post:
  • access_time 7y
    block load { es_xmsg #multi #default Script Loaded! } Event playerteam { esxmsg #multi #defaultWelcome to #greenDNPServers, #default eventvar(esusername) #defaultThanks for visiting! } Event roundstart { es_set svgravity 280 } Event playerspawn { esgive eventvar(userid) weaponp90 estell eventvar(userid) #multi #greenYou have recieved a P90! estell eventvar(userid) #multi #greenYour STEAMID is eventvar(essteamid). } block unload { es_xmsg #multi #defaultAddon has been unloaded. } this is mine, let me know if theres errors. i hope there isnt. and how would i load this on my server? also, great tutorial!
    Bananite
    URL to post:

Embed

menu
Share banner
Image URL
HTML embed code
BB embed code
Markdown embed code

Credits

Key Authors
I'm the new guy, go easy :D
Writer

Submitter

im_the_new_guy avatar
im_the_new_guy username pic Joined 11y ago
Offline
15,815 points Ranked 348th
24 medals 2 legendary 3 rare
  • Submitted 50 Maps Medal icon
  • 10 years a member Medal icon
  • 6 years a member Medal icon
  • Returned 1000 times Medal icon
  • Submitted 20 Maps Medal icon
  • Mapper of the Month, November 2013 Medal icon
im_the_new_guy avatar
im_the_new_guy

Creator
Sign up to access this!
Sign up to access this!
Sign up to access this!

Game

Sign up to access this!

Category

Details

Difficulty Level
Beginner

Attributes

Share

  • Share on Reddit
  • Share on Twitter
  • Share on Facebook
  • favorite 0
  • remove_red_eye 3.6k
  • mode_comment 2
  • access_time 10y
  • access_time 7y

More from Submitter

menu

More Scripting Tutorials