AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] How I can do to make a sprite follow a player? (https://forums.alliedmods.net/showthread.php?t=282389)

Nax0ne 05-05-2016 15:20

[HELP] How I can do to make a sprite follow a player?
 
I'm trying create a sprite follow the player, but I have not succeeded. :cry: :cry:

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( ); }

JusTGo 05-06-2016 08:53

Re: [HELP] How I can do to make a sprite follow a player?
 
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();



Nax0ne 05-06-2016 14:37

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

Originally Posted by JusTGo (Post 2417138)
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. :)


All times are GMT -4. The time now is 18:44.

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