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

Attaching Sprites


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alandarev
Member
Join Date: Aug 2012
Old 01-24-2013 , 17:45   Attaching Sprites
Reply With Quote #1

I want to make a plugin which displays indicators of player's health bar on top of their head for teammates.
I have been thinking of doing it next way:
create few 2d sprites with coloured bars:
[======]
[==== ]
[= ]
Create TempEffect of this sprite on top of person's head depending on his current health and send it to all teammates.
Everything seems fine except one thing, if person moves, the bar stays behind, can I somehow attach it or is there a more correct solution?
alandarev is offline
blaacky
Senior Member
Join Date: Oct 2012
Old 01-24-2013 , 18:37   Re: Attaching Sprites
Reply With Quote #2

Perhaps AcceptEntityInput may work. I know it can be used to remove an entity that is attached to another so maybe it can be used to add one as well.

SetParent
SetParentAttachment
SetParentAttachmentMaintainOffset

those are commands that you can use with AcceptEntityInput
blaacky is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 01-24-2013 , 19:10   Re: Attaching Sprites
Reply With Quote #3

Quote:
Originally Posted by blaacky View Post
Perhaps AcceptEntityInput may work. I know it can be used to remove an entity that is attached to another so maybe it can be used to add one as well.

SetParent
SetParentAttachment
SetParentAttachmentMaintainOffset

those are commands that you can use with AcceptEntityInput
It would work if creator of thread game is not TF2. In TF2 you would need to teleport sprite over player each frame
__________________
...

Last edited by Oshizu; 01-24-2013 at 19:10.
Oshizu is offline
alandarev
Member
Join Date: Aug 2012
Old 01-25-2013 , 05:05   Re: Attaching Sprites
Reply With Quote #4

Thank you for the reply. It is for Counter-Strike:Source.
Though I have been thinking over TempEntities, not Entities, I do not mind using entities but how do I spawn 'sprite' entity? Can anyone give me a simple example?

Last edited by alandarev; 01-25-2013 at 05:06.
alandarev is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 01-25-2013 , 08:22   Re: Attaching Sprites
Reply With Quote #5

Something like this?

PHP Code:
 
stock AttachSprite
(ClientString:sprite[])
{
    if(!
IsPlayerAlive(Client)) return -1;
    
decl String:iTarget[16];
    
Format(iTarget16"Client%d"Client);
    
DispatchKeyValue(Client"targetname"iTarget);
    
decl Float:Origin[3];
    
GetClientEyePosition(Client,Origin);
    
Origin[2] += 25.0;
    new 
Ent CreateEntityByName("env_sprite");
    if(!
Ent) return -1;
    
DispatchKeyValue(Ent"model"sprite);
    
DispatchKeyValue(Ent"classname""env_sprite");
    
DispatchKeyValue(Ent"spawnflags""1");
    
DispatchKeyValue(Ent"scale""0.1");
    
DispatchKeyValue(Ent"rendermode""1");
    
DispatchKeyValue(Ent"rendercolor""255 255 255");
    
DispatchSpawn(Ent);
    
TeleportEntity(EntOriginNULL_VECTORNULL_VECTOR);
    
SetVariantString(iTarget);
    
AcceptEntityInput(Ent"SetParent"EntEnt0);
    return 
Ent;

i'm not sure if its gonna work or not
If it doesn't
Replace every single 'env_sprite' thing with 'env_sprite_oriented'
__________________
...

Last edited by Oshizu; 01-25-2013 at 08:27.
Oshizu is offline
captaindeterprimary
AlliedModders Donor
Join Date: Sep 2012
Old 01-25-2013 , 14:02   Re: Attaching Sprites
Reply With Quote #6

Why no soup for TF2?
__________________
Last edited by ; Today at 08:20 AM. Reason: Get rid of s
captaindeterprimary is offline
alandarev
Member
Join Date: Aug 2012
Old 01-26-2013 , 08:04   Re: Attaching Sprites
Reply With Quote #7

Thank you Oshizu your method works great!! <3 ya

I am having another problem now, though I will post a separate topic as it is unrelated.
alandarev is offline
zeroibis
Veteran Member
Join Date: Jun 2007
Old 01-29-2013 , 23:32   Re: Attaching Sprites
Reply With Quote #8

Wait so that code actually allowed a sprite to be parrented to a player in CS:S!?!?!

People have been looking to do this for years and this is the first I have heard of it actually working...
__________________
zeroibis is offline
alandarev
Member
Join Date: Aug 2012
Old 01-30-2013 , 03:20   Re: Attaching Sprites
Reply With Quote #9

Yes it works great
zeroibis, you got more interesting ideas to use it for?
alandarev is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 01-30-2013 , 13:24   Re: Attaching Sprites
Reply With Quote #10

Quote:
Originally Posted by alandarev View Post
Thank you Oshizu your method works great!! <3 ya

I am having another problem now, though I will post a separate topic as it is unrelated.
I'm glad it works
Anyway are you planning on publishing plugin or making tutorial how to make healthbar like that?
__________________
...
Oshizu 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 05:26.


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