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

[HELP] How I can do to make a sprite follow a player?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nax0ne
Senior Member
Join Date: Jul 2011
Location: Chile
Old 05-05-2016 , 15:20   [HELP] How I can do to make a sprite follow a player?
Reply With Quote #1

I'm trying create a sprite follow the player, but I have not succeeded.

For example, i have a zombie class named "Zombie Heal" (from CSO), and i want when the zombie is healing, the sprite follow the player (in the case if the zombie is moving)

The only idea I have in mind is to detect the velocity of the player, if the player is in moving the sprite follow him. or am I wrong? Please help !

Code:
effect_restore_health( const index ) {     if ( !is_user_alive( index ) || !zbs_is_zombie( index ) ) return;         new Float:flOrigin[ 3 ];     pev( index, pev_origin, flOrigin );                             message_begin( MSG_BROADCAST, SVC_TEMPENTITY );     write_byte( TE_SPRITE );     engfunc( EngFunc_WriteCoord, flOrigin[ 0 ] );     engfunc( EngFunc_WriteCoord, flOrigin[ 1 ] );     engfunc( EngFunc_WriteCoord, flOrigin[ 2 ] + 30.0 ),     write_short( g_iHealSpr );     write_byte( 10 );     write_byte( 192 ),     message_end( )} effect_restore_team_health( const index ) {     if ( !is_user_alive( index ) || !zbs_is_zombie( index ) ) return;         new Float:flOrigin[ 3 ];     pev( index, pev_origin, flOrigin );                              message_begin( MSG_BROADCAST, SVC_TEMPENTITY );     write_byte( TE_SPRITE );     engfunc( EngFunc_WriteCoord, flOrigin[ 0 ] );     engfunc( EngFunc_WriteCoord, flOrigin[ 1 ] );     engfunc( EngFunc_WriteCoord, flOrigin[ 2 ] + 30.0 ),     write_short( g_iHealTeamSpr );     write_byte( 10 );     write_byte( 192 ),     message_end( )}
__________________

Last edited by Nax0ne; 05-06-2016 at 14:04.
Nax0ne is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 05-06-2016 , 08:53   Re: [HELP] How I can do to make a sprite follow a player?
Reply With Quote #2

PHP Code:
stock CREATE_PLAYERATTACHMENT(pPlayeriHeight 50pSpriteiLife)
{
    
message_begin(MSG_ALLSVC_TEMPENTITY);
    
write_byte(TE_PLAYERATTACHMENT);
    
write_byte(pPlayer);
    
write_coord(iHeight);
    
write_short(pSprite);
    
write_short(iLife); // 0.1's
    
message_end();
}

stock CREATE_KILLPLAYERATTACHMENTS(pPlayer)
{
    
message_begin(MSG_ALLSVC_TEMPENTITY);
    
write_byte(TE_KILLPLAYERATTACHMENTS);
    
write_byte(pPlayer);
    
message_end();

__________________
JusTGo is offline
Nax0ne
Senior Member
Join Date: Jul 2011
Location: Chile
Old 05-06-2016 , 14:37   Re: [HELP] How I can do to make a sprite follow a player?
Reply With Quote #3

Quote:
Originally Posted by JusTGo View Post
PHP Code:
stock CREATE_PLAYERATTACHMENT(pPlayeriHeight 50pSpriteiLife)
{
    
message_begin(MSG_ALLSVC_TEMPENTITY);
    
write_byte(TE_PLAYERATTACHMENT);
    
write_byte(pPlayer);
    
write_coord(iHeight);
    
write_short(pSprite);
    
write_short(iLife); // 0.1's
    
message_end();
}

stock CREATE_KILLPLAYERATTACHMENTS(pPlayer)
{
    
message_begin(MSG_ALLSVC_TEMPENTITY);
    
write_byte(TE_KILLPLAYERATTACHMENTS);
    
write_byte(pPlayer);
    
message_end();

Sounds interesting. I'm gonna test it.
__________________
Nax0ne 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 04:05.


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