Jump to content
View in the app

A better way to browse. Learn more.

Forum Supreme-Elite

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Yo,

Voici un plugin que j'avais fais pour une soirée sur le FFA (qui était un mode call of duty, c'est à dire avec série d'élimination) et les récompenses étaient ultra fun (si je me rappelle bien, c'est une simple rocket qui était influencer par la gravité après rocket plasma qui n'est pas influencé par la gravité, mine qui rebondit et explose en faisant des dégâts de zones et attirant tout le monde, la rocket téléguidé c'est à dire que quand vous la lancez, votre vue n'est plus sur votre perso mais sur la rocket et vous la contrôlez et pour finir un genre de bombe nucléaire faisant beaucoup de dégâts et faisant trembler toute la map).

 

Ce code n'a pas été fait entièrement par moi. Toutes les armes viennent du entcontrol (que vous aurez besoin pour compiler sur votre PC et vous aurez besoin de l'extension entcontrol sur votre serveur pour que le plugin fonctionne). Je me suis occupé de coder le reste, c'est à dire la gestion du mod.

 
Ce partage est à titre d'apprentissage pour les futurs sourcepawner.
Pour toutes questions, je suis là pour répondre sur le poste (et uniquement sur le poste, que tout le monde puissent profiter des possibles questions-réponses):

 

https://forums.alliedmods.net/showthread.php?t=157075

 

 

 

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <entcontrol>
#include "stocks.sp"

#define PLUGIN_VERSION "1.56"

#define INVISIBLE 	{255, 255, 255,  0}
#define VISIBLE   	{255, 255, 255, 255}

// -- Globals
// - Some variables
new Handle:kv = INVALID_HANDLE;
new Handle:kvEnts = INVALID_HANDLE;
new gObj[MAXPLAYERS+1];
new gSelectedEntity[MAXPLAYERS+1]; // This is not the grabbed-entity!
new Float:gSavedPos[MAXPLAYERS+1][3];
new Float:gDistance[MAXPLAYERS+1];
new Float:gNextPickup[MAXPLAYERS+1];
new Handle:gTimer;
new Handle:gTimerHudInfo;
new gCollisionOffset;
//new gSelectedEntitySprite;
new gLeaderOffset;
new fakeClient;
new gLaser1;

// Admin Flags
new Handle:gAdminFlagGrab = INVALID_HANDLE;
new Handle:gAdminFlagGrabPlayer = INVALID_HANDLE;
new Handle:gAdminFlagHUD = INVALID_HANDLE;
new Handle:gAdminCanGrabSelf = INVALID_HANDLE;
new Handle:gAdminCanModSelf = INVALID_HANDLE;
new Handle:gNoneAdminsUseGrab = INVALID_HANDLE;

// Spraytrace
new Float:SprayPos[MAXPLAYERS + 1][3];
new String:SprayName[MAXPLAYERS + 1][64];

// Game
new GameType:game;

// Extensions
new bool:SDKHooksLoaded;
new bool:EntControlExtLoaded;



new Handle:gAdminFlagWeapons;

new gSmoke1;
new gHalo1;
new gGlow1;
new gExplosive1;
new bool:g_bHEStuning[MAXPLAYERS+1];


public InitWeapons()
{
	gLaser1 = PrecacheModel("materials/sprites/laser.vmt");
	gSmoke1 = PrecacheModel("materials/effects/fire_cloud1.vmt");
	gHalo1 = PrecacheModel("materials/sprites/halo01.vmt");
	gGlow1 = PrecacheModel("sprites/blueglow2.vmt", true);
	gExplosive1 = PrecacheModel("materials/sprites/sprite_fire01.vmt");
	
	PrecacheModel("models/props_wasteland/rockgranite03b.mdl");
	
	PrecacheSound("weapons/ar2/fire1.wav");
	PrecacheSound("weapons/rpg/rocketfire1.wav");
	PrecacheSound("weapons/explode3.wav");
	PrecacheSound("weapons/physcannon/energy_disintegrate4.wav");
	PrecacheSound("weapons/physcannon/energy_sing_explosion2.wav");
	PrecacheSound("ambient/explosions/citadel_end_explosion2.wav");
	PrecacheSound("ambient/explosions/citadel_end_explosion1.wav");
	PrecacheSound("ambient/energy/weld1.wav");
	PrecacheSound("weapons/flaregun/fire.wav");
}


public OnPluginStart()
{
	HookEvent("player_spawn", Event_PlayerSpawn);
}


public Event_PlayerSpawn(Handle:event,String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event,"userid"));
	g_bHEStuning[client]=false;
}
	

public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
{
if(IsPlayerAlive(client))
{
if(buttons == IN_USE && g_bHEStuning[client]==false)
{
	PrintToChat(client, "Vous pouvez de nouveau bouger");
	g_bHEStuning[client]=true;
	CreateTimer(0.5, TimerStopStun, client);
}
}
}



public Action:TimerStopStun(Handle:timer, any:client)
{
	g_bHEStuning[client]=false;
}













/* 
	------------------------------------------------------------------------------------------
	Command_Rocket
	Rocketlauncher
	------------------------------------------------------------------------------------------
*/


stock RocketAttack(client)
{
	decl Float:clienteyeangle[3], Float:anglevector[3], Float:clienteyeposition[3], Float:resultposition[3], entity;
	GetClientEyeAngles(client, clienteyeangle);
	GetClientEyePosition(client, clienteyeposition);
	GetAngleVectors(clienteyeangle, anglevector, NULL_VECTOR, NULL_VECTOR);
	NormalizeVector(anglevector, anglevector);
	//ScaleVector(anglevector, 10.0);
	AddVectors(clienteyeposition, anglevector, resultposition);
	NormalizeVector(anglevector, anglevector);
	ScaleVector(anglevector, 1500.0);

	if (game == CSS)
	{
		entity = CreateEntityByName("hegrenade_projectile");
		SetEntityMoveType(entity, MOVETYPE_FLY);
	}
	else if (game == TF)
	{
		entity = CreateEntityByName("tf_projectile_rocket");
		SetEntityMoveType(entity, MOVETYPE_FLY);
	}
	else
	{
		entity = CreateEntityByName("npc_grenade_frag");
		SetEntityMoveType(entity, MOVETYPE_VPHYSICS);
	}

	SetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity", client);
	setm_takedamage(entity, DAMAGE_NO);
	DispatchSpawn(entity);
	new Float:vecmax[3] = {4.0, 4.0, 4.0};
	new Float:vecmin[3] = {-4.0, -4.0, -4.0};
	SetEntPropVector(entity, Prop_Send, "m_vecMins", vecmin);
	SetEntPropVector(entity, Prop_Send, "m_vecMaxs", vecmax);
	
	SetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity", client);
	SetEntityModel(entity, "models/weapons/w_missile_launch.mdl");
	TeleportEntity(entity, resultposition, clienteyeangle, anglevector);

	new gascloud = CreateEntityByName("env_rockettrail");
	DispatchKeyValueVector(gascloud,"Origin", resultposition);
	DispatchKeyValueVector(gascloud,"Angles", clienteyeangle);
	new Float:smokecolor[3] = {1.0, 1.0, 1.0};
	SetEntPropVector(gascloud, Prop_Send, "m_StartColor", smokecolor);
	SetEntPropFloat(gascloud, Prop_Send, "m_Opacity", 0.5);
	SetEntPropFloat(gascloud, Prop_Send, "m_SpawnRate", 100.0);
	SetEntPropFloat(gascloud, Prop_Send, "m_ParticleLifetime", 0.5);
	SetEntPropFloat(gascloud, Prop_Send, "m_StartSize", 5.0);
	SetEntPropFloat(gascloud, Prop_Send, "m_EndSize", 30.0);
	SetEntPropFloat(gascloud, Prop_Send, "m_SpawnRadius", 0.0);
	SetEntPropFloat(gascloud, Prop_Send, "m_MinSpeed", 0.0);
	SetEntPropFloat(gascloud, Prop_Send, "m_MaxSpeed", 10.0);
	SetEntPropFloat(gascloud, Prop_Send, "m_flFlareScale", 1.0);
	DispatchSpawn(gascloud);
	decl String:steamid[64];
	GetClientAuthString(client, steamid, 64);
	Format(steamid, 64, "%s%f", steamid, GetGameTime());
	DispatchKeyValue(entity, "targetname", steamid);
	SetVariantString(steamid);
	AcceptEntityInput(gascloud, "SetParent");
	SetEntPropEnt(entity, Prop_Send, "m_hEffectEntity", gascloud);

	EmitSoundToAll("weapons/rpg/rocketfire1.wav", client, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_NORMAL, -1, clienteyeposition);
	SDKHook(entity, SDKHook_StartTouch, RocketTouchHook);
	SDKHook(entity, SDKHook_OnTakeDamage, RocketDamageHook);
	
	new Handle:datapack = CreateDataPack();
	WritePackCell(datapack, EntIndexToEntRef(entity));
	CreateTimer(0.1, RocketSeekThink, datapack, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE | TIMER_DATA_HNDL_CLOSE);
	setm_takedamage(entity, DAMAGE_YES);
 
	new Float:angle[3] = {0.0, 0.0, 0.0};

	angle[0] = -6.0;
	angle[1] = GetRandomFloat(-2.0, 2.0);

	makeviewpunch(client, angle);
}

