GeSHi (python):
# ../addons/eventscripts/wcs_pitfall/wcs_pitfall.py
import es
import gamethread
import playerlib
pitfalls = {}
def load():
if not es.exists('command', 'wcs_pitfall'):
es.regcmd('wcs_pitfall', 'wcs_pitfall/command', 'wcs_pitfall <attacker> <identifier effected> <x> <y> <z> <radius> [time]')
def command():
if es.getargc() not in (7, 8):
es.dbgmsg(0, 'WCS ERROR: wcs_pitfall <attacker> <identifier effected> <x> <y> <z> <radius> [time]')
return
attacker = int(es.getargv(1))
ident = es.getargv(2)
location = map(float, [es.getargv(x) for x in range(3, 6)])
radius = int(float(es.getargv(6))
timeHere = None
if es.getargc() == 8:
timeHere = float(es.getargv(7))
pitfalls[attacker] = {'location': location, 'radius': radius, 'ident': ident}
if timeHere is not None:
gamethread.delayed(timeHere, player_death, {'userid':attacker})
def player_footstep(ev):
x, y, z = map(float, [ev[x] for x in ('x', 'y' ,'z'))
for pitfall in pitfalls:
if int(ev['userid']) not in playerlib.getUseridList(pitfalls[pitfall]['ident']:
continue
xx, yy, zz = pitfalls[pitfall]['location']
if ((x - xx) ** 2 + (y - yy) ** 2 + (z - zz) ** 2) ** 0.5 < pitfalls[pitfall]['radius']:
es.server.queuecmd('es_xsetpos %s %s %s %s' % (ev['userid'], x, y, z - 50) )
es.tell(ev['userid'], '#multi', '#green :: #lightgreenPitfall - #defaultYou have been trapped by %s\'s pitfall trap' % es.getplayername(pitfall) )
es.tell(pitfall, '#multi', '#green :: #lightgreenPitfall - #defaultYou have trapped %s by your pitfall!' % ev['es_username'])
def player_disconnect(ev):
player_death(ev)
def player_death(ev):
userid = int(ev['userid'])
if userid in pitfalls:
del pitfalls[userid]
def round_end(ev):
pitfalls.clear()
Not tested... All you do is save this at the file location which is in the comment on the first line... You can then use this in keygroup races such as:
"#"
{
"name" "Hunter"
"author" "freddukes"
"required_level" "0"
"maximum_level" "0"
"allow_only" "0"
"teamlimit" "0"
"preloadcmd" "0"
"player_spawn_cmd" "0"
"round_start_cmd" "0"
"round_end_cmd" "0"
"numberofskills" "1"
"numberoflevels" "3"
"skillnames" "PitFall"
"skilldescr" "Set A pitfall trap to trap enemies"
"skillcfg" "player_ultimate"
"skill1_setting" "es_xset radius 50|es_xset radius 100|es_xset radius 200"
"skill1_cmd" "es_getplayerlocation wcs_x wcs_y wcs_z server_var(wcs_userid);es_getplayerteam wcs_team server_var(wcs_userid); if (server_var(wcs_team) == 2) then wcs_pitfall server_var(wcs_userid) #ct server_var(wcs_x) server_var(wcs_y) server_var(wcs_z); if (server_var(wcs_team) == 3) then wcs_pitfall server_var(wcs_userid) #t server_var(wcs_x) server_var(y) server_var(z)"
"skill1_sfx" "0"
"ultimate_cooldown" "15"
}
}
The command is:
wcs_pitfall <player who is doing the pitfall> <playerget/set filter ('#all,#t,#ct,!dead') for exaple> <x origin> <y origin> <z origin> [Optional: Time to stay]
If the time to stay is not gave, then it will stay until either the player disconnects, dies, or the round ends
Remember this was not tested, and I wrote it in the "post reply" box, And I hate keygroup coding Lol
-freddukes