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

[HOWTO] Spawn Sprites


Post New Thread Reply   
 
Thread Tools Display Modes
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 03-14-2012 , 14:33   Re: [HOWTO] Spawn Sprites
Reply With Quote #11

I still cant compile. this is on where i added the stuff for your ondeath, mine is a lil diffrent for my usage

PHP Code:
#include <amxmodx>  
#include <engine>  
#include <fakemeta>  
#include <cstrike>  

enum HitData
{
    
AttackType:iAttack,
    
Float:flDistance,
    
iHitgroup,
    
iAttacker,
    
iVictim
};

new 
g_iSpriteLightning
new 
g_iSpriteExplode

public 
plugin_precache( ) 

    
g_iSpriteLightning precache_model("sprites/lightning.spr"); 
    
g_iSpriteExplode precache_model("sprites/lm_explode.spr"); 


public 
plugin_init()  
{  
      
    
register_event"Damage""eventDamage""b" );
}  
public 
eventDamage()  
{  
    static 
victim;
    
victim g_HitData[iVictim];

    new 
origin[3]; 
    new 
start]; 
    
    if( 
health 0.0 )
    {
            
// ShowExplSprite
                
get_user_origin(victim,origin);
                
//ShowExplSprite(origin);
            // LightSprite
                
entity_get_vectorvictimEV_VEC_originFloat:start);
                
//ShowLightSprite(start); 
                
                
set_task(0.1,"ShowLightSprite",0); // 0 so that everybody can see it
                
set_task(0.28,"ShowExplSprite",0); // 0 so that everybody can see it 
     
}    
}  

stock ShowLightSprite(start[3]) 

// coord coord coord (start position) 
// coord coord coord (end position) 
// short (sprite index) 

// byte 1(starting frame) 
// byte 2(frame rate in 0.1's) 
// byte 3(life in 0.1's) 
// byte 4(line width in 0.1's) 
// byte 5(noise amplitude in 0.01's) 
// byte,byte,byte 6-8(color) 
// byte 9(brightness) 
// byte 10(scroll speed in 0.1's) 
     
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY); 
     
    
write_coord(start[0]); // x 
    
write_coord(start[1]); // y 
    
write_coord(start[2]); // z 
    
write_coord(start[0]); // x  Example end[0] = start[0] + 100 
    
write_coord(start[1]);// y  Example end[1] = start[1]   
    
write_coord(start[2]-=15); // z 
    
write_short(g_iSpriteLightning); // Sprite index 
    
write_byte(1); //1 
    
write_byte(1); //2 
    
write_byte(30); //3 
    
write_byte(5); //4 
    
write_byte(10); //5 
    
write_byte(255); //6 
    
write_byte(140); //7 
    
write_byte(0); //8 
    
write_byte(255); //9 
     
    
message_end(); 


stock ShowExplSprite(origin[3]) 

    
// write_byte(TE_SPRITE) 
    // write_coord(position.x) 
    // write_coord(position.y) 
    // write_coord(position.z) 
    // write_short(sprite index)  
    // write_byte(scale in 0.1's)  
    // write_byte(brightness) 
     
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY); 
    
write_byte(TE_SPRITE); 
    
write_coord(origin[0]); //x 
    
write_coord(origin[1]); //y 
    
write_coord(origin[2]) ; //z 
    
write_short(g_iSpriteExplode); // Sprite index 
    
write_byte(6); //scale 
    
write_byte(255); //brightness 
    
message_end(); 

Warnings now are:
Code:
Error: Undefined symbol "entity_get_vector" on line 288
Warning: Label name "Float" shadows tag name on line 288
Warning: Expression has no effect on line 288
Error: Expected token: ";", but found ")" on line 288
Error: Invalid expression, assumed zero on line 288
Error: Too many error messages on one line on line 288
striker07 is offline
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 03-24-2012 , 04:25   Re: [HOWTO] Spawn Sprites
Reply With Quote #12

Quote:
Originally Posted by striker07 View Post
I still cant compile. this is on where i added the stuff for your ondeath, mine is a lil diffrent for my usage

PHP Code:
#include <amxmodx>  
#include <engine>  
#include <fakemeta>  
#include <cstrike>  

enum HitData
{
    
AttackType:iAttack,
    
Float:flDistance,
    
iHitgroup,
    
iAttacker,
    
iVictim
};

new 
g_iSpriteLightning
new 
g_iSpriteExplode

public 
plugin_precache( ) 

    
g_iSpriteLightning precache_model("sprites/lightning.spr"); 
    