public Action:RocketTouchHook(entity, other)
{
	if(other != 0)
	{
		if(other == GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity"))
			return (Plugin_Continue);
		else if(!IsEntityCollidable(other, true, true, true))
			return (Plugin_Continue);
	}

	RocketActive(entity);

	return (Plugin_Continue);
}

public Action:RocketDamageHook(entity, &attacker, &inflictor, &Float:damage, &damagetype)
{
	if(GetEntProp(entity, Prop_Data, "m_takedamage") == DAMAGE_YES)
		RocketActive(entity);

	return (Plugin_Continue);
}

public Action:RocketSeekThink(Handle:Timer, Handle:data)
{
	decl entity, client;
	ResetPack(data);
	entity = ReadPackCell(data);
	entity = EntRefToEntIndex(entity);

	if(entity != -1)
	{
		client = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");

		if(IsClientConnectedIngame(client))
		{
			if(IsPlayerAlive(client))
			{
				decl Float:cleyepos[3], Float:cleyeangle[3], Float:resultposition[3], Float:rocketposition[3], Float:vecangle[3], Float:angle[3];

				GetClientEyePosition(client, cleyepos);
				GetClientEyeAngles(client, cleyeangle);

				new Handle:traceresulthandle = INVALID_HANDLE;

				traceresulthandle = TR_TraceRayFilterEx(cleyepos, cleyeangle, MASK_SOLID, RayType_Infinite, tracerayfilterrocket, client);

				if(TR_DidHit(traceresulthandle) == true)
				{
					TR_GetEndPosition(resultposition, traceresulthandle);
					GetEntPropVector(entity, Prop_Send, "m_vecOrigin", rocketposition);

					MakeVectorFromPoints(rocketposition, resultposition, vecangle);
					NormalizeVector(vecangle, vecangle);
					GetVectorAngles(vecangle, angle);
					ScaleVector(vecangle, 1500.0);
					TeleportEntity(entity, NULL_VECTOR, angle, vecangle);
				}

				CloseHandle(traceresulthandle);
			}
		}
		return (Plugin_Continue);
	}
	else
		return (Plugin_Stop);
}

stock RocketActive(entity)
{
	SDKUnhook(entity, SDKHook_StartTouch, RocketTouchHook);
	SDKUnhook(entity, SDKHook_OnTakeDamage, RocketDamageHook);

	if(GetEntProp(entity, Prop_Data, "m_takedamage") == DAMAGE_YES)
	{
		setm_takedamage(entity, DAMAGE_NO);
		decl Float:entityposition[3];
		GetEntPropVector(entity, Prop_Send, "m_vecOrigin", entityposition);
		new client = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");

		new gasentity = GetEntPropEnt(entity, Prop_Send, "m_hEffectEntity");
		AcceptEntityInput(gasentity, "kill");
		AcceptEntityInput(entity, "Kill");
		entityposition[2] = entityposition[2] + 15.0;

		makeexplosion(IsClientConnectedIngame(client) ? client : 0, -1, entityposition, "", 200);

		EmitSoundToAll("weapons/explode3.wav", 0, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_NORMAL, -1, entityposition);
	}
}

/* 
	------------------------------------------------------------------------------------------
	Command_Plasma
	Plasma
	------------------------------------------------------------------------------------------
*/


stock PlasmaAttack(client)
{
	decl Float:clienteyeangle[3], Float:anglevector[3], Float:clienteyeposition[3], Float:resultposition[3], entity;
	GetClientEyeAngles(client, clienteyeangle);
	GetClientEyePosition(client, clienteyeposition);
	GetAngleVectors(clienteyeangle, anglevector, NULL_VECTOR, NULL_VECTOR);
	NormalizeVector(anglevector, anglevector);
	//ScaleVector(anglevector, 10.0);
	AddVectors(clienteyeposition, anglevector, resultposition);
	NormalizeVector(anglevector, anglevector);
	ScaleVector(anglevector, 4500.0);

	if (game == CSS)
		entity = CreateEntityByName("hegrenade_projectile");
	else if (game == TF)
		entity = CreateEntityByName("tf_projectile_rocket");
	
	SetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity", client);
	setm_takedamage(entity, DAMAGE_NO);
	DispatchSpawn(entity);
	new Float:vecmax[3] = {4.0, 4.0, 4.0};
	new Float:vecmin[3] = {-4.0, -4.0, -4.0};
	SetEntPropVector(entity, Prop_Send, "m_vecMins", vecmin);
	SetEntPropVector(entity, Prop_Send, "m_vecMaxs", vecmax);
	SetEntityMoveType(entity, MOVETYPE_FLY);
	SetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity", client);
	SetEntityModel(entity, "models/weapons/w_missile_launch.mdl");
	TeleportEntity(entity, resultposition, clienteyeangle, anglevector);

	new gascloud = CreateEntityByName("env_rockettrail");
	DispatchKeyValueVector(gascloud,"Origin", resultposition);
	DispatchKeyValueVector(gascloud,"Angles", clienteyeangle);
	new Float:smokecolor[3] = {0.4, 1.0, 1.0};
	SetEntPropVector(gascloud, Prop_Send, "m_StartColor", smokecolor);
	SetEntPropFloat(gascloud, Prop_Send, "m_Opacity", 0.2);
	SetEntPropFloat(gascloud, Prop_Send, "m_SpawnRate", 10.0);
	SetEntPropFloat(gascloud, Prop_Send, "m_ParticleLifetime", 0.1);
	SetEntPropFloat(gascloud, Prop_Send, "m_StartSize", 1.0);
	SetEntPropFloat(gascloud, Prop_Send, "m_EndSize", 3.0);
	SetEntPropFloat(gascloud, Prop_Send, "m_SpawnRadius", 0.0);
	SetEntPropFloat(gascloud, Prop_Send, "m_MinSpeed", 0.0);
	SetEntPropFloat(gascloud, Prop_Send, "m_MaxSpeed", 10.0);
	SetEntPropFloat(gascloud, Prop_Send, "m_flFlareScale", 1.0);
	DispatchSpawn(gascloud);
	decl String:steamid[64];
	GetClientAuthString(client, steamid, 64);
	Format(steamid, 64, "%s%f", steamid, GetGameTime());
	DispatchKeyValue(entity, "targetname", steamid);
	SetVariantString(steamid);
	AcceptEntityInput(gascloud, "SetParent");
	SetEntPropEnt(entity, Prop_Send, "m_hEffectEntity", gascloud);

	EmitSoundToAll("weapons/Irifle/irifle_fire2.wav", client, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_NORMAL, -1, clienteyeposition);
	SDKHook(entity, SDKHook_StartTouch, PlasmaTouchHook);
	SDKHook(entity, SDKHook_OnTakeDamage, PlasmaDamageHook);

	new Handle:datapack = CreateDataPack();
	WritePackCell(datapack, EntIndexToEntRef(entity));
	CreateTimer(0.1, PlasmaSeekThink, datapack, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE | TIMER_DATA_HNDL_CLOSE);
	setm_takedamage(entity, DAMAGE_YES);

	new Float:angle[3] = {0.0, 0.0, 0.0};

	angle[0] = -6.0;
	angle[1] = GetRandomFloat(-2.0, 2.0);

	makeviewpunch(client, angle);
}

public Action:PlasmaTouchHook(entity, other)
{
	if(other != 0)
	{
		if(other == GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity"))
			return (Plugin_Continue);
		else if(!IsEntityCollidable(other, true, true, true))
			return (Plugin_Continue);
	}

	PlasmaActive(entity);

	return (Plugin_Continue);
}

public Action:PlasmaDamageHook(entity, &attacker, &inflictor, &Float:damage, &damagetype)
{
	if(GetEntProp(entity, Prop_Data, "m_takedamage") == DAMAGE_YES)
		PlasmaActive(entity);

	return (Plugin_Continue);
}

public Action:PlasmaSeekThink(Handle:Timer, Handle:data)
{
	decl entity, client;
	ResetPack(data);
	entity = ReadPackCell(data);
	entity = EntRefToEntIndex(entity);

	if(entity != -1)
	{
		client = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");

		if(IsClientConnectedIngame(client))
		{
			if(IsPlayerAlive(client))
			{
				decl Float:cleyepos[3], Float:cleyeangle[3], Float:resultposition[3], Float:rocketposition[3], Float:vecangle[3], Float:angle[3];

				GetClientEyePosition(client, cleyepos);
				GetClientEyeAngles(client, cleyeangle);

				new Handle:traceresulthandle = INVALID_HANDLE;

				traceresulthandle = TR_TraceRayFilterEx(cleyepos, cleyeangle, MASK_SOLID, RayType_Infinite, tracerayfilterrocket, client);

				if(TR_DidHit(traceresulthandle) == true)
				{
					TR_GetEndPosition(resultposition, traceresulthandle);
					GetEntPropVector(entity, Prop_Send, "m_vecOrigin", rocketposition);

					MakeVectorFromPoints(rocketposition, resultposition, vecangle);
					NormalizeVector(vecangle, vecangle);
					GetVectorAngles(vecangle, angle);
					ScaleVector(vecangle, 4500.0);
					TeleportEntity(entity, NULL_VECTOR, angle, vecangle);
				}
				CloseHandle(traceresulthandle);
			}
		}
		return (Plugin_Continue);
	}
	else
		return (Plugin_Stop);
}

stock PlasmaActive(entity)
{
	SDKUnhook(entity, SDKHook_StartTouch, PlasmaTouchHook);
	SDKUnhook(entity, SDKHook_OnTakeDamage, PlasmaDamageHook);

	if(GetEntProp(entity, Prop_Data, "m_takedamage") == DAMAGE_YES)
	{
		setm_takedamage(entity, DAMAGE_NO);
		decl Float:entityposition[3];
		GetEntPropVector(entity, Prop_Send, "m_vecOrigin", entityposition);
		new client = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");

		new gasentity = GetEntPropEnt(entity, Prop_Send, "m_hEffectEntity");
		AcceptEntityInput(gasentity, "kill");
		AcceptEntityInput(entity, "Kill");
		entityposition[2] = entityposition[2] + 15.0;

		makeexplosion(IsClientConnectedIngame(client) ? client : 0, -1, entityposition, "", 25);

		EmitSoundToAll("weapons/physcannon/energy_sing_explosion2.wav", 0, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_NORMAL, -1, entityposition);
	}
}

// - Mine


stock MineAttack(client)
{
	decl Float:cleyepos[3], Float:cleyeangle[3];
	
	GetClientEyePosition(client, cleyepos);
	GetClientEyeAngles(client, cleyeangle);

	new entity;
	if (game == CSS)
		entity = CreateEntityByName("hegrenade_projectile");
	else if (game == TF)
		entity = CreateEntityByName("tf_projectile_pipe");
	
	SetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity", client);
	DispatchSpawn(entity);
	
	setm_takedamage(entity, DAMAGE_YES);
	
	SetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity", client);
	SetEntityModel(entity, "models/items/battery.mdl");
	TeleportEntity(entity, cleyepos, cleyeangle, cleyeangle);

	SetEntProp(entity, Prop_Data, "m_iHealth", 1);
	
	CreateTimer(10.0, StartMine, entity, TIMER_FLAG_NO_MAPCHANGE);
	
	SDKHook(entity, SDKHook_StartTouch, MineTouchHook);				
	SDKHook(entity, SDKHook_OnTakeDamage, MineDamageHook);
}

public Action:StartMine(Handle:Timer, any:entity)
{
	MineActive(entity);
}

public Action:MineTouchHook(entity, other)
{
	decl Float:entityposition[3];
	GetEntPropVector(entity, Prop_Send, "m_vecOrigin", entityposition);	
	
	new laserent = CreateEntityByName("point_tesla");
	DispatchKeyValue(laserent, "m_flRadius", "100.0");
	DispatchKeyValue(laserent, "m_SoundName", "DoSpark");
	DispatchKeyValue(laserent, "beamcount_min", "42");
	DispatchKeyValue(laserent, "beamcount_max", "62");
	DispatchKeyValue(laserent, "texture", "sprites/physbeam.vmt");
	DispatchKeyValue(laserent, "m_Color", "255 255 255");
	DispatchKeyValue(laserent, "thick_min", "10.0");
	DispatchKeyValue(laserent, "thick_max", "11.0");
	DispatchKeyValue(laserent, "lifetime_min", "0.3");
	DispatchKeyValue(laserent, "lifetime_max", "0.3");
	DispatchKeyValue(laserent, "interval_min", "0.1");
	DispatchKeyValue(laserent, "interval_max", "0.2");
	DispatchSpawn(laserent);
	
	TeleportEntity(laserent, entityposition, NULL_VECTOR, NULL_VECTOR);
	
	AcceptEntityInput(laserent, "TurnOn");  
	AcceptEntityInput(laserent, "DoSpark");    
		
	if(other != 0)
	{
		if(other == GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity"))
			return (Plugin_Continue);
		else if(!IsEntityCollidable(other, true, true, true))
			return (Plugin_Continue);
			
		MineActive(entity);
	}

	return (Plugin_Continue);
}

public Action:MineDamageHook(entity, &attacker, &inflictor, &Float:damage, &damagetype)
{
	MineActive(entity);
	
	return (Plugin_Handled);
}

stock MineActive(entity)
{
	SDKUnhook(entity, SDKHook_StartTouch, MineTouchHook);
	SDKUnhook(entity, SDKHook_OnTakeDamage, MineDamageHook);

	if(IsValidEntity(entity) && IsValidEdict(entity))
	{ 
		setm_takedamage(entity, DAMAGE_NO);
		decl Float:entityposition[3];
		GetEntPropVector(entity, Prop_Send, "m_vecOrigin", entityposition);
		new client = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");

		AcceptEntityInput(entity, "Kill");
		
		DrawIonBeam(entityposition);
		TE_SetupBeamRingPoint(entityposition, 0.0, 500.0, gGlow1, gHalo1, 0, 0, 0.5, 10.0, 2.0, {255, 255, 255, 255}, 0, 0);
		TE_SendToAll();
		TE_SetupBeamRingPoint(entityposition, 0.0, 500.0, gGlow1, gHalo1, 0, 0, 0.7, 10.0, 2.0, {255, 255, 255, 255}, 0, 0);
		TE_SendToAll();
		TE_SetupBeamRingPoint(entityposition, 0.0, 500.0, gGlow1, gHalo1, 0, 0, 0.9, 10.0, 2.0, {255, 255, 255, 255}, 0, 0);
		TE_SendToAll();
		TE_SetupBeamRingPoint(entityposition, 0.0, 500.0, gGlow1, gHalo1, 0, 0, 1.4, 10.0, 2.0, {255, 255, 255, 255}, 0, 0);
		TE_SendToAll();

		// Light
		new ent = CreateEntityByName("light_dynamic");

		DispatchKeyValue(ent, "_light", "120 120 255 255");
		DispatchKeyValue(ent, "brightness", "5");
		DispatchKeyValueFloat(ent, "spotlight_radius", 500.0);
		DispatchKeyValueFloat(ent, "distance", 500.0);
		DispatchKeyValue(ent, "style", "6");
		
		// SetEntityMoveType(ent, MOVETYPE_NOCLIP); 
		DispatchSpawn(ent);
		AcceptEntityInput(ent, "TurnOn");
		
		TeleportEntity(ent, entityposition, NULL_VECTOR, NULL_VECTOR);
		
		RemoveEntity(ent, 1.0);
		
		entityposition[2] += 15.0;
		makeexplosion(IsClientConnectedIngame(client) ? client : 0, -1, entityposition, "", 300);
		
		env_shake(entityposition, 120.0, 1000.0, 3.0, 250.0);
		
		EmitSoundToAll("weapons/physcannon/energy_disintegrate4.wav", 0, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_NORMAL, -1, entityposition);
		
		// Knockback
		new Float:vReturn[3], Float:vClientPosition[3], Float:dist;
		for (new i = 1; i <= MaxClients; i++)
		{
			if (IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i))
			{	
				GetClientEyePosition(i, vClientPosition);

				dist = GetVectorDistance(vClientPosition, entityposition, false);
				if (dist < 1000.0)
				{
					MakeVectorFromPoints(entityposition, vClientPosition, vReturn);
					NormalizeVector(vReturn, vReturn);
					ScaleVector(vReturn, -5000.0);

					TeleportEntity(i, NULL_VECTOR, NULL_VECTOR, vReturn);
				}
			}
		}
	}
}

/*
	------------------------------------------------------------------------------------------
	Command_IonCannon
	Shoots the ioncannon
	Idea by Peace-Maker
	------------------------------------------------------------------------------------------
*/
stock Command_IonCannon(client)
{
	
	decl Float:vAngles[3];
	decl Float:vOrigin[3];
	decl Float:vStart[3];
	
	GetClientEyePosition(client, vOrigin);
	GetClientEyeAngles(client, vAngles);
	
	new Handle:trace = TR_TraceRayFilterEx(vOrigin, vAngles, MASK_SHOT, RayType_Infinite, TraceEntityFilterPlayer);
    	
	if(TR_DidHit(trace))
	{   	 
   	 	TR_GetEndPosition(vStart, trace);

		CloseHandle(trace);

		new Handle:data = CreateDataPack();
		WritePackFloat(data, vStart[0]);
		WritePackFloat(data, vStart[1]);
		WritePackFloat(data, vStart[2]);
		WritePackCell(data, 320); // Distance
		WritePackFloat(data, 0.0); // nphi
		ResetPack(data);

		IonAttack(data);
	}
	else
	{
		PrintHintText(client, "%t", "Wrong entity"); 
		CloseHandle(trace);
	}

	return (Plugin_Handled);
}

public DrawIonBeam(Float:startPosition[3])
{
	decl Float:position[3];
	position[0] = startPosition[0];
	position[1] = startPosition[1];
	position[2] = startPosition[2] + 1500.0;	

	TE_SetupBeamPoints(startPosition, position, gLaser1, 0, 0, 0, 0.15, 25.0, 25.0, 0, 1.0, {0, 150, 255, 255}, 3 );
	TE_SendToAll();
	position[2] -= 1490.0;
	TE_SetupSmoke(startPosition, gSmoke1, 10.0, 2);
	TE_SendToAll();
	TE_SetupGlowSprite(startPosition, gGlow1, 1.0, 1.0, 255);
	TE_SendToAll();
}

public IonAttack(Handle:data)
{	
	new Float:startPosition[3];
	new Float:position[3];
	startPosition[0] = ReadPackFloat(data);
	startPosition[1] = ReadPackFloat(data);
	startPosition[2] = ReadPackFloat(data);
	new distance = ReadPackCell(data);
	new Float:nphi = ReadPackFloat(data);
	
	if (distance > 0)
	{
		EmitSoundToAll("ambient/energy/weld1.wav", 0, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_NORMAL, -1, startPosition);
		
		// Stage 1
		new Float:s=Sine(nphi/360*6.28)*distance;
		new Float:c=Cosine(nphi/360*6.28)*distance;
		
		position[0] = startPosition[0];
		position[1] = startPosition[1];
		position[2] = startPosition[2];
		
		position[0] += s;
		position[1] += c;
		DrawIonBeam(position);

		position[0] = startPosition[0];
		position[1] = startPosition[1];
		position[0] -= s;
		position[1] -= c;
		DrawIonBeam(position);
		
		// Stage 2
		s=Sine((nphi+45.0)/360*6.28)*distance;
		c=Cosine((nphi+45.0)/360*6.28)*distance;
		
		position[0] = startPosition[0];
		position[1] = startPosition[1];
		position[0] += s;
		position[1] += c;
		DrawIonBeam(position);
		
		position[0] = startPosition[0];
		position[1] = startPosition[1];
		position[0] -= s;
		position[1] -= c;
		DrawIonBeam(position);
		
		// Stage 3
		s=Sine((nphi+90.0)/360*6.28)*distance;
		c=Cosine((nphi+90.0)/360*6.28)*distance;
		
		position[0] = startPosition[0];
		position[1] = startPosition[1];
		position[0] += s;
		position[1] += c;
		DrawIonBeam(position);
		
		position[0] = startPosition[0];
		position[1] = startPosition[1];
		position[0] -= s;
		position[1] -= c;
		DrawIonBeam(position);
		
		// Stage 3
		s=Sine((nphi+135.0)/360*6.28)*distance;
		c=Cosine((nphi+135.0)/360*6.28)*distance;
		
		position[0] = startPosition[0];
		position[1] = startPosition[1];
		position[0] += s;
		position[1] += c;
		DrawIonBeam(position);
		
		position[0] = startPosition[0];
		position[1] = startPosition[1];
		position[0] -= s;
		position[1] -= c;
		DrawIonBeam(position);

		if (nphi >= 360)
			nphi = 0.0;
		else
			nphi += 5.0;
	}
	distance -= 5;
	
	new Handle:nData = CreateDataPack();
	WritePackFloat(nData, startPosition[0]);
	WritePackFloat(nData, startPosition[1]);
	WritePackFloat(nData, startPosition[2]);
	WritePackCell(nData, distance);
	WritePackFloat(nData, nphi);
	ResetPack(nData);

	if (distance > -50)
		CreateTimer(0.1, DrawIon, nData, TIMER_FLAG_NO_MAPCHANGE|TIMER_DATA_HNDL_CLOSE);
	else
	{
		position[0] = startPosition[0];
		position[1] = startPosition[1];
		position[2] += 1500.0;
		TE_SetupBeamPoints(startPosition, position, gLaser1, 0, 0, 0, 5.0, 30.0, 30.0, 0, 1.0, {255, 255, 255, 255}, 3);
		TE_SendToAll();
		TE_SetupBeamPoints(startPosition, position, gLaser1, 0, 0, 0, 4.0, 50.0, 50.0, 0, 1.0, {200, 255, 255, 255}, 3);
		TE_SendToAll();
		TE_SetupBeamPoints(startPosition, position, gLaser1, 0, 0, 0, 3.0, 80.0, 80.0, 0, 1.0, {100, 255, 255, 255}, 3);
		TE_SendToAll();
		TE_SetupBeamPoints(startPosition, position, gLaser1, 0, 0, 0, 2.0, 100.0, 100.0, 0, 1.0, {0, 255, 255, 255}, 3);
		TE_SendToAll();
		
		TE_SetupSmoke(startPosition, gSmoke1, 350.0, 15);
		TE_SendToAll();
		TE_SetupGlowSprite(startPosition, gGlow1, 3.0, 15.0, 255);
		TE_SendToAll();

		makeexplosion(0, -1, startPosition, "", 500);

		position[2] = startPosition[2] + 50.0;
		new Float:fDirection[3] = {-90.0,0.0,0.0};
		env_shooter(fDirection, 25.0, 0.1, fDirection, 800.0, 120.0, 120.0, position, "models/props_wasteland/rockgranite03b.mdl");

		env_shake(startPosition, 120.0, 10000.0, 15.0, 250.0);

		TE_SetupExplosion(startPosition, gExplosive1, 10.0, 1, 0, 0, 5000);
		TE_SendToAll();
		
		TE_SetupBeamRingPoint(position, 0.0, 1500.0, gGlow1, gHalo1, 0, 0, 0.5, 100.0, 5.0, {150, 255, 255, 255}, 0, 0);
		TE_SendToAll();
		TE_SetupBeamRingPoint(position, 0.0, 1500.0, gGlow1, gHalo1, 0, 0, 5.0, 100.0, 5.0, {255, 255, 255, 255}, 0, 0);
		TE_SendToAll();
		TE_SetupBeamRingPoint(position, 0.0, 1500.0, gGlow1, gHalo1, 0, 0, 2.5, 100.0, 5.0, {255, 255, 255, 255}, 0, 0);
		TE_SendToAll();
		TE_SetupBeamRingPoint(position, 0.0, 1500.0, gGlow1, gHalo1, 0, 0, 6.0, 100.0, 5.0, {255, 255, 255, 255}, 0, 0);
		TE_SendToAll();

		// Light
		new ent = CreateEntityByName("light_dynamic");

		DispatchKeyValue(ent, "_light", "255 255 255 255");
		DispatchKeyValue(ent, "brightness", "5");
		DispatchKeyValueFloat(ent, "spotlight_radius", 500.0);
		DispatchKeyValueFloat(ent, "distance", 500.0);
		DispatchKeyValue(ent, "style", "6");

		// SetEntityMoveType(ent, MOVETYPE_NOCLIP); 
		DispatchSpawn(ent);
		AcceptEntityInput(ent, "TurnOn");
	
		TeleportEntity(ent, position, NULL_VECTOR, NULL_VECTOR);
		
		RemoveEntity(ent, 3.0);
		
		// Sound
		EmitSoundToAll("ambient/explosions/citadel_end_explosion1.wav", 0, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_NORMAL, -1, startPosition);
		EmitSoundToAll("ambient/explosions/citadel_end_explosion2.wav", 0, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_NORMAL, -1, startPosition);	

		// Blend
		sendfademsg(0, 10, 200, FFADE_OUT, 255, 255, 255, 150);	
		
		// Knockback
		new Float:vReturn[3], Float:vClientPosition[3], Float:dist;
		for (new i = 1; i <= MaxClients; i++)
		{
			if (IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i))
			{	
				GetClientEyePosition(i, vClientPosition);

				dist = GetVectorDistance(vClientPosition, position, false);
				if (dist < 1000.0)
				{
					MakeVectorFromPoints(position, vClientPosition, vReturn);
					NormalizeVector(vReturn, vReturn);
					ScaleVector(vReturn, 10000.0 - dist*10);

					TeleportEntity(i, NULL_VECTOR, NULL_VECTOR, vReturn);
				}
			}
		}
	}
}

public Action:DrawIon(Handle:Timer, any:data)
{
	IonAttack(data);
	
	return (Plugin_Stop);
}

/* 
	------------------------------------------------------------------------------------------
	Command_Bullet
	Shoots the sentrygun projectile
	------------------------------------------------------------------------------------------
*/
stock Command_Bullet(client)
{

	decl Float:clienteyeangle[3], Float:clienteyeposition[3];
	GetClientEyePosition(client, clienteyeposition);
	GetClientEyeAngles(client, clienteyeangle);
	SentryShootProjectile(clienteyeposition, clienteyeangle);
	
	return (Plugin_Handled);
}

stock SentryShootProjectile(Float:pos[3], Float:angle[3])
{
	decl Float:anglevector[3], Float:resultposition[3], entity;
		
	GetAngleVectors(angle, anglevector, NULL_VECTOR, NULL_VECTOR);
	NormalizeVector(anglevector, anglevector);
	ScaleVector(anglevector, 100.0);
	AddVectors(pos, anglevector, resultposition);
	NormalizeVector(anglevector, anglevector);
	ScaleVector(anglevector, 2500.0);

	if (game == CSS)
		entity = CreateEntityByName("hegrenade_projectile");
	else if (game == TF)
		entity = CreateEntityByName("tf_projectile_pipe");
		
	//setm_takedamage(entity, DAMAGE_NO);
	setm_takedamage(entity, DAMAGE_YES);
	DispatchSpawn(entity);
	/*
	new Float:vecmax[3] = {4.0, 4.0, 4.0};
	new Float:vecmin[3] = {-4.0, -4.0, -4.0};
	SetEntPropVector(entity, Prop_Send, "m_vecMins", vecmin);
	SetEntPropVector(entity, Prop_Send, "m_vecMaxs", vecmax);
	*/
	SetEntityMoveType(entity, MOVETYPE_FLY);
	SetEntityModel(entity, "models/weapons/w_missile_launch.mdl");
	
	TeleportEntity(entity, resultposition, angle, anglevector);

	EmitSoundToAll("weapons/ar2/fire1.wav", 0, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_NORMAL, -1, pos);
	SDKHook(entity, SDKHook_StartTouch, SentryProjectileTouchHook);
	SDKHook(entity, SDKHook_OnTakeDamage, SentryProjectileDamageHook);

	setm_takedamage(entity, DAMAGE_YES);
}

public Action:SentryProjectileTouchHook(entity, other)
{
	SentryProjectileActive(entity, other);

	return (Plugin_Continue);
}

public Action:SentryProjectileDamageHook(entity, &attacker, &inflictor, &Float:damage, &damagetype)
{
	SentryProjectileActive(entity, 0);

	return (Plugin_Continue);
}

stock SentryProjectileActive(entity, other)
{
	SDKUnhook(entity, SDKHook_StartTouch, SentryProjectileTouchHook);
	SDKUnhook(entity, SDKHook_OnTakeDamage, SentryProjectileDamageHook);

	decl Float:entityposition[3];
	GetEntPropVector(entity, Prop_Send, "m_vecOrigin", entityposition);

	AcceptEntityInput(entity, "Kill");
	//entityposition[2] = entityposition[2] + 15.0;

	MakeDamage(0, other, 5, DMG_BULLET, 500.0, entityposition);
	// makeexplosion(0, -1, entityposition, "", 25);
}


/* 
	------------------------------------------------------------------------------------------
	ShootSimplePlasmaProjectile
	Shoots the soldier plasma projectile
	------------------------------------------------------------------------------------------
*/
stock ShootSimplePlasmaProjectile(Float:pos[3], Float:angle[3])
{
	decl Float:anglevector[3], Float:resultposition[3], entity;
		
	GetAngleVectors(angle, anglevector, NULL_VECTOR, NULL_VECTOR);
	NormalizeVector(anglevector, anglevector);
	ScaleVector(anglevector, 100.0);
	AddVectors(pos, anglevector, resultposition);
	NormalizeVector(anglevector, anglevector);
	ScaleVector(anglevector, 1000.0);

	if (game == CSS)
		entity = CreateEntityByName("hegrenade_projectile");
	else if (game == TF)
		entity = CreateEntityByName("tf_projectile_pipe");
		
	//setm_takedamage(entity, DAMAGE_NO);
	setm_takedamage(entity, DAMAGE_YES);
	DispatchSpawn(entity);

	SetEntityMoveType(entity, MOVETYPE_FLY);
	SetEntityModel(entity, "models/weapons/w_missile_launch.mdl");
	
	TeleportEntity(entity, resultposition, angle, anglevector);

	new gascloud = CreateEntityByName("env_rockettrail");
	DispatchKeyValueVector(gascloud,"Origin", resultposition);
	DispatchKeyValueVector(gascloud,"Angles", angle);
	new Float:smokecolor[3] = {0.4, 1.0, 1.0};
	SetEntPropVector(gascloud, Prop_Send, "m_StartColor", smokecolor);
	SetEntPropFloat(gascloud, Prop_Send, "m_Opacity", 0.2);
	SetEntPropFloat(gascloud, Prop_Send, "m_SpawnRate", 10.0);
	SetEntPropFloat(gascloud, Prop_Send, "m_ParticleLifetime", 0.1);
	SetEntPropFloat(gascloud, Prop_Send, "m_StartSize", 1.0);
	SetEntPropFloat(gascloud, Prop_Send, "m_EndSize", 3.0);
	SetEntPropFloat(gascloud, Prop_Send, "m_SpawnRadius", 0.0);
	SetEntPropFloat(gascloud, Prop_Send, "m_MinSpeed", 0.0);
	SetEntPropFloat(gascloud, Prop_Send, "m_MaxSpeed", 10.0);
	SetEntPropFloat(gascloud, Prop_Send, "m_flFlareScale", 1.0);
	DispatchSpawn(gascloud);
	
	decl String:entIndex[64];
	IntToString(entity, entIndex, sizeof(entIndex));
	DispatchKeyValue(entity, "targetname", entIndex);
	SetVariantString(entIndex);
	AcceptEntityInput(gascloud, "SetParent");
	
	SetEntPropEnt(entity, Prop_Send, "m_hEffectEntity", gascloud);
	
	EmitSoundToAll("weapons/flaregun/fire.wav", 0, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_NORMAL, -1, pos);
	SDKHook(entity, SDKHook_StartTouch, SPProjectileTouchHook);
	SDKHook(entity, SDKHook_OnTakeDamage, SPProjectileDamageHook);

	setm_takedamage(entity, DAMAGE_YES);
}

public Action:SPProjectileTouchHook(entity, other)
{
	SPProjectileActive(entity, other);

	return (Plugin_Continue);
}

public Action:SPProjectileDamageHook(entity, &attacker, &inflictor, &Float:damage, &damagetype)
{
	SPProjectileActive(entity, 0);

	return (Plugin_Continue);
}

stock SPProjectileActive(entity, other)
{
	SDKUnhook(entity, SDKHook_StartTouch, SPProjectileTouchHook);
	SDKUnhook(entity, SDKHook_OnTakeDamage, SPProjectileDamageHook);

	decl Float:entityposition[3];
	GetEntPropVector(entity, Prop_Send, "m_vecOrigin", entityposition);
	
	new gasentity = GetEntPropEnt(entity, Prop_Send, "m_hEffectEntity");
	AcceptEntityInput(gasentity, "kill");
	AcceptEntityInput(entity, "Kill");

	MakeDamage(0, other, 30, DMG_BULLET, 500.0, entityposition);
	EmitSoundToAll("weapons/physcannon/energy_sing_explosion2.wav", 0, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_NORMAL, -1, entityposition);
}






public OnAllPluginsLoaded()
{
	if (LibraryExists("pluginautoupdate"))
		AutoUpdate_AddPlugin("www.exp-clan.com", "/entcontrol.xml", PLUGIN_VERSION);
}

public OnPluginEnd() 
{
	if (LibraryExists("pluginautoupdate"))
		AutoUpdate_RemovePlugin();
}

public OnEventShutdown()
{
	UnhookEvent("player_death", OnPlayerDeath);
	UnhookEvent("player_spawn", OnPlayerSpawn);
	
	// Cstrike only
	if (game == CSS)
	{
		UnhookEvent("round_start", OnRoundStart);
		UnhookEvent("round_end", OnRoundEnd);
	}
	else if (game == TF)
		UnhookEvent("teamplay_round_win", OnRoundEnd);
	else if (game == DOD)
		UnhookEvent("dod_round_win", OnRoundEnd);
}

public OnMapStart()
{
	// Check for SDKHOOKS
	if (GetExtensionFileStatus("sdkhooks.ext") != 1)
		LogError("SDKHooks NOT LOADED! Entcontrol is not fully working! Status: %i", GetExtensionFileStatus("sdkhooks.ext"));
	else
		SDKHooksLoaded = true;

	// Check for the EntControl-Ext
	if (GetExtensionFileStatus("entcontrol.ext") != 1)
		LogError("The EntControl Extension IS NOT LOADED! Entcontrol is not fully working! Status: %i", GetExtensionFileStatus("entcontrol.ext"));
	else
		EntControlExtLoaded = true;
	
	SetConVarString(FindConVar("sm_entcontrol_version"), PLUGIN_VERSION);
	
	// LaserBeam
	gLaser1 = PrecacheModel("materials/sprites/laser.vmt");
	PrecacheModel("models/items/battery.mdl", false);
	PrecacheModel("models/weapons/w_missile_launch.mdl", false);
	PrecacheSound("weapons/Irifle/irifle_fire2.wav", false);

	// Grabbing Sound
	// weapons/physcannon/physcannon_charge.wav
	PrecacheSound("buttons/combine_button5.wav");
	
	//gSelectedEntitySprite = PrecacheModel("models/extras/info_speech.mdl");
	
	// start timer
	gTimer = CreateTimer(0.1, UpdateObjects, INVALID_HANDLE, TIMER_REPEAT);
	
	if (game == CSS || game == TF)
		gTimerHudInfo = CreateTimer(1.0, UpdateHudInfoExtended, INVALID_HANDLE, TIMER_REPEAT);
	//else
		//gTimerHudInfo = CreateTimer(1.0, UpdateHudInfoSimple, INVALID_HANDLE, TIMER_REPEAT);
	
	InitWeapons();
	
	InitNPCs();
	
	// Hostage
	PrecacheSound("physics/glass/glass_sheet_break3.wav");
	
	kv = CreateKeyValues("EntControl");
	decl String:file[256];
	BuildPath(Path_SM, file, sizeof(file), "configs/entcontrol.cfg");
	if (!FileToKeyValues(kv, file))
	{
		CloseHandle(kv);
		
		LogError("%s NOT loaded! You NEED that file!", file);
	}
	
	kvEnts = CreateKeyValues("EntControl_Entities");
	BuildPath(Path_SM, file, sizeof(file), "configs/entcontrol_entities.cfg");
	if (!FileToKeyValues(kvEnts, file))
	{
		CloseHandle(kvEnts);
		
		LogError("%s NOT loaded! You NEED that file!", file);
	}
	
	BuildMenu();
}

public Action:OnRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
	CreateTimer(1.0, SpawnNPCs, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
	CreateTimer(1.0, SpawnEntities, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
}

public Action:OnRoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
	if (fakeClient)
		KickClient(fakeClient);

	// This HACK will fix a few bugs ... -.-
	ServerCommand("sm plugins reload entcontrol");
}

public OnMapEnd()
{
	CloseHandle(gTimer);
	CloseHandle(gTimerHudInfo);

	FreeMenu();
}

public OnClientPutInServer(client)
{
	if(client)
	{ 
		gObj[client] = -1;
		gSelectedEntity[client] = -1;
		gDistance[client] = 0.0;
		gSavedPos[client][0] = 0.0;
		gSavedPos[client][1] = 0.0;
		gSavedPos[client][2] = 0.0;
		gNextPickup[client] = 0.0;

		SprayPos[client][0] = 0.0;
		SprayPos[client][1] = 0.0;
		SprayPos[client][2] = 0.0;
		strcopy(SprayName[client], sizeof(SprayName[]), "");
	}
}

public OnClientDisconnect(client) 
{
	SprayPos[client][0] = 0.0;
	SprayPos[client][1] = 0.0;
	SprayPos[client][2] = 0.0;
	strcopy(SprayName[client], sizeof(SprayName[]), "");
}

// Hostage improvements
public OnEntityCreated(entity, const String:classname[])
{
	if (StrEqual(classname, "hostage_entity"))
		SDKHook(entity, SDKHook_Touch, OnHostageTouch);
}

// Improve the hostage AI !!! xD
public Action:OnHostageTouch(hostage, other)
{
	if (other)
	{
		new String:edictname[32];
		GetEdictClassname(other, edictname, 32);

		if (StrEqual("func_breakable", edictname) || StrEqual("func_breakable_surf", edictname))
		{
			decl Float:vEntPosition[3];
			GetEntPropVector(hostage, Prop_Send, "m_vecOrigin", vEntPosition);
			BaseNPC_PlaySound("physics/glass/glass_sheet_break3.wav", vEntPosition);
			
			AcceptEntityInput(other, "Break");
		}
		else if ((StrEqual(edictname, "prop_physics")
				|| StrEqual(edictname, "prop_physics_multiplayer")
				|| StrEqual(edictname, "func_physbox"))
				&& Entity_GetHealth(other))
		{
			AcceptEntityInput(other, "Break");
		}
	}

	return (Plugin_Continue);
}

public Action:OnPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client;
	client = GetClientOfUserId(GetEventInt(event, "userid"));

	// reset object held
	gObj[client] = -1;

	return (Plugin_Continue);
}

