wcs

All other Source.Python topics and issues.
BASON
Junior Member
Posts: 5
Joined: Wed Aug 25, 2021 12:58 pm

wcs

Postby BASON » Wed Nov 10, 2021 7:20 pm

Hi there everyone!

I am working on my Warcraft-Source server and I started using this version instead of the SourceMod War3Source mod.
I am not very good at Source-Python but I was wondering if someone maybe could make some commands that will make it possible to make a player unkillable for a few seconds, so the player will only drop down to 1 health, but be impossible to kill, is this something that can be made?
Articha
Junior Member
Posts: 4
Joined: Tue Sep 21, 2021 12:13 pm
Location: Russia

Postby Articha » Fri Nov 19, 2021 11:06 pm

This code below didn't have cooldown or anything else. Make this for urself. I'm making WCS based on skills (WCSSKills), instead of races.

Syntax: Select all

# SayText2
from messages import SayText2 as ST2

# Commands
from commands.typed import TypedSayCommand
from commands import CommandReturn

# Entities
from entities import TakeDamageInfo
from entities.hooks import EntityPreHook, EntityCondition
from entities.entity import Entity

# Delay
from listeners.tick import Delay

# Set, that contains players with active god
god_set = set()

@EntityPreHook(EntityCondition.is_player, 'on_take_damage')
def O_T_D(args):
""" Take damage hook """

# Getting TameDamageInfo
info = TakeDamageInfo._obj(args[1])

# Getting player from pointer arg
player = Entity._obj(args[0])

# Abort if player not in active god set
if player not in god_set: return

# This hurt kills target?
if info.damage > player.health:

# Making dmg to leave 1 hp
# Change 1, if u want to leave more hp
info.damage = player.health-1

@TypedSayCommand('/god')
def god_activate(comm):

# Getting calling player index
player = Entity(comm.index)

# Adding player to the active god set
god_set.add(player)

# Notifying player
ST2("\4[WCS]\1 You have activated god for \5 3 seconds\1").send(player.index)

# Delay deactivate
Delay(3, god_set.remove, args=(player,))

# Block command from chat (won't appear in chat)
# If u want to show, delete this line
return CommandReturn.BLOCK

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests