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

[help]help, rebuild this decompiled add-on and add support for l42 please


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
luis enrique
Member
Join Date: Oct 2017
Location: peru
Old 05-26-2018 , 15:15   [help]help, rebuild this decompiled add-on and add support for l42 please
Reply With Quote #1

Code:
public PlVers:__version =
{
	version = 5,
	filevers = "1.4.0",
	date = "12/04/2013",
	time = "20:40:24"
};
new Float:NULL_VECTOR[3];
new String:NULL_STRING[4];
public Extension:__ext_core =
{
	name = "Core",
	file = "core",
	autoload = 0,
	required = 0,
};
new MaxClients;
public Extension:__ext_sdktools =
{
	name = "SDKTools",
	file = "sdktools.ext",
	autoload = 1,
	required = 1,
};
new Handle:g_hCvarAllow;
new Handle:g_hCvarBreak;
new Handle:g_hCvarBright;
new Handle:g_hCvarColor;
new Handle:g_hCvarModes;
new Handle:g_hCvarModesOff;
new Handle:g_hCvarModesTog;
new Handle:g_hCvarRandom;
new bool:g_bCvarAllow;
new g_iCvarBreak;
new Float:g_fCvarBright;
new g_iCvarColor;
new String:g_sCvarColor[12];
new g_iCvarRandom;
new bool:g_bLoaded;
new g_iPlayerSpawn;
new g_iRoundStart;
new g_iEntities[32][9];
new Handle:g_hMPGameMode;
new Handle:g_hMenuMain;
new Handle:g_hMenuTemp;
new Handle:g_hMenuSave;
new Handle:g_hMenuColor;
new Handle:g_hMenuBrightness;
new Handle:g_hMenuAng;
new Handle:g_hMenuPos;
new String:g_sSoundsZap[5][32] =
{
	"ambient/energy/spark5.wav",
	"ambient/energy/spark6.wav",
	"ambient/energy/zap1.wav",
	"ambient/energy/zap2.wav",
	"ambient/energy/zap3.wav"
};
new String:g_sModels[39][64] =
{
	"models/props_exteriors/wood_stairs_120.mdl",
	"models/props_buildings/barn_steps.mdl",
	"models/props/cs_militia/housefence_door.mdl",
	"models/props_interiors/refrigerator03.mdl",
	"models/props_interiors/bbq_grill.mdl",
	"models/props_interiors/table_picnic.mdl",
	"models/props_interiors/bed.mdl",
	"models/props_interiors/tv.mdl",
	"models/props_interiors/couch.mdl",
	"models/props/de_train/chainlinkgate.mdl",
	"models/props_wasteland/exterior_fence002c.mdl",
	"models/props_street/police_barricade3.mdl",
	"models/props_urban/fire_escape_upper.mdl",
	"models/props_vehicles/cara_82hatchback.mdl",
	"models/props_vehicles/army_truck.mdl",
	"models/props_vehicles/airport_fuel_truck.mdl",
	"models/props_vehicles/ambulance.mdl",
	"models/props_exteriors/park_sign.mdl",
	"models/props_exteriors/wood_stairs_wide_48.mdl",
	"models/props_equipment/sleeping_bag2.mdl",
	"models/props_equipment/sleeping_bag3.mdl",
	"models/props_equipment/ticketmachine.mdl",
	"models/props_furniture/piano.mdl",
	"models/props_interiors/sofa.mdl",
	"models/props_interiors/sofa01.mdl",
	"models/props_interiors/sofa_chair.mdl",
	"models/props_interiors/sofa_chair01.mdl",
	"models/props_street/bus_stop.mdl",
	"models/props_interiors/patio_chair2_white.mdl",
	"models/props_equipment/tablegreenhouse01.mdl",
	"models/props_trainstation/train_transporter.mdl",
	"models/props_furniture/heavy_table.mdl",
	"models/props_interiors/table_bedside.mdl",
	"models/props_interiors/bed_houseboat.mdl",
	"models/props_equipment/snack_machine2.mdl",
	"models/props_vehicles/bus01.mdl",
	"models/props/terror/hamradio.mdl",
	"models/props_equipment/scaffolding.mdl",
	"models/props_unique/rope_bridge.mdl"
};
new String:g_sLampNames[39][64] =
{
	"Escalera",
	"Escalera Con Apoyo",
	"Puerta Exterior",
	"Refrigerador",
	"BBQ",
	"Mesa Picnic",
	"Cama",
	"Television",
	"Sofa",
	"Reja Grande",
	"Reja",
	"Reja Poli",
	"Urban 4 (pared)",
	"Auto 1",
	"Camion Militar",
	"Camion Combustible",
	"Ambulancia",
	"Letrero",
	"Escalera",
	"Saco Dormir 2",
	"Saco Dormir 3",
	"Maquina De Tikets",
	"Piano",
	"Sofa",
	"Sofa 1",
	"Sofa Silla",
	"Sofa Silla 1",
	"Paradero",
	"Silla Blanca",
	"Mesa Greenhouse",
	"Vagon Transporte",
	"Mesa Heavy",
	"Mesa Bedsyde",
	"Cama",
	"Snack Machine",
	"Bus",
	"Radio",
	"Andamio",
	"Puente Colgante"
};
public Plugin:myinfo =
{
	name = "Crear Objetos",
	description = "Permite generar y/o guardar objetos en el mapa actual",
	author = "PiromaX",
	version = "1.0",
	url = "[email protected]"
};
new g_iCurrentMode;
public __ext_core_SetNTVOptional()
{
	MarkNativeAsOptional("GetFeatureStatus");
	MarkNativeAsOptional("RequireFeature");
	MarkNativeAsOptional("AddCommandListener");
	MarkNativeAsOptional("RemoveCommandListener");
	VerifyCoreVersion();
	return 0;
}

bool:operator==(Float:,Float:)(Float:oper1, Float:oper2)
{
	return FloatCompare(oper1, oper2) == 0;
}

bool:operator!=(Float:,Float:)(Float:oper1, Float:oper2)
{
	return FloatCompare(oper1, oper2) != 0;
}

bool:operator!(Float:)(Float:oper)
{
	return oper & -1 == 0;
}

ExplodeString(String:text[], String:split[], String:buffers[][], maxStrings, maxStringLength, bool:copyRemainder)
{
	new reloc_idx;
	new idx;
	new total;
	new var1;
	if (maxStrings < 1 || !split[0])
	{
		return 0;
	}
	while ((idx = SplitString(text[reloc_idx], split, buffers[total], maxStringLength)) != -1)
	{
		reloc_idx = idx + reloc_idx;
		total++;
		if (maxStrings == total)
		{
			if (copyRemainder)
			{
				strcopy(buffers[total + -1], maxStringLength, text[reloc_idx - idx]);
			}
			return total;
		}
	}
	total++;
	strcopy(buffers[total], maxStringLength, text[reloc_idx]);
	return total;
}

EmitSoundToAll(String:sample[], entity, channel, level, flags, Float:volume, pitch, speakerentity, Float:origin[3], Float:dir[3], bool:updatePos, Float:soundtime)
{
	new clients[MaxClients];
	new total;
	new i = 1;
	while (i <= MaxClients)
	{
		if (IsClientInGame(i))
		{
			total++;
			clients[total] = i;
		}
		i++;
	}
	if (!total)
	{
		return 0;
	}
	EmitSound(clients, total, sample, entity, channel, level, flags, volume, pitch, speakerentity, origin, dir, updatePos, soundtime);
	return 0;
}

public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
{
	decl String:sGameName[12];
	GetGameFolderName(sGameName, 12);
	if (strcmp(sGameName, "left4dead", false))
	{
		strcopy(error, err_max, "Soporte solo para L4D1 menso");
		return APLRes:2;
	}
	return APLRes:0;
}

public OnPluginStart()
{
	SetupMenus();
	g_hCvarAllow = CreateConVar("p_permitir", "1", "0=Plugin Apagado, 1=Plugin Encendido.", 262400, false, 0.0, false, 0.0);
	g_hCvarBreak = CreateConVar("p_brk", "0", "Dejar en 0.", 262400, false, 0.0, false, 0.0);
	g_hCvarBright = CreateConVar("p_btk", "0.0", "Dejar en 0", 262400, false, 0.0, false, 0.0);
	g_hCvarColor = CreateConVar("p_lr", "0 0 0", "Dejar en 0 para angulos.", 262400, false, 0.0, false, 0.0);
	g_hCvarModes = CreateConVar("p_modos", "", "Encender plugin para estos modos de juego, separa por comas (no espacios). (Vacio = todos los modos encendidos).", 262400, false, 0.0, false, 0.0);
	g_hCvarModesOff = CreateConVar("p_modos_apagados", "", "Apagar plugin para estos modos de juego, separa por comas (no espacios). (Vacio = ningun modos apagado).", 262400, false, 0.0, false, 0.0);
	g_hCvarModesTog = CreateConVar("p_modos_config", "0", "Encender plugin para estos juegos. 0=Todos, 1=Coop, 2=Supervivencia, 4=Enfrentamiento. Agrega los numeros juntos.", 262400, false, 0.0, false, 0.0);
	g_hCvarRandom = CreateConVar("p_aleatorio", "-1", "-1=Todos, 0=apagado otro valor crea cosas de forma aleatoria (NO RECOMENDADO)", 262400, false, 0.0, false, 0.0);
	CreateConVar("p_version", "1.0", "Version del plugin.", 401664, false, 0.0, false, 0.0);
	AutoExecConfig(true, "PiromaX_Objetos", "sourcemod");
	g_hMPGameMode = FindConVar("mp_gamemode");
	HookConVarChange(g_hMPGameMode, ConVarChanged_Allow);
	HookConVarChange(g_hCvarAllow, ConVarChanged_Allow);
	HookConVarChange(g_hCvarModes, ConVarChanged_Allow);
	HookConVarChange(g_hCvarModesOff, ConVarChanged_Allow);
	HookConVarChange(g_hCvarModesTog, ConVarChanged_Allow);
	HookConVarChange(g_hCvarBreak, ConVarChanged_Cvars);
	HookConVarChange(g_hCvarBright, ConVarChanged_Cvars);
	HookConVarChange(g_hCvarColor, ConVarChanged_Cvars);
	HookConVarChange(g_hCvarRandom, ConVarChanged_Cvars);
	RegAdminCmd("sm_p+", CmdLamp, 16384, "Crea temporalmente objeto en tu mira.", "", 0);
	RegAdminCmd("sm_pset", CmdLampSet, 16384, "Por defecto", "", 0);
	RegAdminCmd("sm_pdel", CmdLampDelete, 16384, "Limpia objeto en tu mira", "", 0);
	RegAdminCmd("sm_pclear", CmdLampClear, 16384, "Elimina todo del mapa", "", 0);
	RegAdminCmd("sm_pwipe", CmdLampWipe, 16384, "Elimina todo elemento de la config sobre este mapa", "", 0);
	RegAdminCmd("sm_prefresh", CmdLampRefresh, 16384, "Remueve todo temporalmente en mapa, y carga objetos en cambiar mapa", "", 0);
	return 0;
}

public OnPluginEnd()
{
	ResetPlugin();
	return 0;
}

public OnMapStart()
{
	new i;
	while (i < 39)
	{
		PrecacheModel(g_sModels[i], true);
		i++;
	}
	PrecacheModel("models/props/de_train/light_inset.mdl", true);
	PrecacheModel("models/props/de_nuke/wall_light_off.mdl", true);
	PrecacheModel("models/props_lighting/light_construction.mdl", true);
	PrecacheModel("models/props_c17/lamppost03a_off.mdl", true);
	PrecacheParticle("sparks_generic_random");
	PrecacheParticle("emergency_light_strobe");
	new i;
	while (i < 5)
	{
		PrecacheSound(g_sSoundsZap[i], true);
		i++;
	}
	PrecacheSound("ambient/ambience/tv_static_loop2.wav", true);
	return 0;
}

public OnMapEnd()
{
	ResetPlugin();
	g_bLoaded = false;
	g_iRoundStart = 0;
	g_iPlayerSpawn = 0;
	return 0;
}

public OnConfigsExecuted()
{
	GetCvars();
	IsAllowed();
	return 0;
}

public ConVarChanged_Cvars(Handle:convar, String:oldValue[], String:newValue[])
{
	GetCvars();
	return 0;
}