public Action:OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client;
	client = GetClientOfUserId(GetEventInt(event, "userid"));

	// reset object held
	gObj[client] = -1;

	return (Plugin_Continue);
}

/*
*	Spray Trace
*
*	Originally by Nican
*	Re-released and updated with permission by Lebson506th
*/
public Action:OnPlayerSpray(const String:te_name[],const clients[],client_count,Float:delay) 
{
	new client = TE_ReadNum("m_nPlayer");

	if(client && IsClientInGame(client))
	{
		TE_ReadVector("m_vecOrigin", SprayPos[client]);

		GetClientName(client, SprayName[client], 64);
	}
}
// Spray-Trace end

/*
	------------------------------------------------------------------------------------------
	COMMANDS
	------------------------------------------------------------------------------------------
*/
public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
{
	if (GetConVarBool(gNoneAdminsUseGrab))
	{
		if ((buttons & IN_ATTACK || buttons & IN_ATTACK2) && gObj[client] >= 1)
		{
			gObj[client] = -1;
		}
		else if (buttons & IN_USE && (gNextPickup[client] < GetGameTime()) && IsPlayerAlive(client))
		{
			gNextPickup[client] = GetGameTime() + 1.0;
			
			if (gObj[client] >= 1)
			{
				new Float:vecDir[3], Float:vecPos[3], Float:vecVel[3];
				new Float:viewang[3];

				// get client info
				GetClientEyeAngles(client, viewang);
				GetAngleVectors(viewang, vecDir, NULL_VECTOR, NULL_VECTOR);
				GetClientEyePosition(client, vecPos);
				
				// update object 
				vecPos[0]+=vecDir[0]*100.0;
				vecPos[1]+=vecDir[1]*100.0;
				vecPos[2]+=vecDir[2]*100.0;

				GetEntPropVector(gObj[client], Prop_Send, "m_vecOrigin", vecDir);

				SubtractVectors(vecPos, vecDir, vecVel);
				ScaleVector(vecVel, 10.0);
				TeleportEntity(gObj[client], NULL_VECTOR, NULL_VECTOR, vecVel);

				gObj[client] = -1;
			}
			else
			{
				new ent;
				new Float:VecPos_Ent[3], Float:VecPos_Client[3];
				
				ent = TraceToEntity(client); // GetClientAimTarget(client);

				if (IsValidEntity(ent) && IsValidEdict(ent))
				{
					new String:edictname[64];
					GetEdictClassname(ent, edictname, 64);
					if (StrEqual(edictname, "prop_physics") || StrEqual(edictname, "prop_physics_multiplayer") || StrEqual(edictname, "func_physbox"))
					{
						GetClientEyePosition(client, VecPos_Client);
						GetEntPropVector(ent, Prop_Send, "m_vecOrigin", VecPos_Ent);
						if(GetVectorDistance(VecPos_Client, VecPos_Ent) <= 128.0)
						{
							gObj[client] = ent;
							gDistance[client] = 40.0;
						}
					}
				}
			}
		}
	}
}

