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

Showing sprites above players head


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CodeMonkey
Junior Member
Join Date: Dec 2009
Old 01-12-2011 , 02:37   Showing sprites above players head
Reply With Quote #1

Hey, I've been working on a plugin that would want to place a icon above a player's head to be seen by a few other players (something along the lines of the domination icon.) I was wondering if I could be pointed in the correct direction of how to do this.

Any help is greatly appreciated. Thanks.
CodeMonkey is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 01-12-2011 , 03:09   Re: Showing sprites above players head
Reply With Quote #2

SDK Hooks SetTransmit.
__________________
FaTony is offline
CodeMonkey
Junior Member
Join Date: Dec 2009
Old 01-12-2011 , 03:14   Re: Showing sprites above players head
Reply With Quote #3

Quote:
Originally Posted by FaTony View Post
SDK Hooks SetTransmit.
Could you possibly post an example?
CodeMonkey is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 01-12-2011 , 03:15   Re: Showing sprites above players head
Reply With Quote #4

http://forums.alliedmods.net/showthread.php?t=106748
__________________
FaTony is offline
CodeMonkey
Junior Member
Join Date: Dec 2009
Old 01-12-2011 , 03:29   Re: Showing sprites above players head
Reply With Quote #5

Ahh, yes thank you.

That answered part of my question. What I'm look for now is a way to add the sprite above their head.

Perhaps there is a tutorial somewhere on this or maybe even an example that I can look off of.

I tried to understand how to do this from http://forums.alliedmods.net/showthread.php?t=122320 but couldn't get it to work. If I could just see some code of how to take a sprite from a vmt/vtf file and paste it above a players head to be seen by all that should help quite a bit.
CodeMonkey is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 01-12-2011 , 03:47   Re: Showing sprites above players head
Reply With Quote #6

I guess it's this:
PHP Code:
stock CreateSprite(iClientString:sprite[], Float:offset)
{
    new 
String:szTemp[64]; 
    
Format(szTempsizeof(szTemp), "client%i"iClient);
    
DispatchKeyValue(iClient"targetname"szTemp);

    new 
Float:vOrigin[3];
    
GetClientAbsOrigin(iClientvOrigin);
    
vOrigin[2] += offset;
    new 
ent CreateEntityByName("env_sprite_oriented");
    if (
ent)
    {
        
DispatchKeyValue(ent"model"sprite);
        
DispatchKeyValue(ent"classname""env_sprite_oriented");
        
DispatchKeyValue(ent"spawnflags""1");
        
DispatchKeyValue(ent"scale""0.1");
        
DispatchKeyValue(ent"rendermode""1");
        
DispatchKeyValue(ent"rendercolor""255 255 255");
        
DispatchKeyValue(ent"targetname""donator_spr");
        
DispatchKeyValue(ent"parentname"szTemp);
        
DispatchSpawn(ent);
        
        
TeleportEntity(entvOriginNULL_VECTORNULL_VECTOR);

        
g_EntList[iClient] = ent;
    }

__________________
FaTony is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 01-12-2011 , 04:15   Re: Showing sprites above players head
Reply With Quote #7

Looks like the ents being teleported on every game frame, it would be better to parent the entity onto the player.

PHP Code:
    decl String:sTemp[16];
    
Format(sTempsizeof(sTemp), "client%i"client);
    
DispatchKeyValue(client"targetname"sTemp);
    
SetVariantString(sTemp);
    
AcceptEntityInput(iEnt"SetParent"iEntiEnt0);

    
// Attach to a specific point (names found in SDK Model Viewer)
    
SetVariantString("primary");
    
AcceptEntityInput(iEnt"SetParentAttachment"); 
__________________
Silvers is offline
CodeMonkey
Junior Member
Join Date: Dec 2009
Old 01-12-2011 , 04:41   Re: Showing sprites above players head
Reply With Quote #8

Yeah I was looking into that. Don't suppose you've got a link to a fancy tutorial on sprite making. Looks like I got the donator code to work but it's offset a little.

Thanks for your suggestions!
CodeMonkey is offline
FaTony
Veteran Member
Join Date: Aug 2008
Old 01-12-2011 , 04:55   Re: Showing sprites above players head
Reply With Quote #9

Quote:
Originally Posted by Silvers View Post
Looks like the ents being teleported on every game frame
No,
PHP Code:
DispatchKeyValue(ent"parentname"szTemp); 
__________________
FaTony is offline
CodeMonkey
Junior Member
Join Date: Dec 2009
Old 01-12-2011 , 17:18   Re: Showing sprites above players head
Reply With Quote #10

Quote:
Originally Posted by FaTony View Post
No,
PHP Code:
DispatchKeyValue(ent"parentname"szTemp); 
I think he's right, when I don't put this code in

PHP Code:
public OnGameFrame()
{
    new 
entFloat:vOrigin[3], Float:vVelocity[3];
    
    for(new 
1<= MaxClientsi++)
    {
        if (!
IsClientInGame(i)) continue;
        if ((
ent g_EntList[i]) > 0)
        {
            if (!
IsValidEntity(ent))
                
g_EntList[i] = 0;
            else
                if ((
ent EntRefToEntIndex(ent)) > 0)
                {
                    
GetClientEyePosition(ivOrigin);
                    
vOrigin[2] += 25.0;
                    
GetEntDataVector(igVelocityOffsetvVelocity);
                    
TeleportEntity(entvOriginNULL_VECTORvVelocity);
                }
        }
    }

The sprites don't move they stay stationary between the legs of the players. I've been fiddling with some pieces of code and it seams whenever I do
PHP Code:
DispatchKeyValue(ent"targetname"StrEntityName); 
Where StrEntityName is a unique name for the sprite it will not show up at all.
CodeMonkey 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 01:47.


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