
Thank You & have a great weekend.


Syntax: Select all
from players.entity import Player
from players.helpers import index_from_userid
from events import Event
from messages import SayText2
players = {}
@Event('map_start')
def map_start(args):
players.clear()
@Event('player_spawn')
def player_spawn(args):
userid = args.get_int('userid')
if not userid in players:
players[userid] = 0
@Event('player_death')
def player_death(args):
userid = args.get_int('userid')
attacker = args.get_int('attacker')
if attacker > 0:
if not Player(index_from_userid(userid)).team == Player(index_from_userid(attacker)).team:
players[userid] = 0
players[attacker] += 1
if players[attacker] == 12:
godmode(attacker)
def godmode(userid):
player = Player(index_from_userid(userid))
player.set_godmode(True)
SayText2('\x04You have now godmode for 45seconds!').send(player.index)
player.delay(45, unset, (userid,))
def unset(userid):
player = Player(index_from_userid(userid))
player.set_godmode(False)
SayText2('\x04Your godmode is now off!').send(player.index)
Syntax: Select all
from players.entity import Player
from players.helpers import index_from_userid
from events import Event
from messages import SayText2
players = {}
@Event('map_start')
def map_start(args):
players.clear()
@Event('player_spawn')
def player_spawn(args):
userid = args.get_int('userid')
if not userid in players:
players[userid] = 0
@Event('player_death')
def player_death(args):
userid = args.get_int('userid')
attacker = args.get_int('attacker')
if attacker > 0:
if not Player(index_from_userid(userid)).team == Player(index_from_userid(attacker)).team:
players[userid] = 0
players[attacker] += 1
value = getValue(players[attacker])
if value == 12:
Player(index_from_userid(attacker)).delay(0.1, godmode, (attacker,))
def godmode(userid):
player = Player(index_from_userid(userid))
player.set_godmode(True)
SayText2('\x04You have now godmode for 45seconds!').send(player.index)
player.delay(45, unset, (userid,))
def unset(userid):
player = Player(index_from_userid(userid))
player.set_godmode(False)
SayText2('\x04Your godmode is now off!').send(player.index)
def getValue(i):
if i in _values:
return _values[i]
return None
_values = {12: '12'}
Syntax: Select all
from players.entity import Player
from events import Event
from players.dictionary import PlayerDictionary
from messages import SayText2
class StreakPlayer(Player):
def __init__(self, index):
super().__init__(index)
self.consecutive_kills = 0
streak_players = PlayerDictionary(StreakPlayer)
@Event('player_death')
def player_death(ev):
victim = streak_players.from_userid(ev['userid'])
attacker = streak_players.from_userid(ev['attacker'])
victim.consecutive_kills = 0
attacker.consecutive_kills += 1
if attacker.consecutive_kills == 12:
attacker.consecutive_kills = 0
attacker.set_godmode(True)
attacker.delay(45.0,_reset_godmode,(attacker,))
SayText2(f"{attacker.name} has reached 12 kills and is in godmode now!").send()
def _reset_godmode(player):
player.set_godmode(False)
SayText2(f"{player.name} is no longer in godmode!").send()
Kami wrote:Hey daren, you can give this a try.Syntax: Select all
from players.entity import Player
from events import Event
from players.dictionary import PlayerDictionary
from messages import SayText2
class StreakPlayer(Player):
def __init__(self, index):
super().__init__(index)
self.consecutive_kills = 0
streak_players = PlayerDictionary(StreakPlayer)
@Event('player_death')
def player_death(ev):
victim = streak_players.from_userid(ev['userid'])
attacker = streak_players.from_userid(ev['attacker'])
victim.consecutive_kills = 0
attacker.consecutive_kills += 1
if attacker.consecutive_kills == 12:
attacker.consecutive_kills = 0
attacker.set_godmode(True)
attacker.delay(45.0,_reset_godmode,(attacker,))
SayText2(f"{attacker.name} has reached 12 kills and is in godmode now!").send()
def _reset_godmode(player):
player.set_godmode(False)
SayText2(f"{player.name} is no longer in godmode!").send()
You can edit the messages to your likings :)
Syntax: Select all
from players.entity import Player
from events import Event
from messages import SayText2
class StreakPlayer(Player):
caching = True # Uses caching
def __init__(self, index):
super().__init__(index)
self.consecutive_kills = 0
def _reset_godmode(self):
self.set_godmode(False)
SayText2(f"{self.name} is no longer in godmode!").send()
@Event('player_death')
def player_death(ev):
victim = StreakPlayer.from_userid(ev['userid'])
victim.consecutive_kills = 0
# Try to get the attacker, or exit the call if not a valid player
try:
attacker = StreakPlayer.from_userid(ev['attacker'])
except ValueError:
return
attacker.consecutive_kills += 1
if attacker.consecutive_kills == 12:
attacker.consecutive_kills = 0
attacker.set_godmode(True)
attacker.delay(45.0, attacker._reset_godmode)
SayText2(f"{attacker.name} has reached 12 kills and is in godmode now!").send()
Code: Select all
2021-03-15 23:42:30 - sp - EXCEPTION
[SP] Caught an Exception:
Traceback (most recent call last):
File "..\addons\source-python\packages\source-python\events\listener.py", line 92, in fire_game_event
callback(game_event)
File "..\addons\source-python\plugins\godmode\godmode.py", line 17, in player_death
attacker = streak_players.from_userid(ev['attacker'])
File "..\addons\source-python\packages\source-python\players\dictionary.py", line 50, in from_userid
return self[index_from_userid(userid)]
ValueError: Conversion from "Userid" (0) to "Index" failed
Syntax: Select all
# ../killstreak_god/killstreak_god.py
# Python
from time import time
# Source.Python
from events import Event
from messages import SayText2
from players.entity import Player
class StreakPlayer(Player):
caching = True # Uses caching
def __init__(self, index):
super().__init__(index)
self.consecutive_kills = 0
self.reset_delay = None
def grant_godmode(self, duration):
"""Gives godmode to the player for the specified duration."""
try:
# Let's see if there's a reset delay.
running = self.reset_delay.running
except AttributeError:
running = False
# Well, is there?
if running:
# Update the execution with the newer duration.
self.reset_delay.exec_time = time() + duration
# Nope.
else:
self.set_godmode(True)
self.reset_delay = self.delay(duration, self._reset_godmode)
def _reset_godmode(self):
self.set_godmode(False)
SayText2(f"{self.name} is no longer in godmode!").send()
@Event('player_death')
def player_death(ev):
victim = StreakPlayer.from_userid(ev['userid'])
victim.consecutive_kills = 0
# Try to get the attacker, or exit the call if not a valid player
try:
attacker = StreakPlayer.from_userid(ev['attacker'])
except ValueError:
return
attacker.consecutive_kills += 1
if attacker.consecutive_kills == 12:
attacker.consecutive_kills = 0
attacker.grant_godmode(duration=45)
SayText2(f"{attacker.name} has reached 12 kills and is in godmode now!").send()
Code: Select all
def beacon(attacker):
x,y,z = es.getplayerlocation(attacker)
r = random.randint(0,255)
g = random.randint(0,255)
b = random.randint(0,255)
effectlib.drawCircle((x,y,z + 10),radius=80,steps=12,halo="sprites/greenglow1.vmt",model="sprites/greenglow1.vmt",seconds=0.7,width=10,endwidth=10,red=r,green=g,blue=b)
r2 = random.randint(0,255)
g2 = random.randint(0,255)
b2 = random.randint(0,255)
effectlib.drawCircle((x,y,z + 30),radius=60,steps=12,halo="sprites/greenglow1.vmt",model="sprites/greenglow1.vmt",seconds=0.7,width=10,endwidth=10,red=r2,green=g2,blue=b2)
r3 = random.randint(0,255)
g3 = random.randint(0,255)
b3 = random.randint(0,255)
effectlib.drawCircle((x,y,z + 50),radius=40,steps=12,halo="sprites/greenglow1.vmt",model="sprites/greenglow1.vmt",seconds=0.7,width=10,endwidth=10,red=r3,green=g3,blue=b3)
es.emitsound('player', attacker, 'buttons/blip2.wav', 1.0, 0.7)
try:
if not playerlib.getPlayer(attacker).isdead:
gamethread.delayedname(1, 'beacon_loop', beacon, (attacker))
except:
pass
daren adler wrote:Hello scripters. Is there a way to add a beacon on while the player is in god mode on here ?. Here is a beacon i would like to have please.
I know the beacon is from es, but did not know how to show it. Thank you and have a great weekendCode: Select all
def beacon(attacker):
x,y,z = es.getplayerlocation(attacker)
r = random.randint(0,255)
g = random.randint(0,255)
b = random.randint(0,255)
effectlib.drawCircle((x,y,z + 10),radius=80,steps=12,halo="sprites/greenglow1.vmt",model="sprites/greenglow1.vmt",seconds=0.7,width=10,endwidth=10,red=r,green=g,blue=b)
r2 = random.randint(0,255)
g2 = random.randint(0,255)
b2 = random.randint(0,255)
effectlib.drawCircle((x,y,z + 30),radius=60,steps=12,halo="sprites/greenglow1.vmt",model="sprites/greenglow1.vmt",seconds=0.7,width=10,endwidth=10,red=r2,green=g2,blue=b2)
r3 = random.randint(0,255)
g3 = random.randint(0,255)
b3 = random.randint(0,255)
effectlib.drawCircle((x,y,z + 50),radius=40,steps=12,halo="sprites/greenglow1.vmt",model="sprites/greenglow1.vmt",seconds=0.7,width=10,endwidth=10,red=r3,green=g3,blue=b3)
es.emitsound('player', attacker, 'buttons/blip2.wav', 1.0, 0.7)
try:
if not playerlib.getPlayer(attacker).isdead:
gamethread.delayedname(1, 'beacon_loop', beacon, (attacker))
except:
pass![]()
.
cssbestrpg wrote:daren adler wrote:Hello scripters. Is there a way to add a beacon on while the player is in god mode on here ?. Here is a beacon i would like to have please.
I know the beacon is from es, but did not know how to show it. Thank you and have a great weekendCode: Select all
def beacon(attacker):
x,y,z = es.getplayerlocation(attacker)
r = random.randint(0,255)
g = random.randint(0,255)
b = random.randint(0,255)
effectlib.drawCircle((x,y,z + 10),radius=80,steps=12,halo="sprites/greenglow1.vmt",model="sprites/greenglow1.vmt",seconds=0.7,width=10,endwidth=10,red=r,green=g,blue=b)
r2 = random.randint(0,255)
g2 = random.randint(0,255)
b2 = random.randint(0,255)
effectlib.drawCircle((x,y,z + 30),radius=60,steps=12,halo="sprites/greenglow1.vmt",model="sprites/greenglow1.vmt",seconds=0.7,width=10,endwidth=10,red=r2,green=g2,blue=b2)
r3 = random.randint(0,255)
g3 = random.randint(0,255)
b3 = random.randint(0,255)
effectlib.drawCircle((x,y,z + 50),radius=40,steps=12,halo="sprites/greenglow1.vmt",model="sprites/greenglow1.vmt",seconds=0.7,width=10,endwidth=10,red=r3,green=g3,blue=b3)
es.emitsound('player', attacker, 'buttons/blip2.wav', 1.0, 0.7)
try:
if not playerlib.getPlayer(attacker).isdead:
gamethread.delayedname(1, 'beacon_loop', beacon, (attacker))
except:
pass![]()
.
How long the beacon should be?
cssbestrpg wrote:So the one beacon duration is 45 seconds?
Syntax: Select all
# ../killstreak_god/killstreak_god.py
# Python
import random
from time import time
# Source.Python
from engines.sound import engine_sound
from events import Event
from messages import SayText2
from players.entity import Player
from players.helpers import index_from_userid
from effects import TempEntity
from engines.precache import Model
from mathlib import Vector
from filters.recipients import RecipientFilter
effect_model = Model('sprites/greenglow1.vmt')
class StreakPlayer(Player):
caching = True # Uses caching
def __init__(self, index):
super().__init__(index)
self.consecutive_kills = 0
self.reset_delay = None
def grant_godmode(self, duration):
"""Gives godmode to the player for the specified duration."""
try:
# Let's see if there's a reset delay.
running = self.reset_delay.running
except AttributeError:
running = False
# Well, is there?
if running:
# Update the execution with the newer duration.
self.reset_delay.exec_time = time() + duration
# Nope.
else:
self.set_godmode(True)
self.reset_delay = self.delay(duration, self._reset_godmode)
def _reset_godmode(self):
self.set_godmode(False)
SayText2(f"{self.name} is no longer in godmode!").send()
@Event('player_death')
def player_death(ev):
victim = StreakPlayer.from_userid(ev['userid'])
victim.consecutive_kills = 0
# Try to get the attacker, or exit the call if not a valid player
try:
attacker = StreakPlayer.from_userid(ev['attacker'])
except ValueError:
return
attacker.consecutive_kills += 1
if attacker.consecutive_kills == 12:
attacker.consecutive_kills = 0
attacker.grant_godmode(duration=45)
r = random.randint(0,255)
g = random.randint(0,255)
b = random.randint(0,255)
beamRing(attacker, 0, 350, 10, 45, 3, 2, r, g, b)
emitsound(attacker, 'buttons/blip2.wav', 1.0, 0.7)
SayText2(f"{attacker.name} has reached 12 kills and is in godmode now!").send()
def emitsound(userid, sound, volume, attenuation):
engine_sound.precache_sound(sound)
index = index_from_userid(userid)
engine_sound.emit_sound(RecipientFilter(), index, 0, sound, volume, attenuation)
def beamRing(userid, startRadius, endRadius, zplus, lifeTime, width, amplitude, r, g, b, a=255):
x,y,z = getPlayerLocation(userid)
tempEnt = TempEntity('BeamRingPoint')
tempEnt.red = r
tempEnt.green = g
tempEnt.blue = b
tempEnt.alpha = a
tempEnt.center = Vector(x, y, z + zplus)
tempEnt.start_radius = startRadius
tempEnt.end_radius = endRadius
tempEnt.life_time = lifeTime
tempEnt.start_width = width
tempEnt.end_width = width
tempEnt.amplitude = amplitude
tempEnt.halo_index = effect_model
tempEnt.model_index = effect_model
tempEnt.create()
def getPlayerLocation(userid):
x,y,z = Player.from_userid(userid).get_key_value_string('origin').split(' ')
return (float(x), float(y), float(z))
Users browsing this forum: No registered users and 47 guests