public ConVarChanged_Allow(Handle:convar, String:oldValue[], String:newValue[])
{
	IsAllowed();
	return 0;
}

GetCvars()
{
	g_fCvarBright = GetConVarFloat(g_hCvarBright);
	g_iCvarBreak = GetConVarInt(g_hCvarBreak);
	g_iCvarRandom = GetConVarInt(g_hCvarRandom);
	GetConVarString(g_hCvarColor, g_sCvarColor, 12);
	g_iCvarColor = GetColor(g_sCvarColor);
	return 0;
}

IsAllowed()
{
	new bool:bCvarAllow = GetConVarBool(g_hCvarAllow);
	new bool:bAllowMode = IsAllowedGameMode();
	new var1;
	if (g_bCvarAllow && bCvarAllow == true && bAllowMode == true)
	{
		g_bCvarAllow = true;
		g_bLoaded = false;
		GetCvars();
		LoadLamps();
		HookEvents();
	}
	else
	{
		new var3;
		if (g_bCvarAllow == true && (bCvarAllow && bAllowMode))
		{
			g_bCvarAllow = false;
			ResetPlugin();
			UnhookEvents();
		}
	}
	return 0;
}

bool:IsAllowedGameMode()
{
	if (g_hMPGameMode)
	{
		new iCvarModesTog = GetConVarInt(g_hCvarModesTog);
		if (iCvarModesTog)
		{
			g_iCurrentMode = 0;
			new entity = CreateEntityByName("info_gamemode", -1);
			DispatchSpawn(entity);
			HookSingleEntityOutput(entity, "OnCoop", OnGamemode, true);
			HookSingleEntityOutput(entity, "OnSurvival", OnGamemode, true);
			HookSingleEntityOutput(entity, "OnVersus", OnGamemode, true);
			HookSingleEntityOutput(entity, "OnScavenge", OnGamemode, true);
			AcceptEntityInput(entity, "PostSpawnActivate", -1, -1, 0);
			AcceptEntityInput(entity, "Kill", -1, -1, 0);
			if (g_iCurrentMode)
			{
				if (!g_iCurrentMode & iCvarModesTog)
				{
					return false;
				}
			}
			return false;
		}
		decl String:sGameModes[64];
		decl String:sGameMode[64];
		GetConVarString(g_hMPGameMode, sGameMode, 64);
		Format(sGameMode, 64, ",%s,", sGameMode);
		GetConVarString(g_hCvarModes, sGameModes, 64);
		if (strcmp(sGameModes, "", true))
		{
			Format(sGameModes, 64, ",%s,", sGameModes);
			if (StrContains(sGameModes, sGameMode, false) == -1)
			{
				return false;
			}
		}
		GetConVarString(g_hCvarModesOff, sGameModes, 64);
		if (strcmp(sGameModes, "", true))
		{
			Format(sGameModes, 64, ",%s,", sGameModes);
			if (StrContains(sGameModes, sGameMode, false) != -1)
			{
				return false;
			}
		}
		return true;
	}
	return false;
}

public OnGamemode(String:output[], caller, activator, Float:delay)
{
	if (strcmp(output, "OnCoop", true))
	{
		if (strcmp(output, "OnSurvival", true))
		{
			if (strcmp(output, "OnVersus", true))
			{
				if (!(strcmp(output, "OnScavenge", true)))
				{
					g_iCurrentMode = 8;
				}
			}
			g_iCurrentMode = 4;
		}
		g_iCurrentMode = 2;
	}
	else
	{
		g_iCurrentMode = 1;
	}
	return 0;
}

HookEvents()
{
	HookEvent("round_start", Event_RoundStart, EventHookMode:2);
	HookEvent("round_end", Event_RoundEnd, EventHookMode:2);
	HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode:2);
	return 0;
}

UnhookEvents()
{
	UnhookEvent("round_start", Event_RoundStart, EventHookMode:2);
	UnhookEvent("round_end", Event_RoundEnd, EventHookMode:2);
	UnhookEvent("player_spawn", Event_PlayerSpawn, EventHookMode:2);
	return 0;
}

public Event_RoundStart(Handle:event, String:name[], bool:dontBroadcast)
{
	new var1;
	if (g_iPlayerSpawn == 1 && g_iRoundStart)
	{
		LoadLamps();
	}
	g_iRoundStart = 1;
	return 0;
}

public Event_RoundEnd(Handle:event, String:name[], bool:dontBroadcast)
{
	ResetPlugin();
	g_bLoaded = false;
	g_iRoundStart = 0;
	g_iPlayerSpawn = 0;
	return 0;
}

public Event_PlayerSpawn(Handle:event, String:name[], bool:dontBroadcast)
{
	new var1;
	if (g_iPlayerSpawn && g_iRoundStart == 1)
	{
		LoadLamps();
	}
	g_iPlayerSpawn = 1;
	return 0;
}

LoadLamps()
{
	new var1;
	if (g_bLoaded == true || g_iCvarRandom)
	{
		return 0;
	}
	g_bLoaded = true;
	decl String:sPath[256];
	BuildPath(PathType:0, sPath, 256, "%s", "data/PiromaX_Objetos.cfg");
	if (!FileExists(sPath, false))
	{
		return 0;
	}
	new Handle:hFile = CreateKeyValues("Objetos1", "", "");
	if (!FileToKeyValues(hFile, sPath))
	{
		CloseHandle(hFile);
		return 0;
	}
	decl String:sMap[64];
	GetCurrentMap(sMap, 64);
	if (!KvJumpToKey(hFile, sMap, false))
	{
		CloseHandle(hFile);
		return 0;
	}
	new iCount = KvGetNum(hFile, "num", 0);
	if (iCount)
	{
		new index;
		new i;
		new iRandom = g_iCvarRandom;
		new iIndexes[33];
		if (iCount > 32)
		{
			iCount = 32;
		}
		if (iRandom > iCount)
		{
			iRandom = iCount;
		}
		if (iRandom != -1)
		{
			i = 1;
			while (i <= iCount)
			{
				iIndexes[i + -1] = i;
				i++;
			}
			SortIntegers(iIndexes, iCount, SortOrder:2);
			iCount = iRandom;
		}
		i = 1;
		while (i <= iCount)
		{
			if (iRandom != -1)
			{
				index = iIndexes[i + -1];
			}
			else
			{
				index = i;
			}
			SpawnData(index, hFile, sMap, i, iCount);
			KvRewind(hFile);
			i++;
		}
		CloseHandle(hFile);
		return 0;
	}
	CloseHandle(hFile);
	return 0;
}

SpawnData(index, Handle:hFile, String:sMap[], i, iCount)
{
	new color;
	new type;
	new Float:brightness = 0.0;
	new Float:glow = 0.0;
	new halo;
	new beam;
	new length;
	new width;
	new speed;
	new breakable;
	decl String:sTemp[16];
	decl Float:vPos[3];
	decl Float:vAng[3];
	KvJumpToKey(hFile, sMap, false);
	IntToString(index, sTemp, 16);
	if (KvJumpToKey(hFile, sTemp, false))
	{
		KvGetVector(hFile, "origin", vPos, 8832);
		new var1;
		if (0.0 == vPos[0] && 0.0 == vPos[0] && 0.0 == vPos[0])
		{
			LogError("Error: 0,0,0 origin. Iteration=%d. Index=%d. Count=%d.", i, index, iCount);
		}
		KvGetVector(hFile, "angle", vAng, 8832);
		KvGetString(hFile, "Ganko", sTemp, 16, "");
		color = GetColor(sTemp);
		type = KvGetNum(hFile, "type", 0);
		brightness = KvGetFloat(hFile, "brightness", g_fCvarBright);
		glow = KvGetFloat(hFile, "glow", 0.3);
		halo = KvGetNum(hFile, "halo", 100);
		beam = KvGetNum(hFile, "beam", 100);
		length = KvGetNum(hFile, "length", 100);
		width = KvGetNum(hFile, "width", 40);
		speed = KvGetNum(hFile, "speed", 30);
		breakable = KvGetNum(hFile, "breakable", g_iCvarBreak);
		SpawnLamp(vPos, vAng, color, type, index, brightness, glow, halo, beam, length, width, speed, breakable);
	}
	return 0;
}

GetColor(String:sTemp[])
{
	decl String:sColors[3][4];
	ExplodeString(sTemp, " ", sColors, 3, 4, false);
	new color = StringToInt(sColors[0][sColors], 10);
	color = StringToInt(sColors[1], 10) * 256 + color;
	color = StringToInt(sColors[2], 10) * 65536 + color;
	return color;
}

