SergeyShorokhov
could you please make tuto how can make a custom smoke sprite?
could you please make tuto how can make a custom smoke sprite?
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#if !defined write_coord_f
#define write_coord_f(%1) engfunc( EngFunc_WriteCoord, %1 )
#endif
new
Array:g_iMenu_Command;
new const GLOBAL_DIR[] = "custom_smoke"; //Имя папки где будет создан файл. (Если данной папки нет -- создаётся автоматически).
new const FILE[] = "custom_smoke.ini"; //Имя файла где будут все настройки. (Если файла нет -- создаётся автоматически).
#define VERSION "1.07"
new const g_szClassname[] = "custom_smoke";
new g_fwid
new g_evCreateSmoke;
new g_szSmokeSprite;
new g_Cvar_Enabled;
new g_Cvar_Duration;
new g_Cvar_CountSprites;
new g_Clear;
new g_iCvar_Enebled;
new g_iCountSprites;
new g_szConfigsDir[256];
public plugin_init( )
{
register_plugin( "Custom Smoke", VERSION, "bionext" );
g_iMenu_Command = ArrayCreate(32);
g_Clear = 0;
g_iCvar_Enebled = 0;
g_Cvar_Enabled = register_cvar( "sv_customsmoke", "1" );
g_Cvar_Duration = register_cvar( "sv_smokeduration", "10.0" );
g_Cvar_CountSprites = register_cvar( "sv_smokespritescount", "30" );
get_configsdir(g_szConfigsDir,charsmax(g_szConfigsDir));
CreateFile();
ReadFile();
new szCommand[64];
ArrayGetString(g_iMenu_Command, 0, szCommand, charsmax(szCommand));
g_szSmokeSprite = engfunc(EngFunc_PrecacheModel, szCommand);
unregister_forward(FM_PrecacheEvent, g_fwid, 1);
register_think( g_szClassname, "FwdThink_BlackSmoke" );
register_forward(FM_PlaybackEvent, "FwdPlaybackEvent");
register_logevent("FwdClear", 2, "1=Round_End");
register_logevent("FwdStart", 2, "1=Round_Start");
register_event("TextMsg", "FwdClear", "a", "2=#Game_will_restart_in","2=#Game_Commencing");
}
public FwdClear( )
{
g_Clear = 1;
}
public FwdStart( )
{
g_iCvar_Enebled = get_pcvar_num( g_Cvar_Enabled );
g_Clear = 0;
}
public plugin_precache( )
{
g_fwid = register_forward(FM_PrecacheEvent, "FwdPrecacheEvent", 1);
//force_unmodified(force_exactfile, {0,0,0},{0,0,0}, szCommand);
}
public FwdPlaybackEvent( iFlags , iEntity , iEventindex, Float:fDelay, Float:vOrigin[3], Float:vAngles[3], Float:fParam1, Float:fParam2, iParam1, iParam2, iBparam1, iBparam2 )
{
if(iEventindex != g_evCreateSmoke || iBparam2 || !g_iCvar_Enebled)
return FMRES_IGNORED;
new iEnt = create_entity( "info_target" );
if( !iEnt )
return FMRES_IGNORED;
g_iCountSprites = get_pcvar_num( g_Cvar_CountSprites );
new Float:fDuration = get_pcvar_float( g_Cvar_Duration );
entity_set_string( iEnt, EV_SZ_classname, g_szClassname );
entity_set_float( iEnt, EV_FL_nextthink, get_gametime( ));
entity_set_vector( iEnt, EV_VEC_origin, vOrigin );
entity_set_float( iEnt, EV_FL_animtime, fDuration );
return FMRES_SUPERCEDE;
}
public FwdPrecacheEvent(type, const name[])
{
if (equal("events/createsmoke.sc", name))
{
g_evCreateSmoke = get_orig_retval();
return FMRES_HANDLED;
}
return FMRES_IGNORED;
}
public FwdThink_BlackSmoke( iEntity )
{
if( !is_valid_ent( iEntity ) )
return PLUGIN_CONTINUE;
if( g_Clear > 0 )
{
entity_set_int( iEntity,EV_INT_flags, FL_KILLME );
return PLUGIN_CONTINUE;
}
new Float:vOrigin[3];
entity_get_vector( iEntity, EV_VEC_origin, vOrigin );
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_FIREFIELD );
write_coord_f( vOrigin[ 0 ] );
write_coord_f( vOrigin[ 1 ] );
write_coord_f( vOrigin[ 2 ] + 50 );
write_short( 100 );
write_short( g_szSmokeSprite );
write_byte( g_iCountSprites );
write_byte( TEFIRE_FLAG_ALPHA );
write_byte( 11 );
message_end();
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_FIREFIELD );
write_coord_f( vOrigin[ 0 ] );
write_coord_f( vOrigin[ 1 ] );
write_coord_f( vOrigin[ 2 ] + 50 );
write_short( 150 );
write_short( g_szSmokeSprite );
write_byte( 5 );
write_byte( TEFIRE_FLAG_ALPHA | TEFIRE_FLAG_SOMEFLOAT );
write_byte( 11 );
message_end( );
new Float:time = entity_get_float(iEntity,EV_FL_animtime);
time = time - 0.25;
if( time > 0.0 )
{
entity_set_float( iEntity, EV_FL_nextthink, get_gametime( ) + 0.25 );
entity_set_float( iEntity, EV_FL_animtime, time );
}
else
{
entity_set_int( iEntity,EV_INT_flags, FL_KILLME );
}
return PLUGIN_CONTINUE;
}
stock ReadFile() {
new szData[256],szFile[256],f;
formatex(szFile,charsmax(szFile),"%s/%s/%s",g_szConfigsDir,GLOBAL_DIR,FILE);
f = fopen(szFile,"r");
new szLeft[256],szRight[256];
while(!feof(f)) {
fgets(f,szData,charsmax(szData));
trim(szData);
if(!szData[0] || szData[0] == ';' || szData[0] == EOS)
continue;
strtok(szData,szLeft,charsmax(szLeft),szRight,charsmax(szRight),'=');
trim(szLeft),trim(szRight);
if(equal(szLeft, "PATH"))
ArrayPushString(g_iMenu_Command,szRight);
continue;
}
fclose(f);
}
stock CreateFile() {
new szData[256];
formatex(szData,charsmax(szData),"%s/%s",g_szConfigsDir,GLOBAL_DIR);
if(!dir_exists(szData))
mkdir(szData);
formatex(szData,charsmax(szData),"%s/%s",szData,FILE);
if(!file_exists(szData))
write_file(szData,
"; /*-----[Инструкция]-----*/^n\
;^n\
; PATH -- команда открытия меню^n\
;^n\
; /*-----[Настройки]-----*/^n\
PATH = 12.spr"
);
}