New Member
|
10-07-2015
, 10:42
[CS:GO] SetParent Beams
|
#1
|
Hi,
i'm currently working on a plugin that spawns 2 chickens and set them as a parent of a client, and spawns a beam around the client.
The Problem is, that the Beam can't be turned off!
Code:
//CODE BY ZIPCORE!
//Slightly modified
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
new getChickenOne[MAXPLAYERS+1] = -1;
new getChickenTwo[MAXPLAYERS+1] = -1;
new getBeam[MAXPLAYERS+1] = -1;
public void OnPluginStart()
{
RegConsoleCmd("sm_eve", Cmd_Eve);
}
public Action Cmd_Eve(int client, int args)
{
Eve(client);
return Plugin_Handled;
}
Eve(client)
{
float vec[3];
GetClientAbsOrigin(client, vec);
float playerangle[3];
GetClientEyeAngles(client, playerangle);
playerangle[0] = 0.0;
float vec_start[3];
float vec_end[3];
AddInFrontOf(vec, playerangle, 16.0, vec_start);
vec_start[2] += 3;
AddInFrontOf(vec, playerangle, -16.0, vec_end);
vec_end[2] += 3;
char sStart[30];
Format(sStart, 30, "start");
getChickenOne[client] = Eve_Parent(client, vec_start, sStart);
char sEnd[30];
Format(sEnd, 30, "end");
getChickenTwo[client] = Eve_Parent(client, vec_end, sEnd);
getBeam[client] = Eve_Beam(client, sStart, sEnd);
CreateTimer(10.0, removeAllBeams);
}
int Eve_Parent(int client, float vec[3], char sName[30])
{
int iEntity = CreateEntityByName("prop_dynamic");
char fullPath[] = "models/chicken/chicken.mdl";
PrecacheModel(fullPath, true);
SetEntityModel(iEntity, fullPath);
Format(sName, 30, "%s%d", sName, iEntity);
DispatchKeyValue(iEntity, "targetname", sName);
DispatchKeyValue(iEntity, "solid", "0");
DispatchSpawn(iEntity);
ActivateEntity(iEntity);
SetEntityMoveType(iEntity, MOVETYPE_NONE);
SetEntityRenderMode(iEntity, RENDER_NONE);
TeleportEntity(iEntity, vec, NULL_VECTOR, NULL_VECTOR);
ClientParentEntity(client, iEntity);
return iEntity;
}
int Eve_Beam(int client, char sStart[30], char sEnd[30])
{
float vec[3];
GetClientAbsOrigin(client, vec);
int beament = CreateEntityByName("env_beam");
if (IsValidEntity(beament))
{
char beamindex[30];
Format(beamindex, sizeof(beamindex), "Beam%d", beament);
DispatchKeyValue(beament, "targetname", beamindex);
DispatchKeyValue(beament, "LightningStart", sStart);
DispatchKeyValue(beament, "LightningEnd", sEnd);
DispatchKeyValue(beament, "damage", "0");
DispatchKeyValue(beament, "framestart", "0");
DispatchKeyValue(beament, "BoltWidth", "5");
DispatchKeyValue(beament, "renderfx", "0");
DispatchKeyValue(beament, "TouchType", "3");
DispatchKeyValue(beament, "framerate", "0");
DispatchKeyValue(beament, "decalname", "Bigshot");
DispatchKeyValue(beament, "TextureScroll", "35");
DispatchKeyValue(beament, "HDRColorScale", "3.0");
DispatchKeyValue(beament, "texture", "materials/sprites/laserbeam.vmt");
DispatchKeyValue(beament, "life", "0");
DispatchKeyValue(beament, "StrikeTime", "10");
DispatchKeyValue(beament, "spawnflags", "8");
DispatchKeyValue(beament, "NoiseAmplitude", "0");
DispatchKeyValue(beament, "Radius", "120");
DispatchKeyValue(beament, "rendercolor", "0 0 255");
DispatchKeyValue(beament, "renderamt", "255");
DispatchSpawn(beament);
TeleportEntity(beament, vec, NULL_VECTOR, NULL_VECTOR);
CreateTimer(0.5, beam_enable, beament);
}
return beament;
}
stock void ClientParentEntity(client, entity)
{
SetVariantString("!activator");
AcceptEntityInput(entity, "SetParent", client, entity, 0);
SetVariantString("IchLiebeDichPandora");
AcceptEntityInput(entity, "SetParentAttachmentMaintainOffset", entity, entity, 0);
}
public Action beam_enable(Handle timer, any beam)
{
AcceptEntityInput(beam, "TurnOn");
}
public Action removeAllBeams(Handle timer)
{
for (new client = 1; client <= MaxClients; client++)
{
if (getBeam[client] != -1)
{
PrintToChat(client, "Entferne Ring.");
AcceptEntityInput(getBeam[client], "ClearParent");
AcceptEntityInput(getBeam[client], "TurnOff");
}
}
}
stock void AddInFrontOf(float vecOrigin[3], float vecAngle[3], float units, float output[3])
{
float vecAngVectors[3];
vecAngVectors = vecAngle; //Don't change input
GetAngleVectors(vecAngVectors, vecAngVectors, NULL_VECTOR, NULL_VECTOR);
for (int i; i < 3; i++)
output[i] = vecOrigin[i] + (vecAngVectors[i] * units);
}
That was just a test plugin, but it doesn't work either.
Last edited by zNode; 10-07-2015 at 10:44.
|
|