stock GrabSomething(client)
{
	if (CanUseCMD(client, gAdminFlagGrab))
	{
		new ent;
		new Float:VecPos_Ent[3], Float:VecPos_Client[3];
		
		if (GetConVarBool(gAdminCanGrabSelf)) // I know this might be slow ... but we need the ability to change the cvar every time
			ent = GetObject(client);
		else
			ent = GetObject(client, false);
		
		if (ent == -1)
			return;

		// only grab physics entities
		new String:edictname[128];
		GetEdictClassname(ent, edictname, 128);

		if (StrEqual(edictname, "player"))
		{
			if (!CanUseCMD(client, gAdminFlagGrabPlayer))
				return;
			
			PrintHintText(ent, "Admin %N is grabbing you", client);

			LogAction(client, ent, "%L grabbed %L", client, ent);
		}
		else
		{
			LogAction(client, 0, "%L grabbed %s", client, edictname);

			if (StrEqual(edictname, "prop_physics") || StrEqual(edictname, "prop_physics_multiplayer"))
			{
				// Convert to prop_physics_override
				if (IsValidEdict(ent) && IsValidEntity(ent)) 
				{
					ent = ReplacePhysicsEntity(ent);
				}
			}
		}

		if (GetEntityMoveType(ent) == MOVETYPE_NONE)
		{
			if (strncmp("player", edictname, 5, false)!=0)
			{
				SetEntityMoveType(ent, MOVETYPE_VPHYSICS);

				PrintHintText(client, "Object ist now Unfreezed");
			}
			else
			{
				SetEntityMoveType(ent, MOVETYPE_WALK);
				return;
			}
		}

		gObj[client] = ent;

		GetEntPropVector(ent, Prop_Send, "m_vecOrigin", VecPos_Ent);
		GetClientEyePosition(client, VecPos_Client);
		gDistance[client] = GetVectorDistance(VecPos_Ent, VecPos_Client, false);

		new Float:position[3];
		TeleportEntity(ent, NULL_VECTOR, NULL_VECTOR, position);
		
		EmitSoundToClient(client, "buttons/combine_button5.wav");
	}
}

