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

Control who can see an attached particle


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BrutalGoerge
AlliedModders Donor
Join Date: Jul 2007
Old 03-18-2011 , 20:20   Control who can see an attached particle
Reply With Quote #1

I was wondering if i could attach a particle to a player, and have it visible only to a certain other person. Or any effect for that matter. kinda like when you're dueling someone you can see the thingy floating over that person's head in tf2.
__________________
My Pluggies If you like, consider to me.
BrutalGoerge is offline
dirtyminuth
Senior Member
Join Date: Sep 2009
Old 03-18-2011 , 21:05   Re: Control who can see an attached particle
Reply With Quote #2

You might want to check with Mecha The Slag about this - he was working on achieving this functionality last December.

Failing that, PM me and we can talk about it. I have some theories but haven't had time to test them out.
__________________
dirtyminuth is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 03-19-2011 , 09:47   Re: Control who can see an attached particle
Reply With Quote #3

SDKHooks' SetTransmit can do this.

And you'll need to use the attachables workaround to attach anything to a player for TF2.
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
BrutalGoerge
AlliedModders Donor
Join Date: Jul 2007
Old 03-21-2011 , 02:47   Re: Control who can see an attached particle
Reply With Quote #4

PHP Code:
new g_iClientAttach = -1;
new 
g_iClientCanSee = -1;

new 
g_iParticle = -1;

public 
OnPluginStart()
{
    
HookEvent("player_spawn"Event_PlayerSpawnEventHookMode_Post);
    
HookEvent("player_death"Event_PlayerDeathEventHookMode_Post);
    
HookEvent("teamplay_round_win"Event_RoundWinEventHookMode_PostNoCopy);
}

public 
OnEntityCreated(entity, const String:classname[])
{
    if (
StrEqual(classname"info_particle_system"))
    {
        
SDKHook(entitySDKHook_SpawnHook_OnEntitySpawn);
    }
}

public 
Hook_OnEntitySpawn(entity)
{
    
decl String:parentname[33];
    
GetEntPropString(entityProp_Data"m_iParent"parentnamesizeof(parentname));  
    if (
StrContains(parentname"durp_particle") != -1)
    {
        
SDKHook(entitySDKHook_SetTransmitHook_SetTransmit);
    }
}

public 
Action:Hook_SetTransmit(entityclient
{
    if (
client != g_iClientCanSee)
        return 
Plugin_Handled;
    return 
Plugin_Continue;
}  

public 
Event_RoundWin(Handle:event, const String:name[], bool:dontBroadcast)
{
    
MurderParticle();
}

public 
Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
iDerp GetClientOfUserId(GetEventInt(event"userid"));
    if (
iDerp == g_iClientAttach)
    {
        
MurderParticle();
        if (
GetClientTeam(g_iClientAttach) != GetClientTeam(g_iClientCanSee))
        {
            
AttachParticle(g_iClientAttach"duel_red");
        }
    }
}

public 
Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
iDerp GetClientOfUserId(GetEventInt(event"userid"));
    if (
iDerp == g_iClientAttach)
    {
        
MurderParticle();
    }
}

MurderParticle()
{
    if (
g_iParticle != -&& IsValidEdict(g_iParticle))
    {
        
AcceptEntityInput(g_iParticle"Kill");
        if (
IsValidEdict(g_iParticle))
        {
            
RemoveEdict(g_iParticle);
        }
    }
    
g_iParticle = -1;
}

AttachParticle(entString:particleType[])
{
    
g_iParticle CreateEntityByName("info_particle_system");    
    if (
IsValidEdict(g_iParticle))
    {
        new 
Float:pos[3] ;
        
GetEntPropVector(entProp_Send"m_vecOrigin"pos);
        
pos[1] += 20;
        
TeleportEntity(g_iParticleposNULL_VECTORNULL_VECTOR);
        
        
DispatchKeyValue(ent"targetname""durp_particle");        
        
DispatchKeyValue(g_iParticle"targetname""tf2particle");
        
DispatchKeyValue(g_iParticle"parentname""durp_particle");
        
DispatchKeyValue(g_iParticle"effect_name"particleType);
        
DispatchSpawn(g_iParticle);
        
SetVariantString("durp_particle");
        
AcceptEntityInput(g_iParticle"SetParent"g_iParticleg_iParticle0);
        
SetVariantString("head");
        
AcceptEntityInput(g_iParticle"SetParentAttachment"g_iParticleg_iParticle0);
        
ActivateEntity(g_iParticle);
        
AcceptEntityInput(g_iParticle"start");
    }
}

public 
OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);

2 problems, the transmit is not working, everyone can see the logo, tho i might be doing that wrong, just assuming thats how it works

Second, the logo is not removed when people die, respawn, change class....
tried Kill ent input, and remove edict on the death event and spawn event.

http://cloud.steampowered.com/ugc/55...050AB91EDC231/
__________________
My Pluggies If you like, consider to me.

Last edited by BrutalGoerge; 03-21-2011 at 02:54.
BrutalGoerge is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 03-21-2011 , 10:14   Re: Control who can see an attached particle
Reply With Quote #5

I remember others trying to use SetTransmit and they found it doesn't work on particle systems.
__________________
pheadxdll is offline
BrutalGoerge
AlliedModders Donor
Join Date: Jul 2007
Old 03-21-2011 , 17:46   Re: Control who can see an attached particle
Reply With Quote #6

poo, any ideas? ive never messed with this kinda stuff before. it doesnt have to be a particle, just something visible i guess
__________________
My Pluggies If you like, consider to me.

Last edited by BrutalGoerge; 03-21-2011 at 17:56.
BrutalGoerge is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 03-21-2011 , 20:45   Re: Control who can see an attached particle
Reply With Quote #7

env_sprite would be the easiest to work with.
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
BrutalGoerge
AlliedModders Donor
Join Date: Jul 2007
Old 03-21-2011 , 22:53   Re: Control who can see an attached particle
Reply With Quote #8

sprites lookin good so far, they at least go away when i give them the 'Kill' entity input >
ill try out the transmit blocking later.

thanks
__________________
My Pluggies If you like, consider to me.
BrutalGoerge is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 03-22-2011 , 00:04   Re: Control who can see an attached particle
Reply With Quote #9

I tried that on HL2DM, and it seemed to work just fine as far as I can remember, so you shouldn't have any problems.
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
BrutalGoerge
AlliedModders Donor
Join Date: Jul 2007
Old 03-22-2011 , 12:40   Re: Control who can see an attached particle
Reply With Quote #10

yep it works.
im using OnGameFrame() to teleport the sprite to the player to 'attach' it, but lag compensation makes it look bad
without using that attachments workaround ext, is there a way to at least make it look somewhat better?
__________________
My Pluggies If you like, consider to me.
BrutalGoerge 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 16:05.


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