[CSGO] Howto respawn a player?
Re: [CSGO] Howto respawn a player?
Okay thank you all. Very active community. It's working quite well now :) no problems so far.
Re: [CSGO] Howto respawn a player?
iPlayer wrote:Syntax: Select all
from listeners.tick import Delay
from messages import SayText2
from players.entity import Player
# Create message only once, use it multiple times
respawn_message = SayText2('Prepare for respawn!')
def respawn(player):
# Player might have been respawned already by some reason
if not player.dead:
return
# Also, specs (or unassigneds, I don't remember) are never dead
if player.team not in (2, 3):
return
player.respawn()
@Event('player_death')
def on_player_death(game_event):
player = Player.from_userid(game_event['userid'])
Delay(6, respawn, player) # Use Delay class to delay something
respawn_message.send(player.index)
Again, use Delay class if you want to delay something.
Even if you need threading for reason, use GameThread from listeners.tick module. It's a subclass of threading.Thread, so it accepts the same arguments and works the same way.
Just wanted to mention that you shouldn't pass the Player instance to the Delay class. If the player left the server during the delay, you are probably going to crash. An alternative would be to cancel the delay when the player left the server.
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 125 guests