g_iSpriteExplode precache_model("sprites/lm_explode.spr"); 


public 
plugin_init()  
{  
      
    
register_event"Damage""eventDamage""b" );
}  
public 
eventDamage()  
{  
    static 
victim;
    
victim g_HitData[iVictim];

    new 
origin[3]; 
    new 
start]; 
    
    if( 
health 0.0 )
    {
            
// ShowExplSprite
                
get_user_origin(victim,origin);
                
//ShowExplSprite(origin);
            // LightSprite
                
entity_get_vectorvictimEV_VEC_originFloat:start);
                
//ShowLightSprite(start); 
                
                
set_task(0.1,"ShowLightSprite",0); // 0 so that everybody can see it
                
set_task(0.28,"ShowExplSprite",0); // 0 so that everybody can see it 
     
}    
}  

stock ShowLightSprite(start[3]) 

// coord coord coord (start position) 
// coord coord coord (end position) 
// short (sprite index) 

// byte 1(starting frame) 
// byte 2(frame rate in 0.1's) 
// byte 3(life in 0.1's) 
// byte 4(line width in 0.1's) 
// byte 5(noise amplitude in 0.01's) 
// byte,byte,byte 6-8(color) 
// byte 9(brightness) 
// byte 10(scroll speed in 0.1's) 
     
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY); 
     
    
write_coord(start[0]); // x 
    
write_coord(start[1]); // y 
    
write_coord(start[2]); // z 
    
write_coord(start[0]); // x  Example end[0] = start[0] + 100 
    
write_coord(start[1]);// y  Example end[1] = start[1]   
    
write_coord(start[2]-=15); // z 
    
write_short(g_iSpriteLightning); // Sprite index 
    
write_byte(1); //1 
    
write_byte(1); //2 
    
write_byte(30); //3 
    
write_byte(5); //4 
    
write_byte(10); //5 
    
write_byte(255); //6 
    
write_byte(140); //7 
    
write_byte(0); //8 
    
write_byte(255); //9 
     
    
message_end(); 


stock ShowExplSprite(origin[3]) 

    
// write_byte(TE_SPRITE) 
    // write_coord(position.x) 
    // write_coord(position.y) 
    // write_coord(position.z) 
    // write_short(sprite index)  
    // write_byte(scale in 0.1's)  
    // write_byte(brightness) 
     
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY); 
    
write_byte(TE_SPRITE); 
    
write_coord(origin[0]); //x 
    
write_coord(origin[1]); //y 
    
write_coord(origin[2]) ; //z 
    
write_short(g_iSpriteExplode); // Sprite index 
    
write_byte(6); //scale 
    
write_byte(255); //brightness 
    
message_end(); 

Warnings now are:
Code:
Error: Undefined symbol "entity_get_vector" on line 288
Warning: Label name "Float" shadows tag name on line 288
Warning: Expression has no effect on line 288
Error: Expected token: ";", but found ")" on line 288
Error: Invalid expression, assumed zero on line 288
Error: Too many error messages on one line on line 288
try this
PHP Code:
#include <amxmodx>  
#include <hamsandwich>  
#include <fakemeta>  

new g_iSpriteLightning
new 
g_iSpriteExplode

