AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Trash (https://forums.alliedmods.net/forumdisplay.php?f=22)
-   -   [HOWTO] Spawn Sprites (https://forums.alliedmods.net/showthread.php?t=180087)

Xvil 03-10-2012 12:07

[HOWTO] Spawn Sprites
 
3 Attachment(s)
You Can Use this Script To Display Sprites

Get Player Origin:
PHP Code:

   new Float:start]
  
// get user Origin
  
entity_get_vectoridEV_VEC_originstart ); 

Display Sprite:
PHP Code:

  message_begin(MSG_PVSSVC_TEMPENTITYorigin)
  
write_byte(TE_SPRITETRAIL
  
write_coord(start[0]) // x
  
write_coord(start[1]) // y
  
write_coord(start[2] ) // z
  
write_coord(end[0]) // x  Example end[0] = start[0] + 100
  
write_coord(end[1]) // y  Example end[1] = start[1]  
  
write_coord(end[2]) // z  Example end[2] = start[2]
  
write_short(g_sprite// Sprite Index
  
write_byte(25// Count
  
write_byte(25// Life
  
write_byte(2// Scale
  
write_byte(50// Velocity Along Vector
  
write_byte(10// Rendomness of Velocity
  
message_end(); 


Example:
Spoiler


Screenshot:



JoKeR LauGh 03-10-2012 14:12

Re: [HOWTO] Display Sprites
 
Player will spawn fire at the place where they step?

Anyway, nice work.

Devil259 03-10-2012 15:02

Re: [HOWTO] Display Sprites
 
Yes.

Xvil 03-12-2012 03:00

Re: [HOWTO] Display Sprites
 
Quote:

Originally Posted by JoKeR LauGh (Post 1666183)
Player will spawn fire at the place where they step?

Anyway, nice work.

Yes the Fire Will spawn at the place where he step.

and Thanks.

striker07 03-13-2012 14:34

Re: [HOWTO] Spawn Sprites
 
how can i do it for when a player dies(origin never changes)
I want to do a lightning sprite and a exploding sprite to show up when a player dies,
wil it be effective if i do it like this:

PHP Code:

  new Origin 
  

  engfunc
EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYOrigin); 
  
  
engfuncEngFunc_WriteCoordOrigin ); 
 
  
write_shortlightningsprite );  
  
write_byte); //sprite wil show only 1sec?
  //write_byte( 30 ); is this the damage that will be dealth?
  
write_byte10 ); //height of the sprite?
  //write_byte( 45 ); no need for this becous the player isnt gonna move?
  //write_byte( 40 ); no need for this becous the player isnt gonna move?
  
message_end( ); 

this is probably totally wrong, pls dont flame me i never worked with sprites before

Xvil 03-13-2012 15:24

Re: [HOWTO] Spawn Sprites
 
Quote:

Originally Posted by striker07 (Post 1668185)
how can i do it for when a player dies(origin never changes)
I want to do a lightning sprite and a exploding sprite to show up when a player dies,
wil it be effective if i do it like this:

PHP Code:

  new Origin 
  

  engfunc
EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYOrigin); 
  
  
engfuncEngFunc_WriteCoordOrigin ); 
 
  
write_shortlightningsprite );  
  
write_byte); //sprite wil show only 1sec?
  //write_byte( 30 ); is this the damage that will be dealth?
  
write_byte10 ); //height of the sprite?
  //write_byte( 45 ); no need for this becous the player isnt gonna move?
  //write_byte( 40 ); no need for this becous the player isnt gonna move?
  
message_end( ); 

this is probably totally wrong, pls dont flame me i never worked with sprites before

this An Example:
PHP Code:

#include <amxmodx> 
#include <engine> 
#include <fakemeta> 
#include <cstrike> 

new g_Sprite 

public plugin_precache() 

    
g_Sprite precache_model("sprites/test.spr"

public 
plugin_init() 

     
    
register_event("DeathMsg","onDeath","a"

public 
onDeath() 

    new 
victim read_data(2
    new 
origin[3
    
get_user_origin(victim,origin
    
ShowSprite(origin
}
stock ShowSprite(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]) 
    
write_coord(origin[1]) 
    
write_coord(origin[2]+=30
    
write_short(g_Sprite// Sprite index 
    
write_byte(8
    
write_byte(255
    
message_end() 



striker07 03-14-2012 10:21

Re: [HOWTO] Spawn Sprites
 
Nice, thank you, this will defenitly make it easyer for me thx:)

but i do have a few questions:

the set_task 3.0 secs, does this mean that the showsprite will become 1, 3sec's after the victim has died?

coordinate z is the hight right? when you add +30 there does this mean that the sprite will start showing from z coordinate +=30 units? or that the sprite will be higher with 30 units?

for the scale, is that to extend the width of the sprite? If I enter a value lets say 3, will the sprite be 3 units wider? (sprite width +3 units?) I saw in your contributed notes that it is only for explosions so should i use that too for if i want to add a lightning effect?

striker07 03-14-2012 11:06

Re: [HOWTO] Spawn Sprites
 
Ah nice it certainly works :) but

for the lightning:
i want it to come out of the air, so that the height of the sprite dont matter becous now when players die (very low in the map) the lightning starts coming out of the air about one meter above the player heads and stops at his waste.

for the explosion:
it starts and his waste when it should start at the floor.

- for the lightning:
Can I fix this by making he sprite's height very big and keep the width or is there a way to code it so that the sprite automaticly gets streched when it spawns and starts from to top point of the map?

- for the explosion:
im gonna change the z cordinate for the sprite to write_coord(origin[2]); (without the +=30) and see what that gives

EDIT:

ok after alot of testing I now have this but i cant get it compiled becous of some errors
Spoiler

Errors:

Code:

Error: Undefined symbol "entity_get_vector" on line 421
Error: Undefined symbol "EV_VEC_origin" on line 421
Warning: Expression has no effect on line 421
Error: Expected token: ";", but found ")" on line 421
Error: Too many error messages on one line on line 421


Xvil 03-14-2012 13:47

Re: [HOWTO] Spawn Sprites
 
Sorry I'm Wrong
PHP Code:

#include <amxmodx> 
#include <engine> 
#include <fakemeta> 
#include <cstrike> 

new g_Sprite 

public plugin_precache() 

    
g_Sprite precache_model("sprites/test.spr"

public 
plugin_init() 

     
    
register_event("DeathMsg","onDeath","a"

public 
onDeath() 

    new 
victim read_data(2
    new 
origin[3
    
get_user_origin(victim,origin
    
ShowSprite(origin
}
stock ShowSprite(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]) 
    
write_coord(origin[1]) 
    
write_coord(origin[2]+=30
    
write_short(g_Sprite// Sprite index 
    
write_byte(8
    
write_byte(255
    
message_end() 



Xvil 03-14-2012 13:54

Re: [HOWTO] Spawn Sprites
 
Spoiler


Test this:
Spoiler


All times are GMT -4. The time now is 10:34.

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