Spawnprotection
Spawnprotection
Hey guys I just tried to make a small Spawnprotection mod.
Let me know what I could have done better and what is good!
And yes I stole some of the format stuff from satoon^^
Let me know what I could have done better and what is good!
And yes I stole some of the format stuff from satoon^^
- Attachments
-
- spawnprotection.zip
- (871 Bytes) Downloaded 1214 times
Nice script! You can steal all the formatting you want from me, I encourage it.
One pointer, though, for the script. Since you use player_spawn, you should only give spawn protection to the player that spawned. If you only want to give beginning of round spawn protection, you should use round_freeze_end.
Satoon
One pointer, though, for the script. Since you use player_spawn, you should only give spawn protection to the player that spawned. If you only want to give beginning of round spawn protection, you should use round_freeze_end.
Satoon
-
- Developer
- Posts: 168
- Joined: Sat Jul 07, 2012 1:58 am
-
- Junior Member
- Posts: 10
- Joined: Tue Aug 21, 2012 5:52 pm
Here is how your script could work with [wiki]EasyPlayer[/wiki], which will become more functional in the future.
Syntax: Select all
from players import EasyPlayer
@Event
def player_spawn(GameEvent):
# Chat Messages
userid = GameEvent.GetInt('userid')
player = EasyPlayer(userid)
Chat(player.index, '[Spawnprotection] Enabled!')
say_delay = Timer(prot_time, Chat, (player.index, '[Spawnprotection] Disabled!'))
say_delay.start()
# Godmode
player.SetPropInt("CBaseAnimating.m_nHitboxSet", 2)
prot_delay = Timer(prot_time, player.SetPropInt, ["CBaseAnimating.m_nHitboxSet", 0])
prot_delay.start()
# Color settings
real_color = (255*65792+255)
if player.team == 2:
color = (255*2)
if player.team == 3:
color = (255*65536)
player.SetPropInt("CBaseEntity.m_clrRender", color)
rc_delay = Timer(prot_time, player.SetPropInt, ["CBaseEntity.m_clrRender", real_color])
rc_delay.start()
Monday wrote:Here is how your script could work with [wiki]EasyPlayer[/wiki], which will become more functional in the future.Syntax: Select all
from players import EasyPlayer
@Event
def player_spawn(GameEvent):
# Chat Messages
userid = GameEvent.GetInt('userid')
player = EasyPlayer(userid)
Chat(player.index, '[Spawnprotection] Enabled!')
say_delay = Timer(prot_time, Chat, (player.index, '[Spawnprotection] Disabled!'))
say_delay.start()
# Godmode
player.SetPropInt("CBaseAnimating.m_nHitboxSet", 2)
prot_delay = Timer(prot_time, player.SetPropInt, ["CBaseAnimating.m_nHitboxSet", 0])
prot_delay.start()
# Color settings
real_color = (255*65792+255)
if player.team == 2:
color = (255*2)
if player.team == 3:
color = (255*65536)
player.SetPropInt("CBaseEntity.m_clrRender", color)
rc_delay = Timer(prot_time, player.SetPropInt, ["CBaseEntity.m_clrRender", real_color])
rc_delay.start()
Wouldn't you need to import the Chat() function ?
-Tuck
- Painkiller
- Senior Member
- Posts: 751
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
- Painkiller
- Senior Member
- Posts: 751
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
I updated it, I'll likely do some further updates in the future, but for now I just made it do exactly what it used to do using updated functions.
- Attachments
-
- spawnprotection.zip
- (1.88 KiB) Downloaded 990 times
A few things. First, this is Kami's plugin. While he has not updated it yet, he has been on in the last 2 weeks. We should probably allow him the opportunity to update his plugin.
Second, instead of getting and setting the color as you do, I would suggest using the PlayerEntity's 'color' property:
Also, there is no need for 3 different delays. Simply use one and make a function that removes the protection:
Obviously, if the player disconnects or the map changes, you will want to cancel the delay, but that is another matter.
Second, instead of getting and setting the color as you do, I would suggest using the PlayerEntity's 'color' property:
Syntax: Select all
# Somewhere in the global scope
from colors import RED
from colors import BLUE
protected_red = RED.with_alpha(64)
protected_blue = BLUE.with_alpha(64)
# Inside player_spawn
current_color = player.color
if player.team == 2:
player.color = protected_red
else:
player.color = protected_blue
Also, there is no need for 3 different delays. Simply use one and make a function that removes the protection:
Syntax: Select all
tick_delays.delay(prot_time, remove_protection, player, current_color)
def remove_protection(player, color):
SayText2(message="[SpawnProtection] Disabled!").send(player.index)
player.color = color
player.set_property_int('m_nHitboxSet', 0)
Obviously, if the player disconnects or the map changes, you will want to cancel the delay, but that is another matter.
- Painkiller
- Senior Member
- Posts: 751
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
Who is online
Users browsing this forum: No registered users and 132 guests