Raised This Month: $ Target: $400
 0% 

Spectator semiclip


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wAyz
Senior Member
Join Date: Feb 2010
Location: Germany
Old 12-25-2016 , 23:00   Spectator semiclip
Reply With Quote #1

I want to have semiclip on spectators (alive) to both teams, any ideas?

Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>

new bool:plrSolid[33]
new bool:plrRestore[33]
new plrTeam[33]

new maxplayers

new semiclip_team;

new g_team;

public plugin_init() {
	register_plugin("Team Semiclip","1.31","skyjur")
	
	register_forward(FM_PlayerPreThink, "preThink")
	register_forward(FM_PlayerPostThink, "postThink")
	
	register_forward(FM_AddToFullPack, "addToFullPack", 1)
	
	register_event("HLTV", "EventNewRound", "a", "1=0", "2=0");
	
	semiclip_team = register_cvar("semiclip_team", "1");
	
	maxplayers = get_maxplayers()
}

public addToFullPack(es, e, ent, host, hostflags, player, pSet)
{
	if(player)
	{
		if(plrSolid[host] && plrSolid[ent] && (g_team == 2 || g_team == 1 && plrTeam[host] == plrTeam[ent]))
		{
			set_es(es, ES_Solid, SOLID_NOT)
			set_es(es, ES_RenderMode, kRenderTransAlpha)
			set_es es, ES_RenderAmt, floatround(entity_range(host, ent) * 255.0 / 90.0, floatround_floor) ;
		}
	}
}

FirstThink()
{
	for(new i = 1; i <= maxplayers; i++)
	{
		if(!is_user_alive(i))
		{
			plrSolid[i] = false
			continue
		}
		
		plrTeam[i] = get_user_team(i)
		plrSolid[i] = pev(i, pev_solid) == SOLID_SLIDEBOX ? true : false
	}
}

public preThink(id)
{
	static i, LastThink
	
	if(LastThink > id)
	{
		FirstThink()
	}
	LastThink = id

	
	if(!plrSolid[id]) return
	
	for(i = 1; i <= maxplayers; i++)
	{
		if(!plrSolid[i] || id == i) continue
		
		if(g_team == 2 || g_team == 1 && plrTeam[i] == plrTeam[id])
		{
			set_pev(i, pev_solid, SOLID_NOT)
			plrRestore[i] = true
		}
	}
}

public postThink(id)
{
	static i
	
	for(i = 1; i <= maxplayers; i++)
	{
		if(plrRestore[i])
		{
			set_pev(i, pev_solid, SOLID_SLIDEBOX)
			plrRestore[i] = false
		}
	}
}

public EventNewRound()
{
	g_team = get_pcvar_num(semiclip_team);
}

Last edited by wAyz; 12-25-2016 at 23:02.
wAyz 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 22:45.


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