Raised This Month: $32 Target: $400
 8% 

TF2 Sprite


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Skippy
Senior Member
Join Date: Nov 2011
Old 11-11-2014 , 12:06   TF2 Sprite
Reply With Quote #1

So I have sprite above players heads and right now I have it teleporting every game frame but it's very choppy and doesn't look smooth. Is OnGameFrame the only way to have it follow the player around? (Keep in mind this is for TF2)
__________________
Plugins:
[Any] Aim Menu

Want a TF2 plugin? Feel free to pm me to discuss it.
Skippy is offline
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 11-11-2014 , 12:22   Re: TF2 Sprite
Reply With Quote #2

Quote:
Originally Posted by Skippy View Post
So I have sprite above players heads and right now I have it teleporting every game frame but it's very choppy and doesn't look smooth. Is OnGameFrame the only way to have it follow the player around? (Keep in mind this is for TF2)
Well attach it instead of teleporting to hat or head
__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player
Michalplyoutube is offline
Skippy
Senior Member
Join Date: Nov 2011
Old 11-11-2014 , 12:36   Re: TF2 Sprite
Reply With Quote #3

Quote:
Originally Posted by Michalplyoutube View Post
Well attach it instead of teleporting to hat or head
As far as I know TF2 doesn't allow attachments and if it's able to attach could you show me?
__________________
Plugins:
[Any] Aim Menu

Want a TF2 plugin? Feel free to pm me to discuss it.
Skippy is offline
Plaffy46
Junior Member
Join Date: Mar 2014
Old 11-12-2014 , 06:14   Re: TF2 Sprite
Reply With Quote #4

I found some stock functionsin zombie fortress doing that, I don't know if this method still works though, anyways, here you go :

Code:
stock fxCreateSprite(
  const String:strSprite[], 
  target, 
  &entSpr, 
  &entAnc)
{
  //
  // Create a networked sprite attached to a player's head.
  // This is done by parenting a sprite to a false 'anchor' prop, and then
  // parenting the anchor to a target. While the anchor will not be visible,
  // the sprite will be. Furthermore, since the sprite is parented to a 
  // networked entity, an extension like SDKHooks can be used to selectively
  // display the sprite to an arbitrary set of clients.
  //
  entSpr = CreateEntityByName("env_sprite");
  if(IsValidEntity(entSpr))
  {  
    entAnc = CreateEntityByName("prop_physics_multiplayer");
    if(IsValidEntity(entAnc))
    {
      decl String:strSprTargetname[32]; 
      decl String:strAncTargetname[32];
      decl String:strTgtTargetname[32];
      Format(strSprTargetname, sizeof(strSprTargetname), "zfspr%i", entSpr);
      Format(strAncTargetname, sizeof(strAncTargetname), "zfanc%i", entAnc);
      Format(strTgtTargetname, sizeof(strTgtTargetname), "zftgt%i", target);
      
      // Retrieve target's position
      decl Float:posTgt[3];
      GetEntPropVector(target, Prop_Send, "m_vecOrigin", posTgt);
      posTgt[2] += 12.0;
         
      // Configure target.
      DispatchKeyValue(target, "targetname", strTgtTargetname);
        
      // Configure and spawn anchor.
      DispatchKeyValue(entAnc, "targetname", strAncTargetname);
      DispatchKeyValue(entAnc, "parentname", strTgtTargetname);
      SetEntityMoveType(entAnc, MOVETYPE_NOCLIP);
      SetEntityModel(entAnc, ZFMDL_PRESENT[0]);
      SetEntityRenderMode(entAnc, RENDER_TRANSCOLOR);
      SetEntityRenderColor(entAnc, 0, 0, 0, 0);     
      DispatchSpawn(entAnc);
      
      // Configure and spawn sprite.
      DispatchKeyValue(entSpr, "targetname", strSprTargetname);
      DispatchKeyValue(entSpr, "parentname", strAncTargetname);    
      DispatchKeyValue(entSpr, "model", strSprite);
      DispatchKeyValue(entSpr, "classname", "env_sprite");
      DispatchKeyValue(entSpr, "spawnflags", "1");
      DispatchKeyValue(entSpr, "scale", "0.1");
      DispatchKeyValue(entSpr, "rendermode", "1");
      DispatchKeyValue(entSpr, "rendercolor", "255 255 255");
      DispatchSpawn(entSpr);
      
      // Teleport sprite and anchor to target.
      TeleportEntity(entSpr, posTgt, NULL_VECTOR, NULL_VECTOR);
      TeleportEntity(entAnc, posTgt, NULL_VECTOR, NULL_VECTOR);
      
      // Parent sprite to anchor.
      SetVariantString(strAncTargetname);
      AcceptEntityInput(entSpr, "SetParent", entSpr, entSpr, 0);
      
      // Parent anchor to target.
      AcceptEntityInput(entAnc, "DisableMotion");
      AcceptEntityInput(entAnc, "DisableShadow");
      SetVariantString(strTgtTargetname);
      AcceptEntityInput(entAnc, "SetParent", entAnc, entAnc, 0);
      SetVariantString("head");
      AcceptEntityInput(entAnc, "SetParentAttachmentMaintainOffset", entAnc, entAnc, 0);
    }
    else
    {
      LogError("[ZF] fxCreateSprite(entAnc) (%s, %d) failed.", strSprite, target);  
    }
  }
  else
  {
    LogError("[ZF] fxCreateSprite(entSpr) (%s, %d) failed.", strSprite, target);
  }
}