public Action:Command_Grab(client, args)
{
	GrabSomething(client);

	return (Plugin_Handled);
}

public Action:Command_UnGrab(client, args)
{
	gObj[client] = -1;
	return (Plugin_Handled);
}

public Action:Command_GrabToggle(client, args)
{
	if (gObj[client] != -1)
		gObj[client] = -1;
	else
		GrabSomething(client);
	
	return (Plugin_Handled);
}

public Action:Command_Show_Info(client, args)
{
	if (client)
		ShowMOTDPanel(client, "EntControl-Information", "http://www.exp-clan.com/entcontrol.html", 2);

	return (Plugin_Handled);
}

public Action:Command_Report_Bugs(client, args)
{
 	decl String:steamID[32];
 	decl String:url[120];
 
 	steamID[0] = '\0'; // Ripped from somewhere ... SourceIRC ? Oo

 	GetClientAuthString(client, steamID, sizeof(steamID));

	Format(url, sizeof(url), "http://www.exp-clan.com/mantisbt/bug_report_page.php?Server=19&SteamID=%s", steamID);

	ShowMOTDPanel(client, "Bug-Report", url, 2);
	ShowMOTDPanel(client, "Bug-Report", url, 2);

	return (Plugin_Handled);
}


/* 
	------------------------------------------------------------------------------------------
	MAIN TIMER/LOOP CODE
	------------------------------------------------------------------------------------------
*/
public Action:UpdateObjects(Handle:timer)
{
	new Float:vecDir[3], Float:vecPos[3], Float:vecVel[3];
	new Float:viewang[3];

	for (new i=1; i < MaxClients; i++)
	{
		if (ValidGrab(i))
		{
			// get client info
			GetClientEyeAngles(i, viewang);
			GetAngleVectors(viewang, vecDir, NULL_VECTOR, NULL_VECTOR);
			GetClientEyePosition(i, vecPos);

			// update object
			vecPos[0]+=vecDir[0]*gDistance[i];
			vecPos[1]+=vecDir[1]*gDistance[i];
			vecPos[2]+=vecDir[2]*gDistance[i];
			
			GetEntPropVector(gObj[i], Prop_Send, "m_vecOrigin", vecDir);
			
			SubtractVectors(vecPos, vecDir, vecVel);
			ScaleVector(vecVel, 10.0);
			
			TeleportEntity(gObj[i], NULL_VECTOR, NULL_VECTOR, vecVel);
		}
	}
	
	return (Plugin_Continue);
}

