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

[CS:GO] SetParent Beams


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
zNode
New Member
Join Date: Oct 2015
Old 10-07-2015 , 10:42   [CS:GO] SetParent Beams
Reply With Quote #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.
zNode is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 10-07-2015 , 12:21   Re: [CS:GO] SetParent Beams
Reply With Quote #2

why don't you just use TempEnt?
TE_SetupBeamRingPoint
__________________
8guawong is offline
zNode
New Member
Join Date: Oct 2015
Old 10-07-2015 , 13:06   Re: [CS:GO] SetParent Beams
Reply With Quote #3

Beacuse i want the rings to stay the whole round and move with the player.
zNode is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 10-07-2015 , 13:51   Re: [CS:GO] SetParent Beams
Reply With Quote #4

Kill and recreate it?
Miu is offline
zNode
New Member
Join Date: Oct 2015
Old 10-07-2015 , 14:24   Re: [CS:GO] SetParent Beams
Reply With Quote #5

i did that before. But that's not as smooth as with the code above.
zNode is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 10-08-2015 , 07:11   Re: [CS:GO] SetParent Beams
Reply With Quote #6

__________________
zipcore 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 07:30.


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