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: Advanced Variables.

A Tutorial for Counter-Strike: Source

Members see zero ads. Membership is 100% free

The basics of eventscripts Variables.

Ok by now I expect you all to be pro scripters, and know every command known to eventscripts. Jokes. Ok this tutorial is going to show you how to add more stuff to events. It's hard to explain, so I will just get straight into it, and show you what I mean. In the previous tutorial I showed you how to issue commands when a player spawns, using the following method: [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] Now we are going to build on this, and make it issue those commands to the terrorist team only. [code] event player_spawn { if (event_var(es_userteam) = 2) do { 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] Ok, now look at the second command: [code]if (event_var(es_userteam) = 2) do[/code]. This command checks the users team, and determines whether the script is continued depending on the users team. [b]Terrorist team = 2[/b], [b]Counter Terrorists team = 3[/b], [b]Spectators team = 1[/b]. Now we will give each team a different set of commands when they spawn. [code] event player_spawn { if (event_var(es_userteam) = 2) do { 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). } if (event_var(es_userteam) = 3) do { es_give event_var(userid) weapon_ak47 es est_health event_var(userid) + 100 es_tell event_var(userid) #multi #greenYou were given an AK47 es_tell event_var(userid) #multi #greenYour STEAMID is:#lightgreen event_var(es_steamid). } [/code] As you can see, we gave the terrorists an awps, and the CT's ak47s and 100 health. If you look closely, you will see an EST command. Est, mani, source mod commands can be entered into scripts, same as a eventscripts command. If you are going to enter it into the script though, be sure to always start the line with es. Example(s): [code] es_delayed 10 ma_give event_var(userid) weapon_awp[/code] - WORKS [code] es ma_give event_var(userid) weapon_awp[/code] - WORKS [code] ma_give event_var(userid) weapon_awp[/code] - DOES NOT WORK Also keep in mind, the syntax symbols [code] { }[/code] These are Very important! Your script will not work, if there are an uneven number of these anywhere. Commands under the same Event (event player_spawn etc) and on the same syntax line: [code] event player_spawn { commmand_line_1 { commmand_line_2 { commmand_line_3 { commmand commmand commmand } commmand_line_3 } commmand_line_2 } commmand_line_1 } End player_spawn [code] Any commands under command line 1, will be executed at the same time. Commands on command line 2, will be issued at the same time, provided they pass the checks for command line 1. Same thing for command line 3. Here is an example of syntax, with proper commands: [code] event player_spawn { if (event_var(es_userteam) == 2) do { if (event_var(es_steamid) in server_var(admins)) do { es playerset color event_var(userid) 255 255 255 255 } else do { es_tell event_var(userid) you do not have the permission to do this! } } else do { es_tell event_var(userid) You must be on the Terrorist team to do this! } } [/code] This script pretty much checks the players team when they spawn, and if it is equal to the team specified (in this case terrorists) it will continue on with the second command line. If however, the team is not the same as the script, he would receive the text: You must be on the Terrorist team to do this! This is caused by the command [code]else do[/code] If we didn't want the players to receive a message or another command etc, we would have done the following: [code] event player_spawn { if (event_var(es_userteam) == 2) do { if (event_var(es_steamid) in server_var(admins)) do { es playerset color event_var(userid) 255 255 255 255 } } } [/code] As you can see, there are now only 6 Syntax symbols; 3 open and 3 close. You MUST ALWAYS HAVE THE SAME AMOUNT OF CLOSED SYNTAX AS YOU DO OPEN. OK now I am going to show you how to use block Load properly. The following script will check the status of the player when they type a chat command, and issue commands accordingly: [code] Block load { es_xsetinfo admins "STEAM:X:X:XXXXXXX ; STEAM:X:X:XXXXXXX" es_setinfo access_msg "You Do not have the access to use this command!" } event player_say { if (event_var(text) equalto "!admin") do { if (event_var(es_steamid) in server_var(admins)) do { es_tell event_var(userid) You are an Admin! } else do { es_tell event_var(userid) server_var(access_msg) } } } [/code] You can see now, in block load, that there are two new commands. Es_setinfo and Es_xsetinfo. These commands are very handy when you want to use config settings, or just don't want to type the same thing over and over again. The only difference between the two commands, is that es_setinfo expands, where as es_xsetinfo doesn't. Es_xsetinfo is a lot better for the processor, as it is executed quicker. I don't know to much about expanding variables, this time of night anyway, so I won't go into it. As you can see, there are two steamIDs in the the first line: [code]es_xsetinfo admins "STEAM:X:X:XXXXXXX ; STEAM:X:X:XXXXXXX"[/code] This is setting the information that these steam ids are admins. Now if you reference the line: [code]if (event_var(es_steamid) in server_var(admins)) do[/code] You will see that it checks the variable set for admins. Since the Steam ids are in there, the command line will continue on. Well that's it for Episode two of this series. The answer to the last tutorials question is something like this: [code] block load { es_xmsg I AM LOADED! } block unload { es_xmsg I AM UNLOADED! } event player_team { es_tell event_var(userid) welcome to our server event_var(es_username), enjoy your stay! } event round_start { es sv_gravity 280 } event player_spawn { es_give event_var(userid) weapon_awp } [/code] Ok, I want you to create a script, that does the following: [list] [*]Checks the players steamid, to see if it is in the admin list, after the command is typed. [*]Tells the player he cannot use this command if he isn't in the list [*]Issues an awp to the player who is able to use the command. [*]Gives the admin an awp when he spawns in. [/list] The answer to this one will be given in tutorial 3. Good luck!

Comments

Sign up to access this!

No comments yet

Embed

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

Studio

Sign up to access this!

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 10y ago
Offline
15,763 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 4.6k
  • access_time 10y

More from Submitter

menu

More Scripting Tutorials

bcp.crwdcntrl.net tracking pixel