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

[CS:GO] Add lifetime to sprays/decals


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 01-19-2017 , 13:05   [CS:GO] Add lifetime to sprays/decals
Reply With Quote #1

I am trying to add lifetime to my csgo sprays plugin and I have tried the following:

Create a infodecal
PHP Code:
    new ent CreateEntityByName"infodecal" );  
    
    
DispatchKeyValueent"texture"texture );
    
DispatchKeyValueent"LowPriority""1" ); 
    
TeleportEntityentvecOriginNULL_VECTORNULL_VECTOR ); 
    
DispatchSpawn(ent);
    
ActivateEntityent ); 
The decal works well but when I tried to remove it with "AcceptEntityInput(ent, "Kill");" or "RemoveEdict(ent);" then the decal is not remove and give me log errors that said "Exception reported: Entity 82 (82) is not a CBaseEntity" or "Exception reported: Edict 100 (100) is not a valid edict".

Also I tried that without success
PHP Code:
    new String:buffer[25];
    
Format(buffersizeof(buffer), "!self,Kill,,%0.1f,-1"5.0);
    
DispatchKeyValue(ent"OnUser1"buffer);
    
AcceptEntityInput(ent"FireUser1"); 

I saw that if you put another decal in the same position where a old decal, then the old decal disappear and only appear the new decal, but testing with a very small decal I saw that this only happend when you put 2 decals with similar scale.


Possible solution not tested yet: Maybe I could create a totally invisible decal in the same position that another decal for force to dissapear the old decal?


I tried with CS:GO graffitis temp entities that apparently have lifetime but I can not make it visible at least.

Tried TE used for CS:GO graffitis:
Spoiler

But no idea how to use it with a specific vtf file.


This dont hook when you use T for graffitis:
Spoiler



CS:GO graffitis apparently use "cfe_player_decal" classname but I did not have success to make it visible.


Summary: Suggestions to add lifetime to a decal or force it to dissapear?
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.

Franc1sco is offline
Send a message via MSN to Franc1sco
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 01-19-2017 , 16:07   Re: [CS:GO] Add lifetime to sprays/decals
Reply With Quote #2

Ok I use "env_sprite" now and I can remove the entity when I want.


Testing code:
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>


#define MODELO "sprites/spray_bullseye2"

public OnPluginStart()
{
    
RegConsoleCmd("sm_tests"MakeSpray);
}

public 
OnMapStart()
{
    
char model[124];
    
Format(model124"%s.vmt"MODELO);    
    
PrecacheModel(model);
    
Format(model124"materials/%s.vmt"MODELO);
    
AddFileToDownloadsTable(model);
    
Format(model124"materials/%s.vtf"MODELO);
    
AddFileToDownloadsTable(model);
}

public 
Action:MakeSpray(clientargs)
{    
    
decl Float:fClientEyePosition[3];
    
GetClientEyePosition(clientfClientEyePosition);

    
decl Float:fClientEyeViewPoint[3];
    
GetPlayerEyeViewPoint(clientfClientEyeViewPoint);

    
decl Float:fVector[3];
    
MakeVectorFromPoints(fClientEyeViewPointfClientEyePositionfVector);
    
    
char buffer[124];
    
decl Float:vecAng[3];
    
    
GetCmdArg(1buffer124);
    
vecAng[0]=StringToFloat(buffer);
    
    
GetCmdArg(2buffer124);
     
vecAng[1]=StringToFloat(buffer);
     
     
GetCmdArg(3buffer124);
    
vecAng[2]=StringToFloat(buffer);
    
    
char model[124];
    
Format(model124"%s.vmt"MODELO);    
    
CreateSprite(clientmodelfClientEyeViewPointvecAng0.5"0"10.0);
    return 
Plugin_Handled;
}

stock GetPlayerEyeViewPoint(iClientFloat:fPosition[3])
{
    
decl Float:fAngles[3];
    
GetClientEyeAngles(iClientfAngles);

    
decl Float:fOrigin[3];
    
GetClientEyePosition(iClientfOrigin);

    new 
Handle:hTrace TR_TraceRayFilterEx(fOriginfAnglesMASK_SHOTRayType_InfiniteTraceEntityFilterPlayer);
    if(
TR_DidHit(hTrace))
    {
        
TR_GetEndPosition(fPositionhTrace);
        
CloseHandle(hTrace);
        return 
true;
    }
    
CloseHandle(hTrace);
    return 
false;
}