SpawnLamp(Float:vOrigin[3], Float:vAngles[3], color, type, cfgindex, Float:brightness, Float:glow, halo, beam, length, width, speed, breakable)
{
	new var1;
	if (type < 1 || type > 39)
	{
		LogError("Invalid type %d", type);
		return -1;
	}
	new index = -1;
	new i;
	while (i < 32)
	{
		if (!IsValidEntRef(g_iEntities[i][0]))
		{
			index = i;
			if (index == -1)
			{
				return -1;
			}
			new entity;
			new var2;
			if (type == 4 || type == 8)
			{
				entity = CreateEntityByName("prop_physics_override", -1);
				DispatchKeyValue(entity, "solid", "0");
			}
			else
			{
				entity = CreateEntityByName("prop_dynamic", -1);
				DispatchKeyValue(entity, "solid", "6");
			}
			DispatchKeyValue(entity, "model", g_sModels[type + -1]);
			if (type >= 15)
			{
				SetEntProp(entity, PropType:0, "m_nSkin", any:1, 4, 0);
			}
			DispatchKeyValue(entity, "health", "50");
			DispatchSpawn(entity);
			g_iEntities[index][0] = EntIndexToEntRef(entity);
			g_iEntities[index][7] = type;
			g_iEntities[index][8] = cfgindex;
			new var3;
			if (g_iCvarBreak && breakable)
			{
				HookSingleEntityOutput(entity, "OnTakeDamage", OnBreak, false);
				HookSingleEntityOutput(entity, "OnHealthChanged", OnBreak, false);
			}
			new Float:vAng[3] = 0.0;
			new target = entity;
			if (type == 8)
			{
				if (GetRandomInt(0, 1))
				{
					SetEntProp(target, PropType:0, "m_nSkin", any:1, 4, 0);
				}
				else
				{
					SetEntProp(target, PropType:0, "m_nSkin", any:2, 4, 0);
				}
				TeleportEntity(target, vOrigin, vAngles, NULL_VECTOR);
				EmitSoundToAll("ambient/ambience/tv_static_loop2.wav", target, 0, 60, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
				return index;
			}
			if (type == 1)
			{
				entity = MakeLightDynamic(9200, vAng, color, brightness);
			}
			else
			{
				if (type == 9)
				{
					entity = MakeLightDynamic(9212, vAng, color, brightness);
				}
				if (type == 14)
				{
					entity = MakeLightDynamic(9224, vAng, color, brightness);
				}
				if (type == 13)
				{
					new rotating = CreateEntityByName("func_rotating", -1);
					DispatchKeyValue(rotating, "spawnflags", "0");
					decl String:sTemp[8];
					IntToString(speed, sTemp, 8);
					DispatchKeyValue(rotating, "maxspeed", sTemp);
					DispatchKeyValue(rotating, "fanfriction", "0");
					DispatchSpawn(rotating);
					g_iEntities[index][2] = EntIndexToEntRef(rotating);
					entity = MakeBeamSpotlight(9296, vAng, color, glow, halo, beam, length, width, true);
					g_iEntities[index][3] = EntIndexToEntRef(entity);
					ParentEntities(rotating, entity);
					entity = MakeLightDynamic(9308, vAng, color, brightness);
					g_iEntities[index][1] = EntIndexToEntRef(entity);
					ParentEntities(rotating, entity);
					TeleportEntity(target, NULL_VECTOR, vAng, NULL_VECTOR);
					ParentEntities(rotating, target);
					TeleportEntity(rotating, vOrigin, vAngles, NULL_VECTOR);
					return index;
				}
				new var4;
				if (type == 4 && beam)
				{
					entity = MakeLightDynamic(9320, vAng, color, brightness);
				}
				new var5;
				if (type == 5 || type == 6 || type == 7)
				{
					entity = MakeLightDynamic(9332, vAng, color, brightness);
				}
				if (type == 2)
				{
					entity = MakeLightDynamic(9344, vAng, color, brightness);
				}
				if (type == 10)
				{
					entity = MakeLightDynamic(9356, vAng, color, brightness);
				}
				if (type == 11)
				{
					entity = MakeLightDynamic(9368, vAng, color, brightness);
				}
				if (type == 12)
				{
					entity = MakeLightDynamic(9380, vAng, color, brightness);
				}
				new var6;
				if (type == 21 || type == 22)
				{
					entity = MakeLightDynamic(9392, vAng, color, brightness);
				}
				if (type == 3)
				{
					entity = MakeLightDynamic(9404, vAng, color, brightness);
				}
				if (type == 15)
				{
					entity = MakeLightDynamic(9416, vAng, color, brightness);
				}
				new var7;
				if (type == 16 || type == 18 || type == 19)
				{
					entity = MakeLightDynamic(9428, vAng, color, brightness);
				}
				if (type == 20)
				{
					entity = MakeLightDynamic(9440, vAng, color, brightness);
				}
				if (type == 23)
				{
					entity = MakeLightDynamic(9452, vAng, color, brightness);
				}
				new var8;
				if (type == 24 || type == 26)
				{
					entity = MakeLightDynamic(9464, vAng, color, brightness);
				}
				if (type == 28)
				{
					entity = MakeLightDynamic(9476, vAng, color, brightness);
				}
				if (type == 29)
				{
					entity = MakeLightDynamic(9488, vAng, color, brightness);
				}
				if (type == 30)
				{
					entity = MakeLightDynamic(9500, vAng, color, brightness);
				}
				if (type == 31)
				{
					entity = MakeLightDynamic(9512, vAng, color, brightness);
				}
				if (type == 32)
				{
					entity = MakeLightDynamic(9524, vAng, color, brightness);
				}
				if (type == 33)
				{
					entity = MakeLightDynamic(9536, vAng, color, brightness);
				}
				if (type == 34)
				{
					entity = MakeLightDynamic(9548, vAng, color, brightness);
				}
				if (type == 35)
				{
					entity = MakeLightDynamic(9560, vAng, color, brightness);
				}
				if (type == 36)
				{
					entity = MakeLightDynamic(9572, vAng, color, brightness);
				}
				new var9;
				if (type == 37 || type == 38 || type == 39)
				{
					entity = MakeLightDynamic(9584, vAng, color, brightness);
				}
				entity = MakeLightDynamic(9596, vAng, color, brightness);
			}
			g_iEntities[index][1] = EntIndexToEntRef(entity);
			ParentEntities(target, entity);
			TeleportEntity(target, vOrigin, vAngles, NULL_VECTOR);
			return index;
		}
		i++;
	}
	if (index == -1)
	{
		return -1;
	}
	new entity;
	new var2;
	if (type == 4 || type == 8)
	{
		entity = CreateEntityByName("prop_physics_override", -1);
		DispatchKeyValue(entity, "solid", "0");
	}
	else
	{
		entity = CreateEntityByName("prop_dynamic", -1);
		DispatchKeyValue(entity, "solid", "6");
	}
	DispatchKeyValue(entity, "model", g_sModels[type + -1]);
	if (type >= 15)
	{
		SetEntProp(entity, PropType:0, "m_nSkin", any:1, 4, 0);
	}
	DispatchKeyValue(entity, "health", "50");
	DispatchSpawn(entity);
	g_iEntities[index][0] = EntIndexToEntRef(entity);
	g_iEntities[index][7] = type;
	g_iEntities[index][8] = cfgindex;
	new var3;
	if (g_iCvarBreak && breakable)
	{
		HookSingleEntityOutput(entity, "OnTakeDamage", OnBreak, false);
		HookSingleEntityOutput(entity, "OnHealthChanged", OnBreak, false);
	}
	new Float:vAng[3] = 0.0;
	new target = entity;
	if (type == 8)
	{
		if (GetRandomInt(0, 1))
		{
			SetEntProp(target, PropType:0, "m_nSkin", any:1, 4, 0);
		}
		else
		{
			SetEntProp(target, PropType:0, "m_nSkin", any:2, 4, 0);
		}
		TeleportEntity(target, vOrigin, vAngles, NULL_VECTOR);
		EmitSoundToAll("ambient/ambience/tv_static_loop2.wav", target, 0, 60, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
		return index;
	}
	if (type == 1)
	{
		entity = MakeLightDynamic(9200, vAng, color, brightness);
	}
	else
	{
		if (type == 9)
		{
			entity = MakeLightDynamic(9212, vAng, color, brightness);
		}
		if (type == 14)
		{
			entity = MakeLightDynamic(9224, vAng, color, brightness);
		}
		if (type == 13)
		{
			new rotating = CreateEntityByName("func_rotating", -1);
			DispatchKeyValue(rotating, "spawnflags", "0");
			decl String:sTemp[8];
			IntToString(speed, sTemp, 8);
			DispatchKeyValue(rotating, "maxspeed", sTemp);
			DispatchKeyValue(rotating, "fanfriction", "0");
			DispatchSpawn(rotating);
			g_iEntities[index][2] = EntIndexToEntRef(rotating);
			entity = MakeBeamSpotlight(9296, vAng, color, glow, halo, beam, length, width, true);
			g_iEntities[index][3] = EntIndexToEntRef(entity);
			ParentEntities(rotating, entity);
			entity = MakeLightDynamic(9308, vAng, color, brightness);
			g_iEntities[index][1] = EntIndexToEntRef(entity);
			ParentEntities(rotating, entity);
			TeleportEntity(target, NULL_VECTOR, vAng, NULL_VECTOR);
			ParentEntities(rotating, target);
			TeleportEntity(rotating, vOrigin, vAngles, NULL_VECTOR);
			return index;
		}
		new var4;
		if (type == 4 && beam)
		{
			entity = MakeLightDynamic(9320, vAng, color, brightness);
		}
		new var5;
		if (type == 5 || type == 6 || type == 7)
		{
			entity = MakeLightDynamic(9332, vAng, color, brightness);
		}
		if (type == 2)
		{
			entity = MakeLightDynamic(9344, vAng, color, brightness);
		}
		if (type == 10)
		{
			entity = MakeLightDynamic(9356, vAng, color, brightness);
		}
		if (type == 11)
		{
			entity = MakeLightDynamic(9368, vAng, color, brightness);
		}
		if (type == 12)
		{
			entity = MakeLightDynamic(9380, vAng, color, brightness);
		}
		new var6;
		if (type == 21 || type == 22)
		{
			entity = MakeLightDynamic(9392, vAng, color, brightness);
		}
		if (type == 3)
		{
			entity = MakeLightDynamic(9404, vAng, color, brightness);
		}
		if (type == 15)
		{
			entity = MakeLightDynamic(9416, vAng, color, brightness);
		}
		new var7;
		if (type == 16 || type == 18 || type == 19)
		{
			entity = MakeLightDynamic(9428, vAng, color, brightness);
		}
		if (type == 20)
		{
			entity = MakeLightDynamic(9440, vAng, color, brightness);
		}
		if (type == 23)
		{
			entity = MakeLightDynamic(9452, vAng, color, brightness);
		}
		new var8;
		if (type == 24 || type == 26)
		{
			entity = MakeLightDynamic(9464, vAng, color, brightness);
		}
		if (type == 28)
		{
			entity = MakeLightDynamic(9476, vAng, color, brightness);
		}
		if (type == 29)
		{
			entity = MakeLightDynamic(9488, vAng, color, brightness);
		}
		if (type == 30)
		{
			entity = MakeLightDynamic(9500, vAng, color, brightness);
		}
		if (type == 31)
		{
			entity = MakeLightDynamic(9512, vAng, color, brightness);
		}
		if (type == 32)
		{
			entity = MakeLightDynamic(9524, vAng, color, brightness);
		}
		if (type == 33)
		{
			entity = MakeLightDynamic(9536, vAng, color, brightness);
		}
		if (type == 34)
		{
			entity = MakeLightDynamic(9548, vAng, color, brightness);
		}
		if (type == 35)
		{
			entity = MakeLightDynamic(9560, vAng, color, brightness);
		}
		if (type == 36)
		{
			entity = MakeLightDynamic(9572, vAng, color, brightness);
		}
		new var9;
		if (type == 37 || type == 38 || type == 39)
		{
			entity = MakeLightDynamic(9584, vAng, color, brightness);
		}
		entity = MakeLightDynamic(9596, vAng, color, brightness);
	}
	g_iEntities[index][1] = EntIndexToEntRef(entity);
	ParentEntities(target, entity);
	TeleportEntity(target, vOrigin, vAngles, NULL_VECTOR);
	return index;
}

ParentEntities(target, entity)
{
	SetVariantString("!activator");
	AcceptEntityInput(entity, "SetParent", target, -1, 0);
	return 0;
}

public OnBreak(String:output[], caller, activator, Float:delay)
{
	new entity = EntIndexToEntRef(caller);
	new i;
	while (i < 32)
	{
		if (g_iEntities[i][0] == entity)
		{
			new type = g_iEntities[i][7];
			UnhookSingleEntityOutput(entity, "OnTakeDamage", OnBreak);
			UnhookSingleEntityOutput(entity, "OnHealthChanged", OnBreak);
			if (type == 13)
			{
				SetEntProp(caller, PropType:0, "m_nSkin", any:1, 4, 0);
			}
			else
			{
				new var1;
				if (type == 30 || type == 31)
				{
					SetEntProp(caller, PropType:0, "m_nSkin", any:1, 4, 0);
				}
				if (type == 15)
				{
					SetEntityModel(caller, "models/props/de_train/light_inset.mdl");
				}
				if (type == 16)
				{
					SetEntityModel(caller, "models/props/de_nuke/wall_light_off.mdl");
				}
				if (type == 33)
				{
					SetEntityModel(caller, "models/props_c17/lamppost03a_off.mdl");
				}
				if (type == 20)
				{
					SetEntityModel(caller, "models/props_lighting/light_construction.mdl");
					SetEntProp(caller, PropType:0, "m_nSkin", any:0, 4, 0);
				}
				SetEntProp(caller, PropType:0, "m_nSkin", any:0, 4, 0);
			}
			new iType = GetRandomInt(0, 4);
			EmitSoundToAll(g_sSoundsZap[iType], entity, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
			entity = CreateEntityByName("info_particle_system", -1);
			if (entity != -1)
			{
				DispatchKeyValue(entity, "effect_name", "sparks_generic_random");
				DispatchSpawn(entity);
				ActivateEntity(entity);
				AcceptEntityInput(entity, "Start", -1, -1, 0);
				decl Float:vPos[3];
				GetEntPropVector(caller, PropType:1, "m_vecOrigin", vPos, 0);
				if (type == 8)
				{
					vPos[2] += 30.0;
				}
				else
				{
					if (type == 4)
					{
						vPos[2] += 80.0;
					}
					new var2;
					if (type == 5 || type == 6 || type == 7)
					{
						vPos[2] += 65.0;
					}
					if (type == 14)
					{
						vPos[1] -= 10.0;
						vPos[2] += 70.0;
					}
					vPos[2] += 5.0;
				}
				TeleportEntity(entity, vPos, NULL_VECTOR, NULL_VECTOR);
				SetVariantString("OnUser1 !self:Stop::0.2:1");
				AcceptEntityInput(entity, "AddOutput", -1, -1, 0);
				SetVariantString("OnUser1 !self:Kill::0.3:1");
				AcceptEntityInput(entity, "AddOutput", -1, -1, 0);
				AcceptEntityInput(entity, "FireUser1", -1, -1, 0);
			}
			DeleteLamp(i, false);
			return 0;
		}
		i++;
	}
	return 0;
}

MakeLightDynamic(Float:vOrigin[3], Float:vAngles[3], color, Float:brightness)
{
	new entity = CreateEntityByName("light_dynamic", -1);
	if (entity == -1)
	{
		return 0;
	}
	DispatchKeyValue(entity, "_light", "0 0 0 255");
	DispatchKeyValue(entity, "brightness", "1");
	DispatchKeyValueFloat(entity, "spotlight_radius", 32.0);
	DispatchKeyValueFloat(entity, "distance", brightness);
	DispatchKeyValue(entity, "style", "0");
	SetEntProp(entity, PropType:0, "m_clrRender", color, 4, 0);
	DispatchSpawn(entity);
	AcceptEntityInput(entity, "TurnOn", -1, -1, 0);
	TeleportEntity(entity, vOrigin, vAngles, NULL_VECTOR);
	return entity;
}

MakeBeamSpotlight(Float:vOrigin[3], Float:vAngles[3], color, Float:glow, halo, beam, length, width, bool:rotate)
{
	new entity = CreateEntityByName("beam_spotlight", -1);
	if (entity == -1)
	{
		return 0;
	}
	if (rotate)
	{
		DispatchKeyValue(entity, "SpotlightWidth", "0");
	}
	else
	{
		DispatchKeyValue(entity, "SpotlightWidth", "0");
	}
	DispatchKeyValue(entity, "spawnflags", "3");
	decl String:sTemp[8];
	IntToString(halo, sTemp, 8);
	DispatchKeyValue(entity, "HaloScale", sTemp);
	IntToString(width, sTemp, 8);
	DispatchKeyValue(entity, "SpotlightWidth", sTemp);
	IntToString(length, sTemp, 8);
	DispatchKeyValue(entity, "SpotlightLength", sTemp);
	IntToString(beam, sTemp, 8);
	DispatchKeyValue(entity, "renderamt", sTemp);
	DispatchKeyValueFloat(entity, "HDRColorScale", glow);
	SetEntProp(entity, PropType:0, "m_clrRender", color, 4, 0);
	DispatchSpawn(entity);
	AcceptEntityInput(entity, "TurnOn", -1, -1, 0);
	TeleportEntity(entity, vOrigin, vAngles, NULL_VECTOR);
	return entity;
}

SetupMenus()
{
	g_hMenuMain = CreateMenu(MainMenuHandler, MenuAction:28);
	AddMenuItem(g_hMenuMain, "", "Objeto Temporal", 0);
	AddMenuItem(g_hMenuMain, "", "Guardar Objeto", 0);
	AddMenuItem(g_hMenuMain, "", "Girar", 0);
	AddMenuItem(g_hMenuMain, "", "Mover", 0);
	AddMenuItem(g_hMenuMain, "", "Borrar", 0);
	AddMenuItem(g_hMenuMain, "", "Refrescar", 0);
	AddMenuItem(g_hMenuMain, "", "Lista", 0);
	AddMenuItem(g_hMenuMain, "", "Limpiar", 0);
	AddMenuItem(g_hMenuMain, "", "Eliminar Todo", 0);
	SetMenuTitle(g_hMenuMain, "PiromaX Objetos");
	SetMenuExitButton(g_hMenuMain, true);
	g_hMenuTemp = CreateMenu(TempMenuHandler, MenuAction:28);
	AddMenuList(g_hMenuTemp);
	SetMenuTitle(g_hMenuTemp, "Objeto Temporal");
	SetMenuExitBackButton(g_hMenuTemp, true);
	g_hMenuSave = CreateMenu(SaveMenuHandler, MenuAction:28);
	AddMenuList(g_hMenuSave);
	SetMenuTitle(g_hMenuSave, "Guardar Objeto");
	SetMenuExitBackButton(g_hMenuSave, true);
	g_hMenuBrightness = CreateMenu(BrightnessMenuHandler, MenuAction:28);
	AddMenuItem(g_hMenuBrightness, "", "50", 0);
	AddMenuItem(g_hMenuBrightness, "", "100", 0);
	AddMenuItem(g_hMenuBrightness, "", "200", 0);
	AddMenuItem(g_hMenuBrightness, "", "250", 0);
	AddMenuItem(g_hMenuBrightness, "", "300", 0);
	AddMenuItem(g_hMenuBrightness, "", "500", 0);
	AddMenuItem(g_hMenuBrightness, "", "GUARDAR", 0);
	SetMenuTitle(g_hMenuBrightness, "Brillo");
	SetMenuExitBackButton(g_hMenuBrightness, true);
	g_hMenuColor = CreateMenu(ColorMenuHandler, MenuAction:28);
	AddMenuItem(g_hMenuColor, "", "Rojo", 0);
	AddMenuItem(g_hMenuColor, "", "Verde", 0);
	AddMenuItem(g_hMenuColor, "", "azul", 0);
	AddMenuItem(g_hMenuColor, "", "Morado", 0);
	AddMenuItem(g_hMenuColor, "", "Naranjo", 0);
	AddMenuItem(g_hMenuColor, "", "Blanco", 0);
	AddMenuItem(g_hMenuColor, "", "GUARDAR", 0);
	SetMenuTitle(g_hMenuColor, "Color luz");
	SetMenuExitBackButton(g_hMenuColor, true);
	g_hMenuAng = CreateMenu(AngMenuHandler, MenuAction:28);
	AddMenuItem(g_hMenuAng, "", "X + 5.0", 0);
	AddMenuItem(g_hMenuAng, "", "Y + 5.0", 0);
	AddMenuItem(g_hMenuAng, "", "Z + 5.0", 0);
	AddMenuItem(g_hMenuAng, "", "X - 5.0", 0);
	AddMenuItem(g_hMenuAng, "", "Y - 5.0", 0);
	AddMenuItem(g_hMenuAng, "", "Z - 5.0", 0);
	AddMenuItem(g_hMenuAng, "", "GUARDAR", 0);
	SetMenuTitle(g_hMenuAng, "Girar Objeto");
	SetMenuExitBackButton(g_hMenuAng, true);
	g_hMenuPos = CreateMenu(PosMenuHandler, MenuAction:28);
	AddMenuItem(g_hMenuPos, "", "X + 0.5", 0);
	AddMenuItem(g_hMenuPos, "", "Y + 0.5", 0);
	AddMenuItem(g_hMenuPos, "", "Z + 0.5", 0);
	AddMenuItem(g_hMenuPos, "", "X - 0.5", 0);
	AddMenuItem(g_hMenuPos, "", "Y - 0.5", 0);
	AddMenuItem(g_hMenuPos, "", "Z - 0.5", 0);
	AddMenuItem(g_hMenuPos, "", "GUARDAR", 0);
	SetMenuTitle(g_hMenuPos, "Mover Objeto");
	SetMenuExitBackButton(g_hMenuPos, true);
	return 0;
}

AddMenuList(Handle:menu)
{
	new i;
	while (i < 39)
	{
		AddMenuItem(menu, "", g_sLampNames[i], 0);
		i++;
	}
	return 0;
}

ShowMenuMain(client)
{
	DisplayMenu(g_hMenuMain, client, 0);
	return 0;
}

public MainMenuHandler(Handle:menu, MenuAction:action, client, index)
{
	if (action == MenuAction:4)
	{
		if (index)
		{
			if (index == 1)
			{
				ShowMenuSave(client);
			}
			if (index == 2)
			{
				ShowMenuAng(client);
			}
			if (index == 3)
			{
				ShowMenuPos(client);
			}
			if (index == 4)
			{
				ConfirmDelete(client);
			}
			if (index == 5)
			{
				CmdLampRefresh(client, 0);
				ShowMenuMain(client);
			}
			if (index == 6)
			{
				ListLamps(client);
				ShowMenuMain(client);
			}
			if (index == 7)
			{
				ResetPlugin();
				PrintToChat(client, "%sEl mapa esta limpio de Objetos.", "\x05P+ \x01|");
				ShowMenuMain(client);
			}
			if (index == 8)
			{
				ConfirmWipe(client);
			}
		}
		ShowMenuTemp(client);
	}
	return 0;
}

ConfirmDelete(client)
{
	new Handle:hMenu = CreateMenu(DeleteMenuHandler, MenuAction:28);
	AddMenuItem(hMenu, "", "Si", 0);
	AddMenuItem(hMenu, "", "No", 0);
	SetMenuTitle(hMenu, "Borrar Objeto de la Config?");
	SetMenuExitBackButton(hMenu, true);
	DisplayMenu(hMenu, client, 0);
	return 0;
}

public DeleteMenuHandler(Handle:menu, MenuAction:action, client, index)
{
	if (action == MenuAction:8)
	{
		if (index == -6)
		{
			ShowMenuMain(client);
		}
	}
	else
	{
		if (action == MenuAction:16)
		{
			CloseHandle(menu);
		}
		if (action == MenuAction:4)
		{
			if (index)
			{
				if (index == 1)
				{
					ShowMenuMain(client);
				}
			}
			CmdLampDelete(client, 0);
			ShowMenuMain(client);
		}
	}
	return 0;
}

ConfirmWipe(client)
{
	new Handle:hMenu = CreateMenu(WipeMenuHandler, MenuAction:28);
	AddMenuItem(hMenu, "", "Si", 0);
	AddMenuItem(hMenu, "", "No", 0);
	SetMenuTitle(hMenu, "Borrar Todos los objetos de este mapa?");
	SetMenuExitBackButton(hMenu, true);
	DisplayMenu(hMenu, client, 0);
	return 0;
}

public WipeMenuHandler(Handle:menu, MenuAction:action, client, index)
{
	if (action == MenuAction:8)
	{
		if (index == -6)
		{
			ShowMenuMain(client);
		}
	}
	else
	{
		if (action == MenuAction:16)
		{
			CloseHandle(menu);
		}
		if (action == MenuAction:4)
		{
			if (index)
			{
				if (index == 1)
				{
					ShowMenuMain(client);
				}
			}
			WipeLamps(client);
			ShowMenuMain(client);
		}
	}
	return 0;
}

ListLamps(client)
{
	decl Float:vPos[3];
	new i;
	new entity;
	new count;
	i = 0;
	while (i < 32)
	{
		entity = g_iEntities[i][0];
		if (IsValidEntRef(entity))
		{
			count++;
			GetEntPropVector(entity, PropType:1, "m_vecOrigin", vPos, 0);
			if (client)
			{
				PrintToChat(client, "%s%d) %f %f %f", "\x05P+ \x01|", i + 1, vPos, vPos[1], vPos[2]);
			}
			ReplyToCommand(client, "[P+] %d) %f %f %f", i + 1, vPos, vPos[1], vPos[2]);
		}
		i++;
	}
	if (client)
	{
		ReplyToCommand(client, "%sTotal: %d.", "\x05P+ \x01|", count);
	}
	else
	{
		PrintToChat(client, "[P+] Total: %d.", count);
	}
	return 0;
}

WipeLamps(client)
{
	new i;
	while (i < 32)
	{
		g_iEntities[i][8] = 0;
		i++;
	}
	decl String:sPath[256];
	BuildPath(PathType:0, sPath, 256, "%s", "data/PiromaX_Objetos.cfg");
	if (!FileExists(sPath, false))
	{
		PrintToChat(client, "%sProblema: Todavia no has creado objetos para la config (\x05%s\x01).", "\x05P+ \x01|", sPath);
		return 0;
	}
	new Handle:hFile = CreateKeyValues("Objetos1", "", "");
	if (!FileToKeyValues(hFile, sPath))
	{
		PrintToChat(client, "%sError: no se puede cargar objeto de la config (\x05%s\x01).", "\x05P+ \x01|", sPath);
		CloseHandle(hFile);
		return 0;
	}
	decl String:sMap[64];
	GetCurrentMap(sMap, 64);
	if (!KvJumpToKey(hFile, sMap, false))
	{
		PrintToChat(client, "%sError: Mapa actual no tiene objetos en la config.", "\x05P+ \x01|");
		CloseHandle(hFile);
		return 0;
	}
	KvDeleteThis(hFile);
	KvRewind(hFile);
	KeyValuesToFile(hFile, sPath);
	CloseHandle(hFile);
	PrintToChat(client, "%s(0/%d) - Todos los objetos removidos del config, Ahora usa \x05!p+ \x01opcion limpiar y luego \x05!p+ \x01para crear nuevos", "\x05P+ \x01|", 32);
	return 0;
}

ShowMenuTemp(client)
{
	DisplayMenu(g_hMenuTemp, client, 0);
	return 0;
}

public TempMenuHandler(Handle:menu, MenuAction:action, client, index)
{
	if (action == MenuAction:8)
	{
		if (index == -6)
		{
			ShowMenuMain(client);
		}
	}
	else
	{
		if (action == MenuAction:4)
		{
			decl Float:vPos[3];
			decl Float:vAng[3];
			new var1;
			if (index + 1 == 10 || index + 1 == 11)
			{
				SetupLamp(client, vPos, vAng, 65280, index + 1, 0);
			}
			else
			{
				new var2;
				if (index + 1 == 4 || index + 1 == 5 || index + 1 == 6 || index + 1 == 13)
				{
					SetupLamp(client, vPos, vAng, 16777215, index + 1, 0);
				}
				if (index + 1 == 7)
				{
					SetupLamp(client, vPos, vAng, 255, index + 1, 0);
				}
				SetupLamp(client, vPos, vAng, g_iCvarColor, index + 1, 0);
			}
			new menupos = GetMenuSelectionPosition();
			DisplayMenuAtItem(menu, client, menupos, 0);
		}
	}
	return 0;
}

ShowMenuSave(client)
{
	DisplayMenu(g_hMenuSave, client, 0);
	return 0;
}

public SaveMenuHandler(Handle:menu, MenuAction:action, client, index)
{
	if (action == MenuAction:8)
	{
		if (index == -6)
		{
			ShowMenuMain(client);
		}
	}
	else
	{
		if (action == MenuAction:4)
		{
			new var1;
			if (index + 1 == 10 || index + 1 == 11)
			{
				SaveLampSpawn(client, index + 1, 65280, "0 0 0");
			}
			else
			{
				new var2;
				if (index + 1 == 4 || index + 1 == 5 || index + 1 == 6 || index + 1 == 13)
				{
					SaveLampSpawn(client, index + 1, 16777215, "0 0 0");
				}
				if (index + 1 == 7)
				{
					SaveLampSpawn(client, index + 1, 255, "0 0 0");
				}
				SaveLampSpawn(client, index + 1, g_iCvarColor, g_sCvarColor);
			}
			new menupos = GetMenuSelectionPosition();
			DisplayMenuAtItem(menu, client, menupos, 0);
		}
	}
	return 0;
}

SaveLampSpawn(client, type, color, String:sColor[12])
{
	decl Float:vPos[3];
	decl Float:vAng[3];
	new index = SetupLamp(client, vPos, vAng, color, type, 0);
	if (index != -1)
	{
		new cfgindex = SaveLampNew(client, vPos, vAng, type, sColor);
		g_iEntities[index][8] = cfgindex;
	}
	return 0;
}

SaveLampNew(client, Float:vPos[3], Float:vAng[3], type, String:sColor[12])
{
	decl String:sPath[256];
	BuildPath(PathType:0, sPath, 256, "%s", "data/PiromaX_Objetos.cfg");
	if (!FileExists(sPath, false))
	{
		new Handle:hCfg = OpenFile(sPath, "w");
		WriteFileLine(hCfg, "");
		CloseHandle(hCfg);
	}
	new Handle:hFile = CreateKeyValues("Objetos1", "", "");
	FileToKeyValues(hFile, sPath);
	decl String:sMap[64];
	GetCurrentMap(sMap, 64);
	if (!KvJumpToKey(hFile, sMap, true))
	{
		PrintToChat(client, "%sError: No se pueden agregar mas objetos en este mapa al config.", "\x05P+ \x01|");
		CloseHandle(hFile);
		return 0;
	}
	new iCount = KvGetNum(hFile, "num", 0);
	if (iCount >= 32)
	{
		PrintToChat(client, "%sError: No se pueden agregar mas objetos. Usado: (\x05%d/%d\x01).", "\x05P+ \x01|", iCount, 32);
		CloseHandle(hFile);
		return 0;
	}
	iCount++;
	KvSetNum(hFile, "num", iCount);
	new Float:glow = 0.0;
	new halo;
	new beam;
	new length;
	new width;
	new speed;
	if (type == 14)
	{
		length = 0;
		width = 0;
		speed = 0;
	}
	else
	{
		if (type == 13)
		{
			length = 0;
			width = 0;
			speed = 0;
		}
		if (type == 4)
		{
			glow = 0.0;
			halo = 0;
			beam = 0;
			length = 0;
			width = 0;
		}
		new var1;
		if (type == 5 || type == 6 || type == 7)
		{
			glow = 0.0;
			halo = 0;
			beam = 0;
			length = 0;
			width = 0;
		}
		if (type == 2)
		{
			glow = 0.0;
			halo = 0;
			length = 0;
			width = 0;
		}
		if (type == 29)
		{
			glow = 0.0;
			halo = 0;
			length = 0;
			width = 0;
		}
		new var2;
		if (type == 32 || type == 33 || type == 34)
		{
			if (type == 32)
			{
				width = 0;
			}
			else
			{
				if (type == 33)
				{
					width = 0;
				}
				if (type == 34)
				{
					width = 0;
				}
			}
			glow = 0.0;
			halo = 0;
			beam = 0;
			length = 0;
		}
	}
	decl String:sTemp[12];
	IntToString(iCount, sTemp, 12);
	if (KvJumpToKey(hFile, sTemp, true))
	{
		KvSetVector(hFile, "origin", vPos);
		KvSetVector(hFile, "angle", vAng);
		KvSetNum(hFile, "type", type);
		KvSetString(hFile, "Ganko", sColor);
		if (glow)
		{
			KvSetFloat(hFile, "glow", glow);
		}
		if (halo)
		{
			KvSetNum(hFile, "halo", halo);
		}
		if (beam)
		{
			KvSetNum(hFile, "beam", beam);
		}
		if (length)
		{
			KvSetNum(hFile, "length", length);
		}
		if (width)
		{
			KvSetNum(hFile, "width", width);
		}
		if (speed)
		{
			KvSetNum(hFile, "speed", speed);
		}
	}
	KvRewind(hFile);
	KeyValuesToFile(hFile, sPath);
	CloseHandle(hFile);
	PrintToChat(client, "%s(\x05%d/%d\x01) - Guardado en pos:[\x05%f %f %f\x01]", "\x05P+ \x01|", iCount, 32, vPos, vPos[1], vPos[2]);
	return iCount;
}

SetupLamp(client, Float:vPos[3], Float:vAng[3], color, type, cfgindex)
{
	GetClientEyeAngles(client, vAng);
	GetClientEyePosition(client, vPos);
	new Handle:trace = TR_TraceRayFilterEx(vPos, vAng, 1174421507, RayType:1, TraceFilter, client);
	if (TR_DidHit(trace))
	{
		TR_GetEndPosition(vPos, trace);
		TR_GetPlaneNormal(trace, vAng);
		CloseHandle(trace);
		GetVectorAngles(vAng, vAng);
		decl Float:vDir[3];
		new var1;
		if (type == 1 || type == 3 || type == 4 || type == 8 || type == 5 || type == 6 || type == 7)
		{
			new var6 = vAng;
			var6[0] = var6[0] + 90.0;
			vPos[2] += 0.2;
		}
		else
		{
			if (type == 2)
			{
				new var7 = vAng;
				var7[0] = var7[0] + 90.0;
			}
			if (type == 13)
			{
				new var8 = vAng;
				var8[0] = var8[0] - 0.0;
				vAng[1] -= 90.0;
				vAng[1] -= 180.0;
				vPos[2] += 0.0;
			}
			if (type == 12)
			{
				new var9 = vAng;
				var9[0] = var9[0] + 90.0;
			}
			if (type == 10)
			{
				new var10 = vAng;
				var10[0] = var10[0] + 90.0;
			}
			if (type == 9)
			{
				new var11 = vAng;
				var11[0] = var11[0] + 90.0;
			}
			if (type == 11)
			{
				new var12 = vAng;
				var12[0] = var12[0] + 180.0;
				GetAngleVectors(vAng, vDir, NULL_VECTOR, NULL_VECTOR);
				new var13 = vPos;
				var13[0] = var13[0] + vDir[0] * 0.0;
				vPos[1] += vDir[1] * 0.0;
				vPos[2] += vDir[2] * 8.0;
			}
			if (type == 14)
			{
				new var14 = vAng;
				var14[0] = var14[0] + 90.0;
			}
			if (type == 4)
			{
				new var15 = vAng;
				var15[0] = var15[0] + 90.0;
			}
			if (type == 15)
			{
				new var16 = vAng;
				var16[0] = var16[0] + 90.0;
			}
			if (type == 16)
			{
				new var17 = vAng;
				var17[0] = var17[0] + 90.0;
			}
			if (type == 17)
			{
				new var18 = vAng;
				var18[0] = var18[0] + 90.0;
			}
			if (type == 24)
			{
				new var19 = vAng;
				var19[0] = var19[0] + 90.0;
			}
			if (type == 26)
			{
				new var20 = vAng;
				var20[0] = var20[0] + 90.0;
			}
			if (type == 27)
			{
				new var21 = vAng;
				var21[0] = var21[0] + 90.0;
			}
			if (type == 29)
			{
				new var22 = vAng;
				var22[0] = var22[0] + 90.0;
				vAng[1] -= 180.0;
			}
			if (type == 30)
			{
				new var23 = vAng;
				var23[0] = var23[0] + 90.0;
			}
			if (type == 35)
			{
				new var24 = vAng;
				var24[0] = var24[0] + 90.0;
				vAng[1] -= 180.0;
			}
			if (type == 18)
			{
				new var25 = vAng;
				var25[0] = var25[0] + 90.0;
			}
			if (type == 20)
			{
				new var26 = vAng;
				var26[0] = var26[0] + 90.0;
			}
			new var2;
			if (type == 21 || type == 22)
			{
				new var27 = vAng;
				var27[0] = var27[0] + 90.0;
			}
			if (type == 19)
			{
				new var28 = vAng;
				var28[0] = var28[0] + 90.0;
			}
			if (type == 23)
			{
				new var29 = vAng;
				var29[0] = var29[0] + 90.0;
			}
			if (type == 25)
			{
				new var30 = vAng;
				var30[0] = var30[0] + 90.0;
			}
			if (type == 28)
			{
				new var31 = vAng;
				var31[0] = var31[0] + 90.0;
			}
			if (type == 31)
			{
				new var32 = vAng;
				var32[0] = var32[0] + 90.0;
			}
			new var3;
			if (type == 32 || type == 33 || type == 34)
			{
				new var33 = vAng;
				var33[0] = var33[0] + 90.0;
			}
			if (type >= 36)
			{
				new var34 = vAng;
				var34[0] = var34[0] + 90.0;
			}
		}
		new Float:glow = 0.3;
		new halo = 100;
		new beam = 100;
		new length;
		new width;
		new speed;
		if (type == 14)
		{
			length = 0;
			width = 0;
			speed = 0;
		}
		else
		{
			if (type == 13)
			{
				length = 0;
				width = 0;
				speed = 0;
			}
			if (type == 4)
			{
				glow = 0.2;
				halo = 0;
				length = 0;
				width = 0;
			}
			new var4;
			if (type == 5 || type == 6 || type == 7)
			{
				glow = 0.0;
				halo = 0;
				beam = 0;
				length = 0;
				width = 0;
			}
			if (type == 2)
			{
				halo = 0;
				length = 0;
				width = 0;
			}
			if (type == 29)
			{
				glow = 0.2;
				halo = 0;
				length = 0;
				width = 0;
			}
			new var5;
			if (type == 32 || type == 33 || type == 34)
			{
				if (type == 32)
				{
					width = 0;
				}
				else
				{
					if (type == 33)
					{
						width = 0;
					}
					if (type == 34)
					{
						width = 0;
					}
				}
				glow = 0.0;
				halo = 0;
				beam = 0;
				length = 0;
			}
		}
		new index = SpawnLamp(vPos, vAng, color, type, cfgindex, g_fCvarBright, glow, halo, beam, length, width, speed, g_iCvarBreak);
		return index;
	}
	CloseHandle(trace);
	return -1;
}

public bool:TraceFilter(entity, contentsMask, any:client)
{
	if (client == entity)
	{
		return false;
	}
	return true;
}

ShowMenuBrightness(client)
{
	DisplayMenu(g_hMenuBrightness, client, 0);
	return 0;
}

public BrightnessMenuHandler(Handle:menu, MenuAction:action, client, index)
{
	if (action == MenuAction:8)
	{
		if (index == -6)
		{
			ShowMenuMain(client);
		}
	}
	else
	{
		if (action == MenuAction:4)
		{
			if (index)
			{
				if (index == 1)
				{
					SetBrightness(client, 100);
				}
				if (index == 2)
				{
					SetBrightness(client, 200);
				}
				if (index == 3)
				{
					SetBrightness(client, 250);
				}
				if (index == 4)
				{
					SetBrightness(client, 300);
				}
				if (index == 5)
				{
					SetBrightness(client, 500);
				}
				if (index == 6)
				{
					SaveLampData(client, 0, 1, -1.0, -1, -1, -1, -1, -1, -1);
				}
			}
			else
			{
				SetBrightness(client, 50);
			}
			ShowMenuBrightness(client);
		}
	}
	return 0;
}

SetBrightness(client, brightness)
{
	new entity;
	new index = -1;
	entity = GetClientAimTarget(client, false);
	if (entity == -1)
	{
		return 0;
	}
	entity = EntIndexToEntRef(entity);
	new i;
	while (i < 32)
	{
		if (entity == g_iEntities[i][0])
		{
			index = i;
			if (index == -1)
			{
				return 0;
			}
			entity = g_iEntities[index][1];
			if (IsValidEntRef(entity))
			{
				SetVariantEntity(entity);
				SetVariantInt(brightness);
				AcceptEntityInput(entity, "distance", -1, -1, 0);
			}
			return 0;
		}
		i++;
	}
	if (index == -1)
	{
		return 0;
	}
	entity = g_iEntities[index][1];
	if (IsValidEntRef(entity))
	{
		SetVariantEntity(entity);
		SetVariantInt(brightness);
		AcceptEntityInput(entity, "distance", -1, -1, 0);
	}
	return 0;
}

ShowMenuColor(client)
{
	DisplayMenu(g_hMenuColor, client, 0);
	return 0;
}

public ColorMenuHandler(Handle:menu, MenuAction:action, client, index)
{
	if (action == MenuAction:8)
	{
		if (index == -6)
		{
			ShowMenuMain(client);
		}
	}
	else
	{
		if (action == MenuAction:4)
		{
			if (index)
			{
				if (index == 1)
				{
					SetLampColor(client, "0", "255", "0");
				}
				if (index == 2)
				{
					SetLampColor(client, "0", "0", "255");
				}
				if (index == 3)
				{
					SetLampColor(client, "255", "0", "255");
				}
				if (index == 4)
				{
					SetLampColor(client, "255", "150", "0");
				}
				if (index == 5)
				{
					SetLampColor(client, "255", "255", "255");
				}
				if (index == 6)
				{
					SaveLampData(client, 1, 0, -1.0, -1, -1, -1, -1, -1, -1);
				}
			}
			else
			{
				SetLampColor(client, "255", "0", "0");
			}
			ShowMenuColor(client);
		}
	}
	return 0;
}

ShowMenuAng(client)
{
	DisplayMenu(g_hMenuAng, client, 0);
	return 0;
}

public AngMenuHandler(Handle:menu, MenuAction:action, client, index)
{
	if (action == MenuAction:8)
	{
		if (index == -6)
		{
			ShowMenuMain(client);
		}
	}
	else
	{
		if (action == MenuAction:4)
		{
			if (index == 6)
			{
				SaveLampData(client, 0, 0, -1.0, -1, -1, -1, -1, -1, -1);
			}
			else
			{
				SetAngle(client, index);
			}
			ShowMenuAng(client);
		}
	}
	return 0;
}

SetAngle(client, index)
{
	new aim = GetClientAimTarget(client, false);
	if (aim != -1)
	{
		new Float:vAng[3] = 0.0;
		new entity;
		aim = EntIndexToEntRef(aim);
		new i;
		while (i < 32)
		{
			entity = g_iEntities[i][0];
			if (aim == entity)
			{
				if (g_iEntities[i][7] == 13)
				{
					entity = g_iEntities[i][2];
				}
				GetEntPropVector(entity, PropType:0, "m_angRotation", vAng, 0);
				if (index)
				{
					if (index == 1)
					{
						vAng[1] += 5.0;
					}
					if (index == 2)
					{
						vAng[2] += 5.0;
					}
					if (index == 3)
					{
						vAng[0] = vAng[0] - 5.0;
					}
					if (index == 4)
					{
						vAng[1] -= 5.0;
					}
					if (index == 5)
					{
						vAng[2] -= 5.0;
					}
				}
				else
				{
					vAng[0] = vAng[0] + 5.0;
				}
				TeleportEntity(entity, NULL_VECTOR, vAng, NULL_VECTOR);
				PrintToChat(client, "%sNuevo Angulo: %f %f %f", "\x05P+ \x01|", vAng, vAng[1], vAng[2]);
			}
			i++;
		}
	}
	return 0;
}

ShowMenuPos(client)
{
	DisplayMenu(g_hMenuPos, client, 0);
	return 0;
}

public PosMenuHandler(Handle:menu, MenuAction:action, client, index)
{
	if (action == MenuAction:8)
	{
		if (index == -6)
		{
			ShowMenuMain(client);
		}
	}
	else
	{
		if (action == MenuAction:4)
		{
			if (index == 6)
			{
				SaveLampData(client, 0, 0, -1.0, -1, -1, -1, -1, -1, -1);
			}
			else
			{
				SetOrigin(client, index);
			}
			ShowMenuPos(client);
		}
	}
	return 0;
}

SetOrigin(client, index)
{
	new aim = GetClientAimTarget(client, false);
	if (aim != -1)
	{
		new Float:vPos[3] = 0.0;
		new entity;
		aim = EntIndexToEntRef(aim);
		new i;
		while (i < 32)
		{
			entity = g_iEntities[i][0];
			if (aim == entity)
			{
				if (g_iEntities[i][7] == 13)
				{
					entity = g_iEntities[i][2];
				}
				GetEntPropVector(entity, PropType:0, "m_vecOrigin", vPos, 0);
				if (index)
				{
					if (index == 1)
					{
						vPos[1] += 0.5;
					}
					if (index == 2)
					{
						vPos[2] += 0.5;
					}
					if (index == 3)
					{
						vPos[0] = vPos[0] - 0.5;
					}
					if (index == 4)
					{
						vPos[1] -= 0.5;
					}
					if (index == 5)
					{
						vPos[2] -= 0.5;
					}
				}
				else
				{
					vPos[0] = vPos[0] + 0.5;
				}
				TeleportEntity(entity, vPos, NULL_VECTOR, NULL_VECTOR);
				PrintToChat(client, "%sNuevo Origen: %f %f %f", "\x05P+ \x01|", vPos, vPos[1], vPos[2]);
			}
			i++;
		}
	}
	return 0;
}

public Action:CmdLamp(client, args)
{
	if (!g_bCvarAllow)
	{
		ReplyToCommand(client, "[P+] Plugin turned off.");
		return Action:3;
	}
	if (!client)
	{
		ReplyToCommand(client, "[P+] Commands may only be used in-game on a dedicated server..");
		return Action:3;
	}
	ShowMenuMain(client);
	return Action:3;
}

public Action:CmdLampDelete(client, args)
{
	if (!g_bCvarAllow)
	{
		ReplyToCommand(client, "[P+] Plugin turned off.");
		return Action:3;
	}
	if (!client)
	{
		ReplyToCommand(client, "[P+] Commands may only be used in-game on a dedicated server..");
		return Action:3;
	}
	new entity;
	new index = -1;
	entity = GetClientAimTarget(client, false);
	if (entity == -1)
	{
		return Action:3;
	}
	entity = EntIndexToEntRef(entity);
	new cfgindex;
	new i;
	while (i < 32)
	{
		if (entity == g_iEntities[i][0])
		{
			index = i;
			if (index == -1)
			{
				return Action:3;
			}
			cfgindex = g_iEntities[index][8];
			if (cfgindex)
			{
				new i = index + 1;
				while (i < 32)
				{
					if (g_iEntities[i][8])
					{
						g_iEntities[i][8]--;
					}
					i++;
				}
				DeleteLamp(index, true);
				decl String:sPath[256];
				BuildPath(PathType:0, sPath, 256, "%s", "data/PiromaX_Objetos.cfg");
				if (!FileExists(sPath, false))
				{
					return Action:3;
				}
				new Handle:hFile = CreateKeyValues("Objetos1", "", "");
				if (!FileToKeyValues(hFile, sPath))
				{
					CloseHandle(hFile);
					return Action:3;
				}
				decl String:sMap[64];
				GetCurrentMap(sMap, 64);
				if (!KvJumpToKey(hFile, sMap, false))
				{
					CloseHandle(hFile);
					return Action:3;
				}
				new iCount = KvGetNum(hFile, "num", 0);
				if (iCount)
				{
					new bool:bMove;
					decl String:sTemp[16];
					new i = cfgindex;
					while (i <= iCount)
					{
						IntToString(i, sTemp, 16);
						if (KvJumpToKey(hFile, sTemp, false))
						{
							if (!bMove)
							{
								bMove = true;
								KvDeleteThis(hFile);
							}
							IntToString(i + -1, sTemp, 16);
							KvSetSectionName(hFile, sTemp);
						}
						KvRewind(hFile);
						KvJumpToKey(hFile, sMap, false);
						i++;
					}
					iCount--;
					KvSetNum(hFile, "num", iCount);
					KvRewind(hFile);
					KeyValuesToFile(hFile, sPath);
					CloseHandle(hFile);
					PrintToChat(client, "%s(\x05%d/%d\x01) - Objeto Removido del Config.", "\x05P+ \x01|", iCount, 32);
					return Action:3;
				}
				CloseHandle(hFile);
				return Action:3;
			}
			DeleteLamp(index, true);
			return Action:3;
		}
		i++;
	}
	if (index == -1)
	{
		return Action:3;
	}
	cfgindex = g_iEntities[index][8];
	if (cfgindex)
	{
		new i = index + 1;
		while (i < 32)
		{
			if (g_iEntities[i][8])
			{
				g_iEntities[i][8]--;
			}
			i++;
		}
		DeleteLamp(index, true);
		decl String:sPath[256];
		BuildPath(PathType:0, sPath, 256, "%s", "data/PiromaX_Objetos.cfg");
		if (!FileExists(sPath, false))
		{
			return Action:3;
		}
		new Handle:hFile = CreateKeyValues("Objetos1", "", "");
		if (!FileToKeyValues(hFile, sPath))
		{
			CloseHandle(hFile);
			return Action:3;
		}
		decl String:sMap[64];
		GetCurrentMap(sMap, 64);
		if (!KvJumpToKey(hFile, sMap, false))
		{
			CloseHandle(hFile);
			return Action:3;
		}
		new iCount = KvGetNum(hFile, "num", 0);
		if (iCount)
		{
			new bool:bMove;
			decl String:sTemp[16];
			new i = cfgindex;
			while (i <= iCount)
			{
				IntToString(i, sTemp, 16);
				if (KvJumpToKey(hFile, sTemp, false))
				{
					if (!bMove)
					{
						bMove = true;
						KvDeleteThis(hFile);
					}
					IntToString(i + -1, sTemp, 16);
					KvSetSectionName(hFile, sTemp);
				}
				KvRewind(hFile);
				KvJumpToKey(hFile, sMap, false);
				i++;
			}
			iCount--;
			KvSetNum(hFile, "num", iCount);
			KvRewind(hFile);
			KeyValuesToFile(hFile, sPath);
			CloseHandle(hFile);
			PrintToChat(client, "%s(\x05%d/%d\x01) - Objeto Removido del Config.", "\x05P+ \x01|", iCount, 32);
			return Action:3;
		}
		CloseHandle(hFile);
		return Action:3;
	}
	DeleteLamp(index, true);
	return Action:3;
}

public Action:CmdLampRefresh(client, args)
{
	g_bLoaded = false;
	ResetPlugin();
	LoadLamps();
	return Action:3;
}

public Action:CmdLampClear(client, args)
{
	ResetPlugin();
	PrintToChat(client, "%sTodos los objetos Borrados temporalmente del mapa.", "\x05P+ \x01|");
	return Action:3;
}

public Action:CmdLampWipe(client, args)
{
	WipeLamps(client);
	return Action:3;
}

public Action:CmdLampSet(client, args)
{
	if (!g_bCvarAllow)
	{
		ReplyToCommand(client, "[P+] Plugin turned off.");
		return Action:3;
	}
	if (!client)
	{
		ReplyToCommand(client, "[P+] Commands may only be used in-game on a dedicated server..");
		return Action:3;
	}
	if (args)
	{
		if (args == 2)
		{
			decl String:sTemp[16];
			GetCmdArg(1, sTemp, 16);
			if (strcmp(sTemp, "bright", true))
			{
				if (strcmp(sTemp, "glow", true))
				{
					if (strcmp(sTemp, "beam", true))
					{
						if (strcmp(sTemp, "length", true))
						{
							if (strcmp(sTemp, "width", true))
							{
								if (strcmp(sTemp, "speed", true))
								{
									if (strcmp(sTemp, "break", true))
									{
										if (!(strcmp(sTemp, "halo", true)))
										{
											GetCmdArg(2, sTemp, 16);
											SaveLampData(client, 0, 0, -1.0, -1, -1, -1, -1, -1, StringToInt(sTemp, 10));
										}
									}
									GetCmdArg(2, sTemp, 16);
									SaveLampData(client, 0, 0, -1.0, -1, -1, -1, -1, StringToInt(sTemp, 10), -1);
								}
								GetCmdArg(2, sTemp, 16);
								SaveLampData(client, 0, 0, -1.0, -1, -1, -1, StringToInt(sTemp, 10), -1, -1);
							}
							GetCmdArg(2, sTemp, 16);
							SaveLampData(client, 0, 0, -1.0, -1, -1, StringToInt(sTemp, 10), -1, -1, -1);
						}
						GetCmdArg(2, sTemp, 16);
						SaveLampData(client, 0, 0, -1.0, -1, StringToInt(sTemp, 10), -1, -1, -1, -1);
					}
					GetCmdArg(2, sTemp, 16);
					SaveLampData(client, 0, 0, -1.0, StringToInt(sTemp, 10), -1, -1, -1, -1, -1);
				}
				GetCmdArg(2, sTemp, 16);
				SaveLampData(client, 0, 0, StringToFloat(sTemp), -1, -1, -1, -1, -1, -1);
			}
			else
			{
				GetCmdArg(2, sTemp, 16);
				SaveLampData(client, 0, StringToInt(sTemp, 10), -1.0, -1, -1, -1, -1, -1, -1);
			}
			return Action:3;
		}
		if (args == 3)
		{
			decl String:sRed[4];
			decl String:sGreen[4];
			decl String:sBlue[4];
			GetCmdArg(1, sRed, 4);
			GetCmdArg(2, sGreen, 4);
			GetCmdArg(3, sBlue, 4);
			SetLampColor(client, sRed, sGreen, sBlue);
			SaveLampData(client, 1, 0, -1.0, -1, -1, -1, -1, -1, -1);
		}
		return Action:3;
	}
	SaveLampData(client, 1, 1, -1.0, -1, -1, -1, -1, -1, -1);
	return Action:3;
}

SetLampColor(client, String:sRed[4], String:sGreen[4], String:sBlue[4])
{
	new entity;
	new index = -1;
	entity = GetClientAimTarget(client, false);
	if (entity == -1)
	{
		return 0;
	}
	entity = EntIndexToEntRef(entity);
	new i;
	while (i < 32)
	{
		if (entity == g_iEntities[i][0])
		{
			index = i;
			if (index == -1)
			{
				return 0;
			}
			entity = g_iEntities[index][1];
			if (IsValidEntRef(entity))
			{
				new color = StringToInt(sRed, 10);
				color = StringToInt(sGreen, 10) * 256 + color;
				color = StringToInt(sBlue, 10) * 65536 + color;
				SetEntProp(entity, PropType:0, "m_clrRender", color, 4, 0);
				PrintToChat(client, "%sColor De objeto Cambiado a '\x05%s %s %s\x01'.", "\x05P+ \x01|", sRed, sGreen, sBlue);
			}
			return 0;
		}
		i++;
	}
	if (index == -1)
	{
		return 0;
	}
	entity = g_iEntities[index][1];
	if (IsValidEntRef(entity))
	{
		new color = StringToInt(sRed, 10);
		color = StringToInt(sGreen, 10) * 256 + color;
		color = StringToInt(sBlue, 10) * 65536 + color;
		SetEntProp(entity, PropType:0, "m_clrRender", color, 4, 0);
		PrintToChat(client, "%sColor De objeto Cambiado a '\x05%s %s %s\x01'.", "\x05P+ \x01|", sRed, sGreen, sBlue);
	}
	return 0;
}

SaveLampData(client, color, brightness, Float:glow, beam, length, width, speed, breakable, halo)
{
	new entity;
	new index = -1;
	entity = GetClientAimTarget(client, false);
	if (entity == -1)
	{
		return 0;
	}
	entity = EntIndexToEntRef(entity);
	new i;
	while (i < 32)
	{
		if (entity == g_iEntities[i][0])
		{
			index = i;
			if (index == -1)
			{
				return 0;
			}
			new cfgindex = g_iEntities[index][8];
			if (!cfgindex)
			{
				decl Float:vPos[3];
				decl Float:vAng[3];
				decl String:sColor[12];
				new type = g_iEntities[index][7];
				if (type == 13)
				{
					entity = g_iEntities[index][2];
				}
				GetEntPropVector(entity, PropType:0, "m_vecOrigin", vPos, 0);
				GetEntPropVector(entity, PropType:0, "m_angRotation", vAng, 0);
				entity = g_iEntities[index][1];
				color = GetEntProp(entity, PropType:0, "m_clrRender", 4, 0);
				Format(sColor, 12, "%d %d %d", color & 255, color & 65280 / 256, color / 65536);
				cfgindex = SaveLampNew(client, vPos, vAng, type, sColor);
				g_iEntities[index][8] = cfgindex;
				if (cfgindex)
				{
					PrintToChat(client, "%sObjeto temporal ha sido guardado en el config", "\x05P+ \x01|");
				}
				PrintToChat(client, "%sError al guardar objeto que es temporal.", "\x05P+ \x01|");
				return 0;
			}
			decl String:sPath[256];
			BuildPath(PathType:0, sPath, 256, "%s", "data/PiromaX_Objetos.cfg");
			if (!FileExists(sPath, false))
			{
				PrintToChat(client, "%sError: No se encuentra el config (\x05%s\x01).", "\x05P+ \x01|", sPath);
				return 0;
			}
			new Handle:hFile = CreateKeyValues("Objetos1", "", "");
			if (!FileToKeyValues(hFile, sPath))
			{
				PrintToChat(client, "%sError: No se puede leer el config (\x05%s\x01).", "\x05P+ \x01|", sPath);
				CloseHandle(hFile);
				return 0;
			}
			decl String:sTemp[64];
			decl String:sMap[64];
			GetCurrentMap(sMap, 64);
			if (!KvJumpToKey(hFile, sMap, false))
			{
				PrintToChat(client, "%sError: El mapa actual no se encuentra en el config.", "\x05P+ \x01|");
				CloseHandle(hFile);
				return 0;
			}
			KvJumpToKey(hFile, sMap, false);
			IntToString(cfgindex, sTemp, 64);
			if (KvJumpToKey(hFile, sTemp, false))
			{
				new var1;
				if (-1.0 != glow || beam == -1 || length == -1 || width == -1 || speed == -1 || breakable == -1 || halo == -1)
				{
					if (-1.0 != glow)
					{
						KvSetFloat(hFile, "glow", glow);
						PrintToChat(client, "%sSaved \x03glow\x01 to the config.", "\x05P+ \x01|");
					}
					else
					{
						if (beam != -1)
						{
							KvSetNum(hFile, "beam", beam);
							PrintToChat(client, "%sSaved \x03beam\x01 to the config.", "\x05P+ \x01|");
						}
						if (length != -1)
						{
							KvSetNum(hFile, "length", length);
							PrintToChat(client, "%sSaved \x03length\x01 to the config.", "\x05P+ \x01|");
						}
						if (width != -1)
						{
							KvSetNum(hFile, "width", width);
							PrintToChat(client, "%sSaved \x03width\x01 to the config.", "\x05P+ \x01|");
						}
						if (speed != -1)
						{
							KvSetNum(hFile, "speed", speed);
							PrintToChat(client, "%sSaved \x03speed\x01 to the config.", "\x05P+ \x01|");
						}
						if (halo != -1)
						{
							KvSetNum(hFile, "halo", halo);
							PrintToChat(client, "%sSaved \x03halo\x01 to the config.", "\x05P+ \x01|");
						}
						if (breakable != -1)
						{
							KvSetNum(hFile, "halo", breakable);
							if (breakable)
							{
								PrintToChat(client, "%sGuardado como \x03breakable\x01.", "\x05P+ \x01|");
							}
							PrintToChat(client, "%sGuardado como NO \x03breakable\x01.", "\x05P+ \x01|");
						}
					}
					KvRewind(hFile);
					KeyValuesToFile(hFile, sPath);
					DeleteLamp(index, true);
					SpawnData(cfgindex, hFile, sMap, -1, -1);
					g_iEntities[index][8] = cfgindex;
					CloseHandle(hFile);
					return 0;
				}
				new var2;
				if ((brightness && color) || (brightness == 1 && color == 1))
				{
					decl Float:vPos[3];
					decl Float:vAng[3];
					if (g_iEntities[index][7] == 13)
					{
						entity = g_iEntities[index][2];
					}
					GetEntPropVector(entity, PropType:0, "m_vecOrigin", vPos, 0);
					GetEntPropVector(entity, PropType:0, "m_angRotation", vAng, 0);
					KvSetVector(hFile, "angle", vAng);
					KvSetVector(hFile, "origin", vPos);
				}
				if (brightness == 1)
				{
					new type = g_iEntities[index][7];
					new var5;
					if (type == 7 || type == 8 || type == 9)
					{
						PrintToChat(client, "%sSin luz dinamica para configurar el brillo");
						return 0;
					}
					entity = g_iEntities[index][1];
					if (IsValidEntRef(entity))
					{
						new Float:radius = GetEntPropFloat(entity, PropType:0, "m_Radius", 0);
						if (150.0 != radius)
						{
							KvSetFloat(hFile, "brightness", radius);
						}
					}
				}
				if (color == 1)
				{
					entity = g_iEntities[index][1];
					if (IsValidEntRef(entity))
					{
						color = GetEntProp(entity, PropType:0, "m_clrRender", 4, 0);
						decl String:sColor[12];
						Format(sColor, 12, "%d %d %d", color & 255, color & 65280 / 256, color / 65536);
						KvSetString(hFile, "Ganko", sColor);
					}
				}
				KvRewind(hFile);
				KeyValuesToFile(hFile, sPath);
				new var6;
				if (color && brightness)
				{
					PrintToChat(client, "%sGuardado los angulos y origen en la config.", "\x05P+ \x01|");
				}
				new var7;
				if (brightness == 1 && color)
				{
					PrintToChat(client, "%sGuardado los angulos y origen en la config.", "\x05P+ \x01|");
				}
				new var8;
				if (brightness == 1 && color)
				{
					PrintToChat(client, "%sToda Configuracion guardada en la config.", "\x05P+ \x01|");
				}
				PrintToChat(client, "%sGuardados los angulos y origen en la config.", "\x05P+ \x01|");
			}
			CloseHandle(hFile);
			return 0;
		}
		i++;
	}
	if (index == -1)
	{
		return 0;
	}
	new cfgindex = g_iEntities[index][8];
	if (!cfgindex)
	{
		decl Float:vPos[3];
		decl Float:vAng[3];
		decl String:sColor[12];
		new type = g_iEntities[index][7];
		if (type == 13)
		{
			entity = g_iEntities[index][2];
		}
		GetEntPropVector(entity, PropType:0, "m_vecOrigin", vPos, 0);
		GetEntPropVector(entity, PropType:0, "m_angRotation", vAng, 0);
		entity = g_iEntities[index][1];
		color = GetEntProp(entity, PropType:0, "m_clrRender", 4, 0);
		Format(sColor, 12, "%d %d %d", color & 255, color & 65280 / 256, color / 65536);
		cfgindex = SaveLampNew(client, vPos, vAng, type, sColor);
		g_iEntities[index][8] = cfgindex;
		if (cfgindex)
		{
			PrintToChat(client, "%sObjeto temporal ha sido guardado en el config", "\x05P+ \x01|");
		}
		PrintToChat(client, "%sError al guardar objeto que es temporal.", "\x05P+ \x01|");
		return 0;
	}
	decl String:sPath[256];
	BuildPath(PathType:0, sPath, 256, "%s", "data/PiromaX_Objetos.cfg");
	if (!FileExists(sPath, false))
	{
		PrintToChat(client, "%sError: No se encuentra el config (\x05%s\x01).", "\x05P+ \x01|", sPath);
		return 0;
	}
	new Handle:hFile = CreateKeyValues("Objetos1", "", "");
	if (!FileToKeyValues(hFile, sPath))
	{
		PrintToChat(client, "%sError: No se puede leer el config (\x05%s\x01).", "\x05P+ \x01|", sPath);
		CloseHandle(hFile);
		return 0;
	}
	decl String:sTemp[64];
	decl String:sMap[64];
	GetCurrentMap(sMap, 64);
	if (!KvJumpToKey(hFile, sMap, false))
	{
		PrintToChat(client, "%sError: El mapa actual no se encuentra en el config.", "\x05P+ \x01|");
		CloseHandle(hFile);
		return 0;
	}
	KvJumpToKey(hFile, sMap, false);
	IntToString(cfgindex, sTemp, 64);
	if (KvJumpToKey(hFile, sTemp, false))
	{
		new var1;
		if (-1.0 != glow || beam == -1 || length == -1 || width == -1 || speed == -1 || breakable == -1 || halo == -1)
		{
			if (-1.0 != glow)
			{
				KvSetFloat(hFile, "glow", glow);
				PrintToChat(client, "%sSaved \x03glow\x01 to the config.", "\x05P+ \x01|");
			}
			else
			{
				if (beam != -1)
				{
					KvSetNum(hFile, "beam", beam);
					PrintToChat(client, "%sSaved \x03beam\x01 to the config.", "\x05P+ \x01|");
				}
				if (length != -1)
				{
					KvSetNum(hFile, "length", length);
					PrintToChat(client, "%sSaved \x03length\x01 to the config.", "\x05P+ \x01|");
				}
				if (width != -1)
				{
					KvSetNum(hFile, "width", width);
					PrintToChat(client, "%sSaved \x03width\x01 to the config.", "\x05P+ \x01|");
				}
				if (speed != -1)
				{
					KvSetNum(hFile, "speed", speed);
					PrintToChat(client, "%sSaved \x03speed\x01 to the config.", "\x05P+ \x01|");
				}
				if (halo != -1)
				{
					KvSetNum(hFile, "halo", halo);
					PrintToChat(client, "%sSaved \x03halo\x01 to the config.", "\x05P+ \x01|");
				}
				if (breakable != -1)
				{
					KvSetNum(hFile, "halo", breakable);
					if (breakable)
					{
						PrintToChat(client, "%sGuardado como \x03breakable\x01.", "\x05P+ \x01|");
					}
					PrintToChat(client, "%sGuardado como NO \x03breakable\x01.", "\x05P+ \x01|");
				}
			}
			KvRewind(hFile);
			KeyValuesToFile(hFile, sPath);
			DeleteLamp(index, true);
			SpawnData(cfgindex, hFile, sMap, -1, -1);
			g_iEntities[index][8] = cfgindex;
			CloseHandle(hFile);
			return 0;
		}
		new var2;
		if ((brightness && color) || (brightness == 1 && color == 1))
		{
			decl Float:vPos[3];
			decl Float:vAng[3];
			if (g_iEntities[index][7] == 13)
			{
				entity = g_iEntities[index][2];
			}
			GetEntPropVector(entity, PropType:0, "m_vecOrigin", vPos, 0);
			GetEntPropVector(entity, PropType:0, "m_angRotation", vAng, 0);
			KvSetVector(hFile, "angle", vAng);
			KvSetVector(hFile, "origin", vPos);
		}
		if (brightness == 1)
		{
			new type = g_iEntities[index][7];
			new var5;
			if (type == 7 || type == 8 || type == 9)
			{
				PrintToChat(client, "%sSin luz dinamica para configurar el brillo");
				return 0;
			}
			entity = g_iEntities[index][1];
			if (IsValidEntRef(entity))
			{
				new Float:radius = GetEntPropFloat(entity, PropType:0, "m_Radius", 0);
				if (150.0 != radius)
				{
					KvSetFloat(hFile, "brightness", radius);
				}
			}
		}
		if (color == 1)
		{
			entity = g_iEntities[index][1];
			if (IsValidEntRef(entity))
			{
				color = GetEntProp(entity, PropType:0, "m_clrRender", 4, 0);
				decl String:sColor[12];
				Format(sColor, 12, "%d %d %d", color & 255, color & 65280 / 256, color / 65536);
				KvSetString(hFile, "Ganko", sColor);
			}
		}
		KvRewind(hFile);
		KeyValuesToFile(hFile, sPath);
		new var6;
		if (color && brightness)
		{
			PrintToChat(client, "%sGuardado los angulos y origen en la config.", "\x05P+ \x01|");
		}
		new var7;
		if (brightness == 1 && color)
		{
			PrintToChat(client, "%sGuardado los angulos y origen en la config.", "\x05P+ \x01|");
		}
		new var8;
		if (brightness == 1 && color)
		{
			PrintToChat(client, "%sToda Configuracion guardada en la config.", "\x05P+ \x01|");
		}
		PrintToChat(client, "%sGuardados los angulos y origen en la config.", "\x05P+ \x01|");
	}
	CloseHandle(hFile);
	return 0;
}

ResetPlugin()
{
	new i;
	while (i < 32)
	{
		DeleteLamp(i, true);
		i++;
	}
	return 0;
}

DeleteLamp(index, bool:all)
{
	new entity;
	KillEntity(g_iEntities[index][1]);
	g_iEntities[index][1] = 0;
	KillEntity(g_iEntities[index][2]);
	g_iEntities[index][2] = 0;
	KillEntity(g_iEntities[index][3]);
	g_iEntities[index][3] = 0;
	KillEntity(g_iEntities[index][4]);
	g_iEntities[index][4] = 0;
	KillEntity(g_iEntities[index][5]);
	g_iEntities[index][5] = 0;
	KillEntity(g_iEntities[index][6]);
	g_iEntities[index][6] = 0;
	if (g_iEntities[index][7] == 8)
	{
		entity = g_iEntities[index][0];
		if (IsValidEntRef(entity))
		{
			StopSound(entity, 0, "ambient/ambience/tv_static_loop2.wav");
			UnhookSingleEntityOutput(entity, "OnTakeDamage", OnBreak);
			UnhookSingleEntityOutput(entity, "OnHealthChanged", OnBreak);
		}
	}
	entity = g_iEntities[index][0];
	if (IsValidEntRef(entity))
	{
		AcceptEntityInput(entity, "ClearParent", -1, -1, 0);
		if (all)
		{
			g_iEntities[index][0] = 0;
			UnhookSingleEntityOutput(entity, "OnTakeDamage", OnBreak);
			UnhookSingleEntityOutput(entity, "OnHealthChanged", OnBreak);
			AcceptEntityInput(entity, "Kill", -1, -1, 0);
		}
	}
	return 0;
}

KillEntity(entity)
{
	if (IsValidEntRef(entity))
	{
		AcceptEntityInput(entity, "ClearParent", -1, -1, 0);
		AcceptEntityInput(entity, "LightOff", -1, -1, 0);
		AcceptEntityInput(entity, "TurnOff", -1, -1, 0);
		SetVariantString("OnUser1 !self:Kill::0.5:1");
		AcceptEntityInput(entity, "AddOutput", -1, -1, 0);
		AcceptEntityInput(entity, "FireUser1", -1, -1, 0);
	}
	return 0;
}

bool:IsValidEntRef(entity)
{
	new var1;
	if (entity && EntRefToEntIndex(entity) != -1)
	{
		return true;
	}
	return false;
}

PrecacheParticle(String:ParticleName[])
{
	new particle = CreateEntityByName("info_particle_system", -1);
	DispatchKeyValue(particle, "effect_name", ParticleName);
	DispatchSpawn(particle);
	ActivateEntity(particle);
	AcceptEntityInput(particle, "start", -1, -1, 0);
	SetVariantString("OnUser1 !self:Kill::0.1:1");
	AcceptEntityInput(particle, "AddOutput", -1, -1, 0);
	AcceptEntityInput(particle, "FireUser1", -1, -1, 0);
	return 0;
}
luis enrique is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 05-26-2018 , 21:19   Re: [help]help, rebuild this decompiled add-on and add support for l42 please
Reply With Quote #2

Why not email [email protected] asking for source?
__________________
Neuro Toxin is offline
luis enrique
Member
Join Date: Oct 2017
Location: peru
Old 05-26-2018 , 22:45   Re: [help]help, rebuild this decompiled add-on and add support for l42 please
Reply With Quote #3

Quote:
Originally Posted by Neuro Toxin View Post
Why not email [email protected] asking for source?

I tried but I do not answer why I posted here to see if someone helped me to rebuild and add support for l4d2, since I'm not a programmer ... thanks for answering
luis enrique is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 05-29-2018 , 08:22   Re: [help]help, rebuild this decompiled add-on and add support for l42 please
Reply With Quote #4

This is a blatent rip of my Lamps plugin without credit. Thanks.

I don't see much different from mine other than allowing l4d1, renaming vars and removing my name. So wtf scam is this. Did you pay for it or something?

[L4D2] Lamp (1.3) [05-May-2018]

^^
__________________

Last edited by Silvers; 05-29-2018 at 09:11.
Silvers is offline
luis enrique
Member
Join Date: Oct 2017
Location: peru
Old 05-30-2018 , 15:02   Re: [help]help, rebuild this decompiled add-on and add support for l42 please
Reply With Quote #5

Quote:
Originally Posted by Silvers View Post
This is a blatent rip of my Lamps plugin without credit. Thanks.

I don't see much different from mine other than allowing l4d1, renaming vars and removing my name. So wtf scam is this. Did you pay for it or something?

[L4D2] Lamp (1.3) [05-May-2018]

^^
hi silver lord we go in parts 1. I did not pay for this add-on, I found it on a page and here is the proof
http://fiksiki.3dn.ru/forum/11-218-1
I just unpacked it and put it here to see if someone helped me because I did not program, I apologize if I offended it. sorry for my English

Last edited by luis enrique; 05-30-2018 at 15:05.
luis enrique is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 05-30-2018 , 19:30   Re: [help]help, rebuild this decompiled add-on and add support for l42 please
Reply With Quote #6

Those dirty Russian's
__________________
Neuro Toxin is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 05-30-2018 , 19:39   Re: [help]help, rebuild this decompiled add-on and add support for l42 please
Reply With Quote #7

Quote:
Originally Posted by luis enrique View Post
hi silver lord we go in parts 1. I did not pay for this add-on, I found it on a page and here is the proof
http://fiksiki.3dn.ru/forum/11-218-1
I just unpacked it and put it here to see if someone helped me because I did not program, I apologize if I offended it. sorry for my English
No you didn't offend, who converted did, but whatever.

If you need L4D2 version you could just use the official posted one, I dunno what's different other than translations and maybe L4D1 support. L4D1 support would be easy just some models don't exist or something trivial, don't remember why it's L4D2 only.
__________________
Silvers is offline
luis enrique
Member
Join Date: Oct 2017
Location: peru
Old 06-02-2018 , 21:25   Re: [help]help, rebuild this decompiled add-on and add support for l42 please
Reply With Quote #8

Quote:
Originally Posted by Silvers View Post
No you didn't offend, who converted did, but whatever.

If you need L4D2 version you could just use the official posted one, I dunno what's different other than translations and maybe L4D1 support. L4D1 support would be easy just some models don't exist or something trivial, don't remember why it's L4D2 only.

thanks silvers I tried to help you with your plugin but it gave me a lot of errors of brightness and colors but thanks for responds, I am not a programmer T_T
luis enrique is offline
Venom1777
Junior Member
Join Date: Oct 2019
Old 10-09-2019 , 01:34   Re: [help]help, rebuild this decompiled add-on and add support for l42 please
Reply With Quote #9

Quote:
Originally Posted by luis enrique View Post
thanks silvers I tried to help you with your plugin but it gave me a lot of errors of brightness and colors but thanks for responds, I am not a programmer T_T
that plugin strikerblack gave it to several xd, yep it was a modified version, xd, and you broke it down and uploaded it xd
Venom1777 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:22.


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