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 playerspawn { esgive eventvar(userid) weaponawp estell eventvar(userid) #multi #greenYou were given an awp estell eventvar(userid) #multi #greenYour STEAMID is:#lightgreen eventvar(essteamid). } [/code]
Now we are going to build on this, and make it issue those commands to the terrorist team only. [code] event playerspawn { if (eventvar(esuserteam) = 2) do { esgive eventvar(userid) weaponawp estell eventvar(userid) #multi #greenYou were given an awp estell eventvar(userid) #multi #greenYour STEAMID is:#lightgreen eventvar(essteamid). } } [/code] Ok, now look at the second command: [code]if (eventvar(esuserteam) = 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 playerspawn { if (eventvar(esuserteam) = 2) do { esgive eventvar(userid) weaponawp estell eventvar(userid) #multi #greenYou were given an awp estell eventvar(userid) #multi #greenYour STEAMID is:#lightgreen eventvar(essteamid). } if (eventvar(esuserteam) = 3) do { esgive eventvar(userid) weaponak47 es esthealth eventvar(userid) + 100 estell eventvar(userid) #multi #greenYou were given an AK47 estell eventvar(userid) #multi #greenYour STEAMID is:#lightgreen eventvar(essteamid). } [/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] esdelayed 10 magive eventvar(userid) weaponawp[/code] - WORKS [code] es magive eventvar(userid) weaponawp[/code] - WORKS [code] magive eventvar(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 playerspawn etc) and on the same syntax line: [code] event playerspawn { commmandline1 { commmandline2 { commmandline3 { commmand commmand commmand } commmandline3 } commmandline2 } commmandline1 } End playerspawn [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 playerspawn { if (eventvar(esuserteam) == 2) do { if (eventvar(essteamid) in servervar(admins)) do { es playerset color eventvar(userid) 255 255 255 255 } else do { estell eventvar(userid) you do not have the permission to do this! } } else do { estell eventvar(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 playerspawn { if (eventvar(esuserteam) == 2) do { if (eventvar(essteamid) in servervar(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 { esxsetinfo admins "STEAM:X:X:XXXXXXX ; STEAM:X:X:XXXXXXX" essetinfo access_msg "You Do not have the access to use this command!" }
event playersay { if (eventvar(text) equalto "!admin") do { if (eventvar(essteamid) in servervar(admins)) do { estell eventvar(userid) You are an Admin! } else do { estell eventvar(userid) servervar(accessmsg) } } } [/code] You can see now, in block load, that there are two new commands. Essetinfo and Esxsetinfo. 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 essetinfo expands, where as esxsetinfo doesn't. Esxsetinfo 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]esxsetinfo 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 (eventvar(essteamid) in servervar(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 playerteam { estell eventvar(userid) welcome to our server eventvar(es_username), enjoy your stay! }
event roundstart { es svgravity 280 }
event playerspawn { esgive eventvar(userid) weaponawp } [/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!