public Action:UpdateHudInfoExtended(Handle:timer)
{
	new Float:vecPos[3];
	
	for (new i=1; i < MaxClients; i++)
	{
		if (IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i))
		{
			if (CanUseCMD(i, gAdminFlagHUD, false)) // This might be a little slow
			{
				GetPlayerEye(i, vecPos);

				for (new i2 = 1; i2 < MaxClients; i2++) 
				{
					if (GetVectorDistance(vecPos, SprayPos[i2]) <= 40.0)
					{
						decl String:szText[250];
						Format(szText, sizeof(szText), "Sprayer: %s", SprayName[i2]);
    
						new Handle:hBuffer = StartMessageOne("KeyHintText", i);
						BfWriteByte(hBuffer, 1);
						BfWriteString(hBuffer, szText);
						EndMessage();

						break;
					}
				}

				// find entity
				new ent = GetObject(i, false);
				if (ent != -1)
				{
					new String:edictname[128];
					GetEdictClassname(ent, edictname, 128);

					if (StrEqual(edictname, "player"))
						GetClientName(ent, edictname, sizeof(edictname));

					decl String:szText[64];
					Format(szText, sizeof(szText), "%s(%i)\nHP: %i", edictname, ent, GetEntProp(ent, Prop_Data, "m_iHealth"));
    
					new Handle:hBuffer = StartMessageOne("KeyHintText", i);
					BfWriteByte(hBuffer, 1);
					BfWriteString(hBuffer, szText);
					EndMessage();
					
					/*
					if (gSelectedEntity[i] != -1)
					{
						new Float:vEntPosition[3];
						GetEntPropVector(gSelectedEntity[i], Prop_Send, "m_vecOrigin", vEntPosition);
						vEntPosition[2] += 20.0;
						TE_SetupGlowSprite(vEntPosition, gSelectedEntitySprite, 1.0, 1.0, 255);
						TE_SendToClient(i);
					}
					*/
				}
			}
		}
	}
	
	return (Plugin_Continue);
}