public 
plugin_precache( ) { 
    
g_iSpriteLightning precache_model("sprites/lightning.spr"); 
    
g_iSpriteExplode precache_model("sprites/lm_explode.spr"); 


public 
plugin_init()  {  
    
    
RegisterHam(Ham_Killed"player""Ham_Kill_Post"1)
}  

public 
Ham_Kill_Post(victimattackershouldgib) {
    if(!
is_user_connected(victim))
        return
    
    static 
Origin[3]
    
    
get_user_origin(victimOrigin)
    
    
ShowLightSprite(Origin)
    
set_task(0.28"ShowExplSprite"0Origin3)
}
    

ShowLightSprite(start[3]) { 
    
// coord coord coord (start position) 
    // coord coord coord (end position) 
    // short (sprite index) 
    
    // byte 1(starting frame) 
    // byte 2(frame rate in 0.1's) 
    // byte 3(life in 0.1's) 
    // byte 4(line width in 0.1's) 
    // byte 5(noise amplitude in 0.01's) 
    // byte,byte,byte 6-8(color) 
    // byte 9(brightness) 
    // byte 10(scroll speed in 0.1's) 
    
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY); 
    
    
write_coord(start[0]); // x 
    
write_coord(start[1]); // y 
    
write_coord(start[2]); // z 
    
write_coord(start[0]); // x  Example end[0] = start[0] + 100 
    
write_coord(start[1]);// y  Example end[1] = start[1]   
    
write_coord(start[2]-=15); // z 
    
write_short(g_iSpriteLightning); // Sprite index 
    
write_byte(1); //1 
    
write_byte(1); //2 
    
write_byte(30); //3 
    
write_byte(5); //4 
    
write_byte(10); //5 
    
write_byte(255); //6 
    
write_byte(140); //7 
    
write_byte(0); //8 
    
write_byte(255); //9 
    
    
message_end(); 


public 
ShowExplSprite(origin[]) { 
    
// write_byte(TE_SPRITE) 
    // write_coord(position.x) 
    // write_coord(position.y) 
    // write_coord(position.z) 
    // write_short(sprite index)  
    // write_byte(scale in 0.1's)  
    // write_byte(brightness) 
    
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY); 
    
write_byte(TE_SPRITE); 
    
write_coord(origin[0]); //x 
    
write_coord(origin[1]); //y 
    
write_coord(origin[2]) ; //z 
    
write_short(g_iSpriteExplode); // Sprite index 
    
write_byte(6); //scale 
    
write_byte(255); //brightness 
    
message_end(); 

----------

@Xvil... why use engine?
__________________

www.amxmodx-es.com

Steam: Luchokoldo

Last edited by rak; 03-24-2012 at 04:27.
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
JoKeR LauGh
Veteran Member
Join Date: May 2011
Location: Malaysia
Old 03-24-2012 , 07:27   Re: [HOWTO] Spawn Sprites
Reply With Quote #13

PHP Code:
    message_begin(MSG_BROADCAST,SVC_TEMPENTITY); 
    
    
write_coord(start[0]); // x 
    
write_coord(start[1]); // y 
    
write_coord(start[2]); // z 
    
write_coord(start[0]); // x  Example end[0] = start[0] + 100 
    
write_coord(start[1]);// y  Example end[1] = start[1]   
    
write_coord(start[2]-=15); // z 
    
write_short(g_iSpriteLightning); // Sprite index 
    
write_byte(1); //1 
    
write_byte(1); //2 
    
write_byte(30); //3 
    
write_byte(5); //4 
    
write_byte(10); //5 
    
write_byte(255); //6 
    
write_byte(140); //7 
    
write_byte(0); //8 
    
write_byte(255); //9 
    
    
message_end(); 
I thought that code needs "engine" module
__________________
Quote:
Originally Posted by addons_zz View Post
Also, just to not read `the article`, read all you find. Read and read, for ever and ever. Never stop reading.
Why? Because there is not one single universal truth which holds the meaning for everything.

Last edited by JoKeR LauGh; 03-24-2012 at 07:27.
JoKeR LauGh is offline
Xvil
BANNED
Join Date: Feb 2012
Old 03-24-2012 , 10:03   Re: [HOWTO] Spawn Sprites
Reply With Quote #14

Quote:
Originally Posted by rak View Post
try this
PHP Code:
#include <amxmodx>  
#include <hamsandwich>  
#include <fakemeta>  

new g_iSpriteLightning
new 
g_iSpriteExplode

public 
plugin_precache( ) { 
    
g_iSpriteLightning precache_model("sprites/lightning.spr"); 
    
g_iSpriteExplode precache_model("sprites/lm_explode.spr"); 


public 
plugin_init()  {  
    
    
RegisterHam(Ham_Killed"player""Ham_Kill_Post"1)
}  

public 
Ham_Kill_Post(victimattackershouldgib) {
    if(!
is_user_connected(victim))
        return
    
    static 
Origin[3]
    
    
get_user_origin(victimOrigin)
    
    
ShowLightSprite(Origin)
    
set_task(0.28"ShowExplSprite"0Origin3)
}
    

ShowLightSprite(start[3]) { 
    
// coord coord coord (start position) 
    // coord coord coord (end position) 
    // short (sprite index) 
    
    // byte 1(starting frame) 
    // byte 2(frame rate in 0.1's) 
    // byte 3(life in 0.1's) 
    // byte 4(line width in 0.1's) 
    // byte 5(noise amplitude in 0.01's) 
    // byte,byte,byte 6-8(color) 
    // byte 9(brightness) 
    // byte 10(scroll speed in 0.1's) 
    
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY); 
    
    
write_coord(start[0]); // x 
    
write_coord(start[1]); // y 
    
write_coord(start[2]); // z 
    
write_coord(start[0]); // x  Example end[0] = start[0] + 100 
    
write_coord(start[1]);// y  Example end[1] = start[1]   
    
write_coord(start[2]-=15); // z 
    
write_short(g_iSpriteLightning); // Sprite index 
    
write_byte(1); //1 
    
write_byte(1); //2 
    
write_byte(30); //3 
    
write_byte(5); //4 
    
write_byte(10); //5 
    
write_byte(255); //6 
    
write_byte(140); //7 
    
write_byte(0); //8 
    
write_byte(255); //9 
    
    
message_end(); 


public 
ShowExplSprite(origin[]) { 
    
// write_byte(TE_SPRITE) 
    // write_coord(position.x) 
    // write_coord(position.y) 
    // write_coord(position.z) 
    // write_short(sprite index)  
    // write_byte(scale in 0.1's)  
    // write_byte(brightness) 
    
    
message_begin(MSG_BROADCAST,SVC_TEMPENTITY); 
    
write_byte(TE_SPRITE); 
    
write_coord(origin[0]); //x 
    
write_coord(origin[1]); //y 
    
write_coord(origin[2]) ; //z 
    
write_short(g_iSpriteExplode); // Sprite index 
    
write_byte(6); //scale 
    
write_byte(255); //brightness 
    
message_end(); 

----------

@Xvil... why use engine?
Soory
Xvil is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-24-2012 , 11:19   Re: [HOWTO] Spawn Sprites
Reply With Quote #15

PHP Code:
    message_begin(MSG_BROADCAST,SVC_TEMPENTITY); 
    
    
write_coord(start[0]); // x 

Where is the temp entity TYPE ? it's missing.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 03-25-2012 , 14:54   Re: [HOWTO] Spawn Sprites
Reply With Quote #16

Quote:
Originally Posted by ConnorMcLeod View Post
PHP Code:
    message_begin(MSG_BROADCAST,SVC_TEMPENTITY); 
    
    
write_coord(start[0]); // x 
Where is the temp entity TYPE ? it's missing.
what do you mean?

I had it compiled but when i went in the game to test it,
when a player was going to die (but not dead yet) the server had overflow or crash not sure and it kicked me out.

I mixed it into the distance meter plugin from SchlumPF
this is how the entire script looks like:
Spoiler
Attached Files
File Type: sma Get Plugin or Get Source (knife-distance(bijnaklaar).sma - 501 views - 12.0 KB)
striker07 is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 03-25-2012 , 15:14   Re: [HOWTO] Spawn Sprites
Reply With Quote #17

You're missing the TE_* byte that needs to be written after you begin the message. You can see all examples here: Const.h Messages Written for AMX
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 03-26-2012 , 04:33   Re: [HOWTO] Spawn Sprites
Reply With Quote #18

ah ok so to fix this i should add for the lignthining (beam):
PHP Code:
#define TE_LIGHTNING    7 
//and one line below message_begin:
write_byte(TE_LIGHTNING
and for the explosion:
PHP Code:
#define TE_EXPLOSION    3
// and
write_byte(TE_EXPLOSION
I also noticed this :
PHP Code:
//-----------------------------------------------------------------------------
#define TE_BEAMSPRITE   18    // A beam with a sprite at the end
 
message_begin(MSG_ ,SVC_TEMPENTITY//message begin
write_byte(TE_)
write_coord() // start position
write_coord()
write_coord()
write_coord() // end position
write_coord()
write_coord()
write_short() // beam sprite index
write_short() // end sprite index
message_end()
//----------------------------------------------------------------------------- 
Would id be better to limit cpu/ram peeks if I use this type of sprite displaying? this way i dont need to work with tasks. so that when the lightning hits the endpoint the explosion automaticly shows?

I will apply the changes and test out some stuff when i get home.
thank you all for your help, much appreciated
striker07 is offline
K.K.Lv
Veteran Member
Join Date: Aug 2008
Location: GameFolder
Old 03-27-2012 , 02:02   Re: [HOWTO] Spawn Sprites
Reply With Quote #19

why not create a real sprite entity ?
__________________
QQ:116268742
K.K.Lv is offline
Send a message via MSN to K.K.Lv
Xvil
BANNED
Join Date: Feb 2012
Old 03-27-2012 , 02:33   Re: [HOWTO] Spawn Sprites
Reply With Quote #20

Quote:
Originally Posted by K.K.Lv View Post
why not create a real sprite entity ?
And what's the class of entity for sprites ??
Xvil 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 12:35.


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