stock fxDeleteSprite(entSpr, entAnc)
{
  if(fxIsSpriteValid(entSpr, entAnc))
  { 
    AcceptEntityInput(entSpr, "Kill");
    AcceptEntityInput(entAnc, "Kill");
  }
}

stock fxShowSprite(entSpr, entAnc)
{
  if(fxIsSpriteValid(entSpr, entAnc))
    AcceptEntityInput(entSpr, "ShowSprite");    
}

stock fxHideSprite(entSpr, entAnc)
{
  if(fxIsSpriteValid(entSpr, entAnc))
    AcceptEntityInput(entSpr, "HideSprite");    
}
Plaffy46 is offline
Skippy
Senior Member
Join Date: Nov 2011
Old 11-12-2014 , 20:12   Re: TF2 Sprite
Reply With Quote #5

Yeah every time I'm trying to use this coding it's crashing the server now
__________________
Plugins:
[Any] Aim Menu

Want a TF2 plugin? Feel free to pm me to discuss it.
Skippy is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 11-12-2014 , 20:43   Re: TF2 Sprite
Reply With Quote #6

From "[TF2] Donator Recognition":

Spoiler


Use "CreateSprite(i, "%.vmt", 25.0);", where "%" is the name of the sprite VMT (and the path to it, I believe). "25.0" is the offset which I believe would be the height.

Use "KillSprite(i);" to kill it.

I'm actually picking up an old project that I put to the side for a while, which is to re-code the Donator Recognition plugin so it doesn't require use of the Basic Donator Interface plugin.

Last edited by 404UserNotFound; 11-12-2014 at 20:44.
404UserNotFound is offline
Skippy
Senior Member
Join Date: Nov 2011
Old 11-13-2014 , 09:24   Re: TF2 Sprite
Reply With Quote #7

Quote:
Originally Posted by abrandnewday View Post
From "[TF2] Donator Recognition":

Spoiler


Use "CreateSprite(i, "%.vmt", 25.0);", where "%" is the name of the sprite VMT (and the path to it, I believe). "25.0" is the offset which I believe would be the height.

Use "KillSprite(i);" to kill it.

I'm actually picking up an old project that I put to the side for a while, which is to re-code the Donator Recognition plugin so it doesn't require use of the Basic Donator Interface plugin.
Yeah I already use that coding. It teleports it on game frame which I don't want. It's not smooth.
__________________
Plugins:
[Any] Aim Menu

Want a TF2 plugin? Feel free to pm me to discuss it.
Skippy is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 11-16-2014 , 20:31   Re: TF2 Sprite
Reply With Quote #8

Look for Noodleboy 347's old Premium mod (someone recently re-did and re-released it), that has a CreateParticle function in it with a few attachment points (head, back). I'm pretty sure you can mess with that and make it use sprite entities instead of particles.
404UserNotFound is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 11-16-2014 , 23:08   Re: TF2 Sprite
Reply With Quote #9

You could also try OnPostThink or OnPreThink as well from SDKHooks to update the location of the sprite.
Drixevel is offline
Skippy
Senior Member
Join Date: Nov 2011
Old 11-16-2014 , 23:40   Re: TF2 Sprite
Reply With Quote #10

Quote:
Originally Posted by r3dw3r3w0lf View Post
You could also try OnPostThink or OnPreThink as well from SDKHooks to update the location of the sprite.
Wouldn't that result in the same thing as OnGameFrame?
__________________
Plugins:
[Any] Aim Menu

Want a TF2 plugin? Feel free to pm me to discuss it.
Skippy is offline
Reply


Thread Tools
Display Modes

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 06:30.


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