public Action:UpdateHudInfoSimple(Handle:timer)
{
	new Float:vecPos[3];
	
	for (new i=1; i < MaxClients; i++)
	{
		if (IsClientConnected(i) && IsClientInGame(i) && !IsFakeClient(i))
		{
			if (CanUseCMD(i, gAdminFlagHUD, false)) // This might be a little slow
			{
				GetPlayerEye(i, vecPos);

				for (new i2 = 1; i2 < MaxClients; i2++) 
				{
					if (GetVectorDistance(vecPos, SprayPos[i2]) <= 40.0)
					{
						decl String:szText[250];
						Format(szText, sizeof(szText), "Sprayer: %s", SprayName[i2]);
    
						PrintCenterText(i, szText);

						break;
					}
				}

				// find entity
				new ent = GetObject(i, false);
				if (ent != -1)
				{
					new String:edictname[128];
					GetEdictClassname(ent, edictname, 128);

					if (StrEqual(edictname, "player"))
						GetClientName(ent, edictname, sizeof(edictname));
    
					PrintCenterText(i, edictname);
				}
			}
		}
	}
	
	return (Plugin_Continue);
}


 

 

 

  • Author

Je veux pas voir vos trolls de merde sur cette parties du forum. Prochaine fois, c'est une modération assuré, staff/admin ou pas.

J espère que j'ai été assez clair.

Cordialement.

  • 3 weeks later...

j'ai Look le principe je trouve sa super sympas dommage que sa ne soit pas d'actualité de le faire en ce moment 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.