This site is a testing version, but all data is shared with the live forum.


Raised This Month: $12 Target: $400
 3% 

[Tutorial] How to Instant Respawn on Free For All


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 05-27-2024 , 11:59   [Tutorial] How to Instant Respawn on Free For All
Reply With Quote #1

Hello.
If you ever tried to make a FFA server with instant respawn then you know it will bug and people at respawn will get their team changed. (The real instant respawn, not the 0.1 respawn task)

In order to fix it you must trick the Ham_Killed with something very simple.

Instead of this:
Code:
public Killed(victim, attacker, shouldgib)
{
	if( victim != attacker && (1 <= attacker <= g_iMaxPlayers) )
	{
		new vteam = fm_get_user_team(victim)
		if( vteam == fm_get_user_team(attacker) )
		{
			fm_set_user_team(victim, vteam == 1 ? 2 : 1)
			ExecuteHamB(Ham_Killed, victim, attacker, shouldgib)
			fm_set_user_team(victim, vteam)
			return HAM_SUPERCEDE
		}
	}
	return HAM_IGNORED
}

public Ham__Killed_Post(iVictim)
{
	if(is_user_connected(iVictim))
	{
		set_pev(iVictim, pev_deadflag, DEAD_RESPAWNABLE)
		dllfunc(DLLFunc_Think, iVictim)
	}
}
Make this:
Code:
public Killed(victim, attacker, shouldgib)
{
	if( victim != attacker && (1 <= attacker <= g_iMaxPlayers) )
	{
		new vteam = fm_get_user_team(victim)
		if( vteam == fm_get_user_team(attacker) )
		{
			fm_set_user_team(victim, vteam == 1 ? 2 : 1)
			ExecuteHamB(Ham_Killed, victim, attacker, shouldgib)
			g_iChangeTeam[victim] = vteam
			return HAM_SUPERCEDE
		}
	}
	return HAM_IGNORED
}

public Ham__Killed_Post(iVictim)
{
	if(is_user_connected(iVictim))
	{
		if(g_iChangeTeam[iVictim])
		{
			fm_set_user_team(iVictim, g_iChangeTeam[iVictim])
			g_iChangeTeam[iVictim] = 0
		}
		
		set_pev(iVictim, pev_deadflag, DEAD_RESPAWNABLE)
		dllfunc(DLLFunc_Think, iVictim)
	}
}
And your instant respawn will work just fine on your ffa server.

This Plugin is an edit to ConnorMcLeod's FFA plugin.
Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "Free For All"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.0.6"

#define OFFSET_TEAM	114
#define fm_get_user_team(%1)	get_pdata_int(%1,OFFSET_TEAM)
#define fm_set_user_team(%1,%2)	set_pdata_int(%1,OFFSET_TEAM,%2)

new g_iMaxPlayers, g_iChangeTeam[MAX_PLAYERS]

public plugin_init()
{
	register_plugin( PLUGIN, VERSION, AUTHOR )

	RegisterHam(Ham_Killed, "player", "Ham__Killed_Post", true)

	RegisterHam(Ham_TraceAttack, "player", "TraceAttack")
	RegisterHam(Ham_TakeDamage, "player", "TakeDamage")
	RegisterHam(Ham_Killed, "player", "Killed")
}

public TraceAttack(victim, attacker, Float:damage, Float:direction[3], tracehandle, damagebits)
{
	if( victim != attacker && (1 <= attacker <= g_iMaxPlayers) )
	{
		new vteam = fm_get_user_team(victim)
		if( vteam == fm_get_user_team(attacker) )
		{
			fm_set_user_team(victim, vteam == 1 ? 2 : 1)
			ExecuteHamB(Ham_TraceAttack, victim, attacker, damage, direction, tracehandle, damagebits)
			fm_set_user_team(victim, vteam)
			return HAM_SUPERCEDE
		}
	}
	return HAM_IGNORED
}

public TakeDamage(victim, idinflictor, attacker, Float:damage, damagebits)
{
	if( victim != attacker && (1 <= attacker <= g_iMaxPlayers) )
	{
		new vteam = fm_get_user_team(victim)
		if( vteam == fm_get_user_team(attacker) )
		{
			fm_set_user_team(victim, vteam == 1 ? 2 : 1)
			ExecuteHamB(Ham_TakeDamage, victim, idinflictor, attacker, damage, damagebits)
			fm_set_user_team(victim, vteam)
			return HAM_SUPERCEDE
		}
	}
	return HAM_IGNORED
}

public Killed(victim, attacker, shouldgib)
{
	if( victim != attacker && (1 <= attacker <= g_iMaxPlayers) )
	{
		new vteam = fm_get_user_team(victim)
		if( vteam == fm_get_user_team(attacker) )
		{
			fm_set_user_team(victim, vteam == 1 ? 2 : 1)
			ExecuteHamB(Ham_Killed, victim, attacker, shouldgib)
			g_iChangeTeam[victim] = vteam
			return HAM_SUPERCEDE
		}
	}
	return HAM_IGNORED
}

public Ham__Killed_Post(iVictim)
{
	if(is_user_connected(iVictim))
	{
		if(g_iChangeTeam[iVictim])
		{
			fm_set_user_team(iVictim, g_iChangeTeam[iVictim])
			g_iChangeTeam[iVictim] = 0
		}
		
		set_pev(iVictim, pev_deadflag, DEAD_RESPAWNABLE)
		dllfunc(DLLFunc_Think, iVictim)
	}
}
__________________

Last edited by Jhob94; 05-27-2024 at 12:01.
Jhob94 is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old Yesterday , 09:28   Re: [Tutorial] How to Instant Respawn on Free For All
Reply With Quote #2

PHP Code:
#define isPlayer(%1,%2)    (%1 != %2 && (1 <= %2 <= g_iMaxPlayers)) 
Code:
public plugin_init() {     //..     g_iMaxPlayers = get_maxplayers() } //.. if( victim != attacker && (1 <= attacker <= g_iMaxPlayers) ) ~> if( isPlayer(victim,attacker ) )
__________________
mlibre is offline
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old Yesterday , 11:21   Re: [Tutorial] How to Instant Respawn on Free For All
Reply With Quote #3

It’s the same. I made an edit to an existing approved plugin, why would i bother with something like that?
__________________
Jhob94 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:12.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode