AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
|
05-27-2020
, 13:45
[CSGO] Is posible to spawn an ENT on other ENT ?
|
#1
|
Well all is working by far, the problem is than i can't spawn the same ent on it...
For example the Mine 1 is spawned to the wall, and i want the mine 2 to spawn on the mine 1, but it just let me spawn the mine 2 near the mine 1 and just in walls or floor or anything else which is not the mine 1
PHP Code:
PlantMine(client, Float:activation_delay = 0.0, explode_damage, explode_radius, const health = 0, const color[3] = {255, 255, 255})
{
if (activation_delay > 10.0)
{
activation_delay = 10.0;
}
else if (activation_delay < 0.0)
{
activation_delay = 0.0;
}
new Handle:trace = TraceRay(client);
decl Float:end[3], Float:normal[3], Float:beamend[3];
if (TR_DidHit(trace) && TR_GetEntityIndex(trace) < 1)
{
TR_GetEndPosition(end, trace);
TR_GetPlaneNormal(trace, normal);
CloseHandle(trace);
GetVectorAngles(normal, normal);
TR_TraceRayFilter(end, normal, CONTENTS_SOLID, RayType_Infinite, FilterAll);
TR_GetEndPosition(beamend, INVALID_HANDLE);
new ent = CreateEntityByName("prop_physics_override");
if (ent == -1 || !IsValidEdict(ent))
{
LogError("Could not create entity \"prop_physics_override\"");
return -1;
}
new beament = CreateEntityByName("env_beam");
if (beament == -1 || !IsValidEdict(beament))
{
LogError("Could not create entity \"env_beam\"");
return -1;
}
//CreateTimer(2.0, MakeSolid, EntIndexToEntRef(ent), TIMER_FLAG_NO_MAPCHANGE);
decl String:start[30], String:tmp[200];
Format(start, sizeof(start), "Beam%i", beament);
SetEntityModel(ent, MDL_MINE);
decl String:buffer[16];
IntToString(explode_damage, buffer, sizeof(buffer));
DispatchKeyValue(ent, "ExplodeDamage", buffer);
IntToString(explode_radius, buffer, sizeof(buffer));
DispatchKeyValue(ent, "ExplodeRadius", buffer);
DispatchKeyValue(ent, "spawnflags", "3");
SetEntProp(ent, Prop_Data, "m_nSolidType", 6); //Hacer no solido
SetEntProp(ent, Prop_Data, "m_CollisionGroup", 5); //Hacer no solido
DispatchSpawn(ent);
AcceptEntityInput(ent, "DisableMotion");
SetEntityMoveType(ent, MOVETYPE_NONE);
TeleportEntity(ent, end, normal, NULL_VECTOR);
if (health)
{
SetEntProp(ent, Prop_Data, "m_takedamage", 2);
SetEntProp(ent, Prop_Data, "m_iHealth", health);
}
Format(tmp, sizeof(tmp), "%s,Kill,,0,-1", start);
DispatchKeyValue(ent, "OnBreak", tmp);
EmitSoundToAll(SND_MINEPUT, ent);
// Set keyvalues on the beam.
DispatchKeyValue(beament, "targetname", start);
DispatchKeyValue(beament, "damage", "0");
DispatchKeyValue(beament, "framestart", "0");
DispatchKeyValue(beament, "BoltWidth", "4.0");
DispatchKeyValue(beament, "renderfx", "0");
DispatchKeyValue(beament, "TouchType", "3"); // 0 = none, 1 = player only, 2 = NPC only, 3 = player or NPC, 4 = player, NPC or physprop
DispatchKeyValue(beament, "framerate", "0");
DispatchKeyValue(beament, "decalname", "Bigshot");
DispatchKeyValue(beament, "TextureScroll", "35");
DispatchKeyValue(beament, "HDRColorScale", "1.0");
DispatchKeyValue(beament, "texture", MDL_LASER);
DispatchKeyValue(beament, "life", "0"); // 0 = infinite, beam life time in seconds
DispatchKeyValue(beament, "StrikeTime", "1"); // If beam life time not infinite, this repeat it back
DispatchKeyValue(beament, "LightningStart", start);
DispatchKeyValue(beament, "spawnflags", "0"); // 0 disable, 1 = start on, etc etc. look from hammer editor
DispatchKeyValue(beament, "NoiseAmplitude", "0"); // straight beam = 0, other make noise beam
DispatchKeyValue(beament, "Radius", "256");
DispatchKeyValue(beament, "renderamt", "100");
DispatchKeyValue(beament, "rendercolor", "0 0 0");
AcceptEntityInput(beament, "TurnOff");
SetEntityModel(beament, MDL_LASER);
TeleportEntity(beament, beamend, NULL_VECTOR, NULL_VECTOR); // Teleport the beam
SetEntPropVector(beament, Prop_Data, "m_vecEndPos", end);
SetEntPropFloat(beament, Prop_Data, "m_fWidth", 3.0);
SetEntPropFloat(beament, Prop_Data, "m_fEndWidth", 3.0);
SetEntPropEnt(beament, Prop_Data, "m_hOwnerEntity", client); // Sets the owner of the beam
SetEntPropEnt(ent, Prop_Data, "m_hMoveChild", beament);
SetEntPropEnt(beament, Prop_Data, "m_hEffectEntity", ent);
new Handle:datapack = CreateDataPack();
WritePackCell(datapack, beament);
WritePackCell(datapack, ent);
WritePackCell(datapack, color[0]);
WritePackCell(datapack, color[1]);
WritePackCell(datapack, color[2]);
WritePackString(datapack, start);
CreateTimer(activation_delay, OnActivateLaser, datapack, TIMER_FLAG_NO_MAPCHANGE|TIMER_HNDL_CLOSE);
SDKHook(ent, SDKHook_OnTakeDamage, OnTakeDamage);
return ent;
}
else
CloseHandle(trace);
return -1;
}
__________________
|
|