public 
bool:TraceEntityFilterPlayer(iEntityiContentsMask)
{
    return 
iEntity GetMaxClients();
}

        
/*
 * CREATE SPRITE
 * 
 * @param iClient                Player to target.
 * @param String:sprite            Path to VMT File.
 * @param Float:vOrigin[3]        Location of Sprite.
 * @param Float:fAng[3]            Angles (P Y R).
 * @param Float:Scale            Size of Sprite.
 * @param String:fps            Render Speed.
 * @param Float:fLifetime        Life of Sprite. 
 */
stock CreateSprite(iClientString:sprite[], Float:vOrigin[3], Float:fAng[3], Float:ScaleString:fps[], Float:fLifetime

    new 
String:szTemp[64];  
    
Format(szTempsizeof(szTemp), "client%i"iClient); 
    
DispatchKeyValue(iClient"targetname"szTemp); 
    
    new 
ent CreateEntityByName("env_sprite_oriented"); 
    if (
IsValidEdict(ent)) 
    { 
        new 
String:StrEntityName[64]; Format(StrEntityNamesizeof(StrEntityName), "ent_sprite_oriented_%i"ent); 
        
DispatchKeyValue(ent"model"sprite); 
        
DispatchKeyValue(ent"classname""env_sprite_oriented");
        
DispatchKeyValue(ent"spawnflags""1");
        
DispatchKeyValueFloat(ent"scale"Scale);
        
DispatchKeyValue(ent"rendermode""1");
        
DispatchKeyValue(ent"rendercolor""255 255 255");
        
DispatchKeyValue(ent"framerate"fps);
        
DispatchKeyValueVector(ent"Angles"fAng);
        
DispatchSpawn(ent);
        
        
TeleportEntity(entvOriginfAngNULL_VECTOR); 
        
        
CreateTimer(fLifetimeRemoveParticleent);
    } 
}

/*
 * REMOVE PARTICLE ENT
 * 
 * @param particle        Ent to remove.
 */
public Action:RemoveParticle(Handle:timerany:particle)
{
    if(
IsValidEdict(particle))
    {
        
AcceptEntityInput(particle"Deactivate");
        
AcceptEntityInput(particle"Kill");
    }

vmt file:
Code:
"Sprite"
{
	"$basetexture"	"decals\franug\sm_csgosprays_5\spray_bullseye"
	"$translucent" "1"
	"$nocull" "1"
	"$spriteorientation" "oriented"

}
Input angles (adjust for ground):
Code:
!tests 90.0 0.0 0.0


The problem is that I need to adjust the entity angles with the wall so I need to get wall angles where I am looking for, but how?
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.

Franc1sco is offline
Send a message via MSN to Franc1sco
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 01-19-2017 , 16:18   Re: [CS:GO] Add lifetime to sprays/decals
Reply With Quote #3

Quote:
Originally Posted by Franc1sco View Post
The problem is that I need to adjust the entity angles with the wall so I need to get wall angles where I am looking for, but how?
TR_GetPlaneNormal, but it is flaky as fuck on certain map geometry.
__________________
asherkin is offline
Sappykun
Member
Join Date: Nov 2019
Old 05-28-2021 , 03:49   Re: [CS:GO] Add lifetime to sprays/decals
Reply With Quote #4

Bringing this thread back from the dead to see if there has been any progress made on removing decals from a map mid-game without using Stripper. I'd like to implement something similar in my resizable sprays plugin, but I have been hitting the same roadblocks Franc has.

Is there any way to move a decal once it's been placed, similar to how regular player sprays can be moved?
Sappykun is offline
Zynda
Member
Join Date: Jul 2011
Old 05-31-2021 , 22:54   Re: [CS:GO] Add lifetime to sprays/decals
Reply With Quote #5

infodecals emits a CTEProjectedDecal to all players when they are activated, then deletes themselves, so probably no shot there.

Clients can clear these decals with "r_cleardecals permanent" however, I'm not sure if there is a way to force this effect from the server side.
Zynda 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:56.


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