Esx commands
|
es_x versions of EventScripts functions do not expand variables such as server_var() or event_var(). [edit] WarningFor anyone new to EventScripts, 95% of the time you should be using the normal commands. It's recommend that newbies stay away from es_x commands entirely until they get more experienced and understand them. These commands only make things a little faster, but they can cause all sorts of issues if you're not careful with them. [edit] OverviewBasically this means that if you did this example: es_msg The gravity is server_var(sv_gravity) It would 'expand' the server_var(sv_gravity) part before executing the command. So es_msg would broadcast the following message: The gravity is 800 If you instead use the es_xmsg command, it will just treat the line as a lump of text and won't expand or read any variables you reference. So this bad code: es_xmsg The gravity is server_var(sv_gravity) wouldn't do anything with the 'server_var' and just output this (which really makes no sense to anyone): The gravity is server_var(sv_gravity) [edit] Why use es_x commands?In cases where you are 100% certain that you won't need to expand variables, es_x commands can be used to improve performance of your script. Let's say we wanted to create a variable with a particular hard-coded starting value: es_setinfo MyVar 33 In the case above, we're not using server_var and event_var, so it'd be handy if we had a way to tell EventScripts not to look for them. This would speed up performance. This is where an es_x command would come in handy: es_xsetinfo MyVar 33 Now the line will run a few milliseconds faster. The most common case to use es_x commands for performance is when working with if then commands. The [[if] command automatically expands all variables on the line, so any command in the then half could be an es_x command. For example: if (server_var(gravity) notequalto 800) then es_msg Gravity is not normal! gravity: server_var(sv_gravity) Since the if command goes through the entire line and expands variables, it's already expanding all of the variables es_msg needs in the last half. So you could make the line slightly faster by changing es_msg to es_xmsg in this way: if (server_var(gravity) notequalto 800) then es_xmsg Gravity is not normal! gravity: server_var(sv_gravity) The output would be the same, but the speed would slightly increase. |
