Description
Provides some helper functions for both ESS and ESP scripts.
To use from ESS scripts, this addon must be loaded (es_load sh).
To use in ESP scripts, this script must be present on the server and imported as in
[syntax="python"]import sh[/syntax]
The functions provided currently:
[list]
[*][list]
[*][color=blue]sh_holdindexprop[/color] index property value seconds
[*][color=green]sh.holdindexprop[/color](index, property, value, seconds)
[*][color=green]sh.holdplayerprop[/color](userid, property, value, seconds)
[*]Just like es_setindexprop/es.setindexprop/es.setplayerprop except the value is re-set on every tick for specified time. Example property is "CBasePlayer.localdata.m_vecBaseVelocity"
[/list]
[*][list]
[*][color=blue]sh_linearindexprop[/color] index property start_value end_value seconds
[*][color=green]sh.linearindexprop[/color](index, property, start_value, end_value, seconds)
[*][color=green]sh.linearplayerprop[/color](userid, property, start_value, end_value, seconds)
[*]Just like sh_holdindexprop/sh.holdindexprop/sh.holdplayerprop except that instead of applying the same value every tick, the value is altered linearly between start and end values. Supports numerical and vectorstring values (integers are converted to floats).
[/list]
[*][list]
[*][color=green]sh.functionalindexprop[/color](index, property, start_value, end_value, seconds, modifier)
[*][color=green]sh.functionalplayerprop[/color](userid, property, start_value, end_value, seconds, modifier)
[*]Just like sh.linearindexprop/sh.linearplayerprop except that the value being set is not the value linearly itself but the value returned my modifier function.[/list]
[*][list]
[*][color=blue]sh_linearcmd[/color] start_value end_value seconds command parameters
[*][color=green]sh.linearcommand[/color](start_value, end_value, seconds, function, pre_args, post_args, kw)
[*]Goes linearly through values from start_value to end_value and executes command/function each tick passing the value along with other arguments.
[*]The parameters in sh_linearcmd can contain special token %% which will be replaced by the value each time. If this token is not found, then it is automatically appended as the last parameter to the command.
[*]The extra arguments for sh.linearcommand can be given as three objects: two tuples and one dict. The pre_args are inserted to the function call before the value, the post_args are inserted to the function call after the value. The keyword arguments are added to the call. All of these parameters are optional.
[/list]
[*][list]
[*][color=green]sh.functionalcommand[/color](start_value, end_value, seconds, modifier, function, pre_args, post_args, kw)
[*]Just like sh.linearcommand except that you pass extra modifier function like with sh.functionalindexprop.
[/list]
[*][list]
[*][color=green]sh.getargs[/color](start)
[*]To be used with commands registered with es.regcmd, es.regclientcmd and es.regsaycmd. This function returns all the arguments as a normal Python list.
[*]The optional start parameter can be used to specify the first parameter of the list (default: 0)
[/list]
[*][list]
[*][color=green]sh.dbgobj[/color](message, object, level)
[*]Prints debug information about any Python object to the console.
[*]The message parameter is used to give a name for the object.
[*]The optional level parameter is the debug message level to filter the output by eventscripts_debug server variable (default: 0)
[/list]
[/list]
Example usage:
[syntax="python"]import sh, playerlib
import math, vecmath
#make smooth bigger jump without affecting gravity
def player_jump(ev):
sh.linearplayerprop(ev['userid'], 'CBasePlayer.localdata.m_vecBaseVelocity', '0,0,0', '0,0,30', 0.5)
# use functionalplayerprop to make the user perform circular movement
def es_player_chat(ev):
if ev['text'] == 'roll':
sh.functionalplayerprop(ev['userid'], 'CBasePlayer.localdata.m_vecBaseVelocity', 0, 4*math.pi, 3, sineit)
def sineit(x):
return vecmath.vector((20*math.sin(x),20*math.cos(x),20))
[/syntax]
See the roll effect from above example at Xfire Video: [url]http://www.xfire.com/video/101ad/[/url]
Suggestions for more features can be made in [url=http://forums.mattie.info/cs/forums/viewtopic.php?t=24662]forums[/url]!