Raised This Month: $51 Target: $400
 12% 

EventScripts v0.7.7 beta has released!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mattie
Veteran Member
Join Date: Jan 2005
Old 05-22-2005 , 16:17   EventScripts v0.7.7 beta has released!
Reply With Quote #1

This is the Satisfy-the-Advanced-Scripters release. I put a number of things in here that I've tried to argue around for ages. I'm at the point now where I think these will help things more than they'd hurt. Hopefully you'll be pleasantly surprised. (Info thread with download link: http://forums.alliedmods.net/showthread.php?t=37471)

Changed in this version:
  • 1. Added es_getmoney command for looking-up a player's cash level. Also added eventscripts_cflags to help out once Valve breaks this function (just a matter of time).
    2. Support for nested server_var and event_var syntax. E.g. This syntax should now work: server_var(server_var(event_var(userid))).
    3. if and es_xif have been updated to support the lessthan and greaterthan operators. (I.e. goodbye IsGreaterThan.cfg)
    4. Added es_attackersteamid extended event variable.
    5. Fixed crashes caused by "exec player_say.cfg". This is inappropriate usage, but it certainly shouldn't crash the server. As such, I fixed it such that an event_var() reference outside of an event doesn't crash (but is still undefined in behavior).

Here's the sections of documentation that were updated:
Quote:
Nested Variable Expansion
In EventScripts v0.7.7, support was added such that a nested variable syntax could be used. This allows you to look-up server and event variables indirectly. For example, you could write the following code in a cfg file:
Code:
// EventScripts v0.7.7 
setinfo varname sv_gravity
es_msg The gravity is currently server_var(server_var(varname))
The es_msg line would first look-up the variable "varname" and see that it's "sv_gravity". It would then look-up what is stored in the variable named "sv_gravity" and place that in the text of the command. So the output would be:
Quote:
The gravity is currently 800
The above is an unlikely example. Script writers, though, commonly need to build custom variable names. For example, here's a player_death.cfg that assume variables have been created called "playerteamkills_x" for each player:
Code:
// EventScripts v0.7.7
setinfo varname 0
es_format varname "%1_%2" "playerteamkills" event_var(userid)
es_tell event_var(userid) You have killed server_var(server_var(varname)) team members. Shame on you!
This code uses es_format to build a custom variable name and uses the "server_var(server_var(" syntax to look-up the value indirectly.

...


Conditional Expressions
Last but not least, I added support for if/then statements-- conditional expressions. Here's the syntax:
  • if (token1 equalto token2) then commandstring
    In addition to "equalto", it also supports "notequalto", "lessthan", and "greaterthan". token1 and token2 above must each be a single word, quoted string, or number. EventScripts will expand any variables it finds. (Equivalent to calling "es es_xif".)
    es_xif (token1 equalto token2) then commandstring
    In addition to "equalto", it also supports "notequalto", "lessthan", and "greaterthan". token1 and token2 above must each be a single word, quoted string, or number. No variables are expanded as it is assumed everything is already perfect.
So, if we bundle all of this together, we get a really neat player_death.cfg file:
Code:
// EventScripts v0.2.0 Example
// Some example player_death commands.
if (event_var(headshot) equalto 1) then es_tell event_var(attacker) Now THAT was a good shot!
if (event_var(weapon) equalto "knife") then es_tell event_var(attacker) You humiliated him!
This script will cause a player to get a personalized notification when a player is headshot, as well as when they kill someone with a knife. You can replace the "es_tell" part with anything else you want-- for example, when combined with Mani Admin's plugin, you could play a particular sound. E.g. "[...] then ma_play headshot".

As of EventScripts v0.7.7, the operators lessthan and greaterthan were added. These work just as you'd expect on numbers. Their behavior is undefined when strings are compared, though. Here's an example of its use:
Code:
// EventScripts v0.7.7
// never let the gravity get higher than 800
if (server_var(sv_gravity) greaterthan 800) then sv_gravity 800
...

Extended Event Variables
...
es_attackersteamid - Anytime an event is received that provides "attacker", EventScripts will also set es_attackersteamid to the player's Steam ID. It's accessible like normal event variables as such: event_var(es_attackersteamid).

...

Lookup Functions
...
In EventScripts v0.7.7, support was added for es_getmoney which will look-up a Counter-Strike: Source player's current money supply. Warning this command has a dependency on internal Valve structures which can change on a Steam update. The server variable eventscripts_cflags will need to be alterred at times to prevent this function from causing undefined behavior in your scripts. (Just be aware that using it might cause problems after a Steam update until the new cflags value is available.)

Here's an example of its use in player_spawn.cfg:
Code:
// EventScripts v0.7.7
es_setinfo cash1 0
es_getmoney cash1 event_var(userid)
es_tell event_var(userid) You have server_var(cash1) dollars in your pocket.
Enjoy, and let me know if you have any problems,
-Mattie
Mattie is offline
blade81
Senior Member
Join Date: Apr 2005
Old 05-22-2005 , 19:20  
Reply With Quote #2

Is that download link invisible for me
There is still the version 7.6.
blade81 is offline
ichthys
Veteran Member
Join Date: Dec 2004
Location: []*[]
Old 05-22-2005 , 19:40  
Reply With Quote #3

What a fantastic release! Thanks M!
__________________
ichthys is offline
Mattie
Veteran Member
Join Date: Jan 2005
Old 05-22-2005 , 20:25  
Reply With Quote #4

Quote:
Originally Posted by blade81
Is that download link invisible for me
There is still the version 7.6.
The site is down at the moment, but I forgot to update that site's version number. Try to download it and you'll find it's 7.7.

-Mattie
Mattie is offline
ajax
Veteran Member
Join Date: Jan 2005
Old 05-22-2005 , 20:32  
Reply With Quote #5


thanks
ajax is offline
Ace Rimmer
Senior Member
Join Date: Apr 2005
Old 05-22-2005 , 22:10  
Reply With Quote #6

Fantastic! Just when I was getting comfortable with 7.6! LOL...

Great extras there Mattie, looking forward to using them.
__________________
Smoke me a kipper, I'll be back for breakfast

Main Web Site-Ace Rimmer-System Information
Ace Rimmer is offline
ztaky
Member
Join Date: Mar 2005
Location: Hungary
Old 05-23-2005 , 08:16  
Reply With Quote #7

Mattie!

THANKS!!! My long waited dreams became real!!!

YOU! ARE! THE! GREATEST!!!
__________________
Taki
http://www.smalla.hu
CS:S servers: pub.smalla.hu:27015 & 27014

ztaky is offline
Send a message via MSN to ztaky
ajax
Veteran Member
Join Date: Jan 2005
Old 05-23-2005 , 13:58  
Reply With Quote #8

Mattie, i'm getting something strange with v0.7.7.

these 2 lines of code work...
Quote:
if (server_var(server_var(playerkillvar)) greaterthan server_var(mostkills)) then es_setinfo winner event_var(es_attackername)
if (server_var(server_var(playerkillvar)) greaterthan server_var(mostkills)) then es_setinfo mostkills server_var(server_var(playerkillvar))
but switching their order doesn't (winner doesn't get new value)...
Quote:
if (server_var(server_var(playerkillvar)) greaterthan server_var(mostkills)) then es_setinfo mostkills server_var(server_var(playerkillvar))
if (server_var(server_var(playerkillvar)) greaterthan server_var(mostkills)) then es_setinfo winner event_var(es_attackername)
realizing that i haven't posted the script in its entirety, does this make any sense to you?
ajax is offline
Mattie
Veteran Member
Join Date: Jan 2005
Old 05-23-2005 , 14:51  
Reply With Quote #9

