Hi there, I'm currently looking for a plugin content creator to help me with an issue.
Intro -
My friend, who I will link his Steam below, owns a popular (ish) TF2 Zombies server, in which a team of RED Engineer 'survivors' must fend of BLU medic 'zombies'. The Engineers cannot build sentries, and the Medics are melee only. The problem we face currently though, is that after a RED engineer dies, he must swap to BLU, as the RED engineers cannot respawn, but the BLU medics can. And yes, we can just ask them to switch, but people refuse, and spy on other 'Survivor' spots, allowing them to switch and instantly know where to go.
What I'm looking for is a plugin, that can be activated post-setup, and will remain active till it is turned off (round end), that instantly switches any dead RED engineer to BLU. I assume this may be hard, and I have good experience with Python, but not Python.source. Also, commands to activate the auto-switching and deactivate it would be handy, if not necessary, as we have a script that runs on setup start that could easily house the activate command.
Lazyneer (Server Owner)
[TF2] Switch Team on death (For red only)
Re: [TF2] Switch Team on death (For red only)
Should be as simple as:
Syntax: Select all
from commands.typed import TypedServerCommand
from events import Event
from events.manager import event_manager
from players.entity import Player
@TypedServerCommand("switch_death_on")
def switch_enable(command_info):
try:
event_manager.register_for_event("player_death", player_death)
except ValueError:
print("Already on.")
@TypedServerCommand("switch_death_off")
def switch_disable(command_info):
try:
event_manager.unregister_for_event("player_death", player_death)
except ValueError:
print("Already off.")
def player_death(event):
player = Player.from_userid(event["userid"])
if player.get_team() == 2:
player.set_team(3)
@Event("teamplay_round_active")
def round_start(event):
try:
event_manager.register_for_event("player_death", player_death)
except ValueError:
pass
@Event("teamplay_round_win")
def round_end(event):
try:
event_manager.unregister_for_event("player_death", player_death)
except ValueError:
pass
Last edited by quartata on Tue Aug 09, 2016 10:52 pm, edited 1 time in total.
Re: [TF2] Switch Team on death (For red only)
Woops, noticed that you wanted it to start when setup ends not when the round begins. Should do that now.
Re: [TF2] Switch Team on death (For red only)
Is cool man, thanks for the help!
Re: [TF2] Switch Team on death (For red only)
Loaded on server, errors.
Anyone can fix it?
Anyone can fix it?
Re: [TF2] Switch Team on death (For red only)
It says line 9 in your stack trace:
This is line 1 in quartata's code, what did you add before the line 9?
Code: Select all
File '../addons/source-python/plugins/REDSWITCH/REDSWITCH.py', line 9
from commands.typed import TypedServerCommand
This is line 1 in quartata's code, what did you add before the line 9?
Last edited by Mahi on Wed Aug 10, 2016 10:53 am, edited 1 time in total.
Re: [TF2] Switch Team on death (For red only)
Ah, thats where I put myinfo and import sourcemod, should i lower those down?
Re: [TF2] Switch Team on death (For red only)
I'm pretty sure there's an error in those lines, may we see them?
Also, what do you mean import sourcemod? I don't think Source.Python can import SM..
Also, what do you mean import sourcemod? I don't think Source.Python can import SM..
Re: [TF2] Switch Team on death (For red only)
This is it currently - The bottom 2 sections for activating on round start and deactivating on round end were unnecessary, so cleaned up - Also, the plugin info was placeholder, as we were going to test first before fully fleshing out credits.
- L'In20Cible
- Project Leader
- Posts: 1536
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
Re: [TF2] Switch Team on death (For red only)
Missing closing bracket.
Re: [TF2] Switch Team on death (For red only)
I am not sure why you would be trying to import sourcemod, but you should certainly remove that. Once you fix the SyntaxError (which is because you are missing the closing } for your myinfo variable), you will get an ImportError, unless you have some sort of sourcemod plugin for Source.Python installed that isn't used in the above plugin. Just an fyi, but Source.Python has absolutely nothing to do with SourceMod.
Re: [TF2] Switch Team on death (For red only)
wow, really just a bracket? welp, thanks guys
Re: [TF2] Switch Team on death (For red only)
Also, for adding info for the plugin, see:
http://wiki.sourcepython.com/developing ... PluginInfo
http://wiki.sourcepython.com/developing ... PluginInfo
Who is online
Users browsing this forum: No registered users and 72 guests