Page 1 of 1

Spawnprotection

Posted: Sun Aug 26, 2012 8:41 pm
by Kami
Hey guys I just tried to make a small Spawnprotection mod.

Let me know what I could have done better and what is good!

The attachment spawnprotection.zip is no longer available


And yes I stole some of the format stuff from satoon^^

Posted: Sun Aug 26, 2012 9:12 pm
by satoon101
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

Posted: Sun Aug 26, 2012 9:17 pm
by your-name-here
+1! The first useful script!

Posted: Tue Aug 28, 2012 1:19 am
by paytonpenn
I'm not understanding how its "godding" everyone on each individual spawn.
It could be bot related.. I just tested it offline..

Posted: Tue Aug 28, 2012 2:48 pm
by Kami
Updated the addon to work on player_spawn (its not looping through every player anymore).
Now it can be used on any kind of server :)

Posted: Tue Aug 28, 2012 3:35 pm
by Monday
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()

Posted: Tue Aug 28, 2012 3:38 pm
by Kami
So is EasyPlayer available yet or comes with the next build?

Posted: Tue Aug 28, 2012 3:40 pm
by satoon101
It was committed yesterday, but is not included in the latest download.

Satoon

Posted: Tue Aug 28, 2012 3:50 pm
by Tuck
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 ?

Posted: Tue Aug 28, 2012 3:58 pm
by satoon101
I think he was more showing how you would need to add the EasyPlayer import than just giving a whole script. You would also need to import Timer and Event, which are already included in the script itself.

Satoon

Posted: Tue Aug 28, 2012 4:03 pm
by Monday
satoon101 wrote:I think he was more showing how you would need to add the EasyPlayer import than just giving a whole script. You would also need to import Timer and Event, which are already included in the script itself.

Satoon


Correct. I was just showing how EasyPlayer could be used :)

Posted: Tue Mar 24, 2015 12:46 pm
by Painkiller
This Plugin not work for HL2DM

Posted: Tue Mar 24, 2015 1:12 pm
by Ayuto
This addon was made for a very early version of Source.Python and doesn't work with the latest release. It requires some updates to work again.

Posted: Tue Mar 24, 2015 1:22 pm
by Painkiller
Ok, thanks for the info

Posted: Tue Mar 24, 2015 1:30 pm
by Ayuto
Maybe someone volunteers to update this script. I could do it, but I don't have time today.

Posted: Wed Mar 25, 2015 1:46 am
by necavi
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.

Posted: Wed Mar 25, 2015 4:03 am
by satoon101
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:

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.

Posted: Wed Mar 25, 2015 4:07 am
by necavi
Yeah, that's why I said I would add further updates later. My intention was just to update it as faithfully to the original as possible to start, then do a full rewrite in my version to remove more of the bugs in the original plugin.

Posted: Wed Mar 25, 2015 11:11 am
by Painkiller
Hello,

(Test it in HL2DM)

could you fix this script, it's not working anymore. thanks in advance.


(and the fix from necavi notwork)