free for all

A place for requesting new Source.Python plugins to be made for your server.

Please request only one plugin per thread.
Alex Winchester
Junior Member
Posts: 6
Joined: Tue May 16, 2023 4:30 pm

free for all

Postby Alex Winchester » Tue May 16, 2023 4:56 pm

Hello source-python,

I would like to request a free for all plugin like this one from sourcemod, https://forums.alliedmods.net/showthread.php?p=1465985%20
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: free for all

Postby satoon101 » Tue May 16, 2023 5:39 pm

I don't have much time right now, but all you would need to do is remove the GunGame specific code from GG-FFA:

https://github.com/GunGame-Dev-Team/Gun ... /gg_ffa.py
Image
Alex Winchester
Junior Member
Posts: 6
Joined: Tue May 16, 2023 4:30 pm

Re: free for all

Postby Alex Winchester » Tue May 16, 2023 8:53 pm

satoon101 wrote:I don't have much time right now, but all you would need to do is remove the GunGame specific code from GG-FFA:

https://github.com/GunGame-Dev-Team/Gun ... /gg_ffa.py


i'm sorry i have no idea what you mean,
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Re: free for all

Postby satoon101 » Tue May 16, 2023 11:11 pm

Sorry, it was more for if someone wanted to write it up for you really quick, since I did not have the time. But, I have a few minutes now, so try this:

Syntax: Select all

# =============================================================================
# >> IMPORTS
# =============================================================================
# Source.Python
from entities import TakeDamageInfo
from entities.entity import Entity
from entities.hooks import EntityCondition, EntityPostHook, EntityPreHook
from memory import make_object
from memory.hooks import use_pre_registers


# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
# Store a variable to know whether to revert the team or not
_take_damage_dict = {}


# =============================================================================
# >> HOOKED FUNCTIONS
# =============================================================================
@EntityPreHook(EntityCondition.is_bot_player, 'on_take_damage')
@EntityPreHook(EntityCondition.is_human_player, 'on_take_damage')
def _pre_take_damage(stack_data):
"""Change the victim's team if they are on the attacker's team."""
take_damage_info = make_object(TakeDamageInfo, stack_data[1])
attacker = Entity(take_damage_info.attacker)
if attacker.classname != 'player':
return

victim = make_object(Entity, stack_data[0])
if victim.team_index != attacker.team_index:
return

address = stack_data[0].address
if address in _take_damage_dict:
return

_take_damage_dict[address] = (victim.index, victim.team_index)

# Change the player's team by using the m_iTeamNum property
victim.team_index = 5 - victim.team_index


@EntityPostHook(EntityCondition.is_bot_player, 'on_take_damage')
@EntityPostHook(EntityCondition.is_human_player, 'on_take_damage')
def _post_take_damage(stack_data, return_value):
"""Revert the victim's team if necessary."""
with use_pre_registers(stack_data):
address = stack_data[0].address

if address not in _take_damage_dict:
return

index, team = _take_damage_dict.pop(address)
Entity(index).team_index = team
Image
Alex Winchester
Junior Member
Posts: 6
Joined: Tue May 16, 2023 4:30 pm

Re: free for all

Postby Alex Winchester » Wed May 17, 2023 12:51 am

Oh okay,

it works

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 15 guests