Quote:
Originally Posted by ajax
Mattie, i'm getting something strange with v0.7.7.

these 2 lines of code work...
Quote:
if (server_var(server_var(playerkillvar)) greaterthan server_var(mostkills)) then es_setinfo winner event_var(es_attackername)
if (server_var(server_var(playerkillvar)) greaterthan server_var(mostkills)) then es_setinfo mostkills server_var(server_var(playerkillvar))
but switching their order doesn't (winner doesn't get new value)...
Quote:
if (server_var(server_var(playerkillvar)) greaterthan server_var(mostkills)) then es_setinfo mostkills server_var(server_var(playerkillvar))
if (server_var(server_var(playerkillvar)) greaterthan server_var(mostkills)) then es_setinfo winner event_var(es_attackername)
realizing that i haven't posted the script in its entirety, does this make any sense to you?
So, in pseudocode, the second group would resolve to this:
Code:
// this is just simplified pseudocode, not EventScripts code!
if (kills > mostkills) mostkills = kills
if (kills > mostkills) winner = name
So, executed in that order, it would resolve like this:
  • 1. Is kills (e.g. 2) greater than mostkills (e.g. 1)?
    2. If so, set mostkills to kills (mostkills = 2)
    3. Is kills (2) greater than mostkills (2)?
    4. Nope

So your first ordering is proper. You don't want to change the mostkills value until you're done testing it.

Am I following your code correctly?
-Mattie
Mattie is offline
ajax
Veteran Member
Join Date: Jan 2005
Old 05-23-2005 , 14:59  
Reply With Quote #10

DOH!
ajax is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:31.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode