Sprite Changer

Active Member
✔️ HL Verified
💻 Oldtimer
Joined
Mar 13, 2005
Messages
3,877
Best answers
0
Not too experienced with this... so... Will this work?


Code:
#include <amxmodx> 
#include <fun> 
#include <engine> 
#include <fakemeta> 

new kame, kameball, kametrail 

public plugin_init() 
    
{ 
   register_message( get_user_msgid( "EETrail" ), "trail" ); 
} 

public trail( id ) 
    
{ 
    
   new pid = get_msg_arg_int( 1 ); // pid = PLAYER ID 
    
   if ( variable == 1) 
  
   { 
  
  set_msg_arg_int( 5, 0, kame ); // the thingy in ur hand 
  set_msg_arg_int( 6, 0, kameball ); // beam start 
  set_msg_arg_int( 7, 0, kameball ); // beam end 
  set_msg_arg_int( 8, 0, kametrail ); // trail 
  set_msg_arg_int( 9, 0, get_msg_arg_int( 9 ) * 5 ) // scale 
  
   } 
    
    
   return PLUGIN_CONTINUE; 
    
} 

public kamehamehacharge (id) 
   { 
   new Float:vOrigin[3]; 
   entity_get_vector( id, EV_VEC_origin, vOrigin ); 
    
   new ent = find_ent_in_sphere( -1, vOrigin, 64.0 ); 
   while( ent > 0 ) 
  
   { 
  
  new szModel[32]; 
  entity_get_string( ent, EV_SZ_model, szModel, 31 ); 
  if( containi( szModel, "sprites/OldKamesprite.spr" ) != -1 ) 
      
  { 
      
     entity_set_model( ent, "sprites/Newkamecharge.spr" ); 
      
  } 
  
  ent = find_ent_in_sphere( ent, vOrigin, 64.0 ); 
  
  
   } 
} 

public plugin_precache() 
   { 
   kameball = precache_model("sprites/Newkamestart.spr") 
   kametrail = precache_model("sprites/NewKametrail.spr") 
   kame = precache_model("sprites/Newkamecharge.spr") 
}
 
Member
✔️ HL Verified
🎈 Advanced
Joined
Oct 16, 2006
Messages
379
Best answers
0
I can't vouch for efficiency, since I haven't scripted in Small for years. but this is what I've come up with;

Code:
#include <amxmodx> 
#include <fun> 
#include <engine> 
#include <fakemeta> 

new kame, kameball, kametrail 

public plugin_init() 
{ 
   register_message( get_user_msgid( "EETrail" ), "trail" ); 
} 

public trail( id ) 
{ 
	new playerID = get_msg_arg_int( 1 );
	new weapon = get_user_weapon( playerID );
	
	if ( weapon == 6 ) //kame
	{ 
		set_msg_arg_int( 5, ARG_SHORT, kame ); // beam start
		set_msg_arg_int( 6, ARG_SHORT, kameball ); // beam head
		set_msg_arg_int( 7, ARG_SHORT, kameball ); //kame charge
		set_msg_arg_int( 8, ARG_SHORT, kametrail ); // trail
		set_msg_arg_int( 9, ARG_BYTE, get_msg_arg_int(9) * 5 ) //scale
	} 
    
   return PLUGIN_CONTINUE; 
} 

public server_frame() 
{
	new weapon
	//go through each player
	for(new i = 1; i <= get_playersnum(); i++) 
	{
		if(!is_user_alive(i))
			continue;
		
		weapon = get_user_weapon( i );
		
		if (weapon == 6)
			kamehamehacharge(i);
	}
}

public kamehamehacharge (id) 
{ 
	new Float:vOrigin[3]; 
	new szModel[32]; 
	
	entity_get_vector( id, EV_VEC_origin, vOrigin ); 
	new ent = find_ent_in_sphere( -1, vOrigin, 64.0 ); 
	
	while( ent > 0 ) 
	{ 
		szModel[0] = '^0'; //empty the string
		
		entity_get_string( ent, EV_SZ_model, szModel, 31 ); 
		if( containi( szModel, "sprites/kamecharge.spr" ) != -1 ) 
		{ 
			entity_set_model( ent, "sprites/Newkamecharge.spr" ); 
		} 

		ent = find_ent_in_sphere( ent, vOrigin, 64.0 ); 
	} 
} 


public plugin_precache() 
{ 
   kameball = precache_model("sprites/Newkamestart.spr") 
   kametrail = precache_model("sprites/NewKametrail.spr") 
   kame = precache_model("sprites/Newkamecharge.spr") 
}
Also, someone told me a long while ago that you proberly could change the server_frame with some kind of client_frame callback, but like I said, I haven't done this in a while.

And if you want to find out more about efficiency, check out this page: http://wiki.amxmodx.org/Optimizing_Plugins_(AMX_Mod_X_Scripting)
 
NOT IN THE MANGA™
★ Black Lounger ★
✔️ HL Verified
🚂 Steam Linked
💻 Oldtimer
Joined
Jan 5, 2008
Messages
3,276
Best answers
0
I can't vouch for efficiency, since I haven't scripted in Small for years. but this is what I've come up with;

Code:
#include <amxmodx> 
#include <fun> 
#include <engine> 
#include <fakemeta> 

new kame, kameball, kametrail 

public plugin_init() 
{ 
   register_message( get_user_msgid( "EETrail" ), "trail" ); 
} 

public trail( id ) 
{ 
	new playerID = get_msg_arg_int( 1 );
	new weapon = get_user_weapon( playerID );
	
	if ( weapon == 6 ) //kame
	{ 
		set_msg_arg_int( 5, ARG_SHORT, kame ); // beam start
		set_msg_arg_int( 6, ARG_SHORT, kameball ); // beam head
		set_msg_arg_int( 7, ARG_SHORT, kameball ); //kame charge
		set_msg_arg_int( 8, ARG_SHORT, kametrail ); // trail
		set_msg_arg_int( 9, ARG_BYTE, get_msg_arg_int(9) * 5 ) //scale
	} 
    
   return PLUGIN_CONTINUE; 
} 

public server_frame() 
{
	new weapon
	//go through each player
	for(new i = 1; i <= get_playersnum(); i++) 
	{
		if(!is_user_alive(i))
			continue;
		
		weapon = get_user_weapon( i );
		
		if (weapon == 6)
			kamehamehacharge(i);
	}
}

public kamehamehacharge (id) 
{ 
	new Float:vOrigin[3]; 
	new szModel[32]; 
	
	entity_get_vector( id, EV_VEC_origin, vOrigin ); 
	new ent = find_ent_in_sphere( -1, vOrigin, 64.0 ); 
	
	while( ent > 0 ) 
	{ 
		szModel[0] = '^0'; //empty the string
		
		entity_get_string( ent, EV_SZ_model, szModel, 31 ); 
		if( containi( szModel, "sprites/kamecharge.spr" ) != -1 ) 
		{ 
			entity_set_model( ent, "sprites/Newkamecharge.spr" ); 
		} 

		ent = find_ent_in_sphere( ent, vOrigin, 64.0 ); 
	} 
} 


public plugin_precache() 
{ 
   kameball = precache_model("sprites/Newkamestart.spr") 
   kametrail = precache_model("sprites/NewKametrail.spr") 
   kame = precache_model("sprites/Newkamecharge.spr") 
}
Also, someone told me a long while ago that you proberly could change the server_frame with some kind of client_frame callback, but like I said, I haven't done this in a while.

And if you want to find out more about efficiency, check out this page: http://wiki.amxmodx.org/Optimizing_Plugins_(AMX_Mod_X_Scripting)
Such model/sprite changes are caught in FM_SetModel forward so there's really no point in using server_frame() for that.
 
Active Member
✔️ HL Verified
💻 Oldtimer
Joined
Mar 13, 2005
Messages
3,877
Best answers
0
Thanks you two. I am still completely new to this all. I used to mess with it long ago but lost my mind trying.
 

Users who are viewing this thread

Top