Правила форума Гаранты форума
Размещение рекламы AMX-X компилятор

Здравствуйте, гость Вход | Регистрация

Наши новости:

14-дек
24-апр
10-апр
11-апр

Интеграция дамагера

Статус пользователя ThisIsSparta
сообщение 30.9.2015, 10:40
Сообщение #1
Стаж: 11 лет

Сообщений: 566
Благодарностей: 307
Полезность: 600

Здравствуйте народ.
Делаю небольшую менюшку для своего паблик сервера и там есть такая фишка что игроки могут делать некторые настройки. Вкл/выкл подсветку экрана сделал, работает норм, решил добавить дамагер. Дабы не тыркаться с нативами решил все всунуть в один плагин(так удобнее) и тут-то возникло некоторое затруднение.
Перенес код дамагера из abd в свою менюшку все работает, но не показывается урон который наносит игрок, урон который нанесли игроку показывается норм.

Тестирую на голом локальном сервере с подботами. никаких других плагинов с hudами нет

Код:

#define get_bit(%1,%2) ((%1) & (1 << ((%2) - 1)))
#define set_bit(%1,%2) ((%1) |= (1 << ((%2) - 1)))
#define clr_bit(%1,%2) ((%1) &= ~(1 << ((%2) - 1)))

new giMenuV[MAX_PLAYERS + 1]
enum _:SETTING
{
SCREAN,
DAMAGE
};
new g_iBitMenuUsed,g_iBitFirstSet,giType[MAX_PLAYERS + 1][SETTING],gVault


new g_type, g_enabled, g_recieved, bool:g_showrecieved, g_hudmsg1, g_hudmsg2

public plugin_init()
{
register_plugin(PLUGINAME, VERSION, AUTHOR)
register_clcmd("menu", "menu_pub")
register_clcmd("say /menu", "menu_pub")
register_clcmd("nightvision", "menu_pub");

register_event("Damage", "on_damage", "b", "2!0", "3=0", "4!0")
register_event("HLTV", "on_new_round", "a", "1=0", "2=0")

register_event("DeathMsg", "death", "a", "1>0")

g_type = register_cvar("amx_bulletdamage","2")
g_recieved = register_cvar("amx_bulletdamage_recieved","1")

g_hudmsg1 = CreateHudSyncObj()
g_hudmsg2 = CreateHudSyncObj()
}

public death()
{
new i_Killer = read_data(1)
if(giType[i_Killer][SCREAN] == 1)
ScreenFade(i_Killer)
}

public on_new_round()
{
g_enabled = get_pcvar_num(g_type)
if(get_pcvar_num(g_recieved)) g_showrecieved = true
}

public on_damage(id)
{
if(g_enabled && (giType[id][DAMAGE] == 1))
{
static attacker; attacker = get_user_attacker(id)
static damage; damage = read_data(2)

if(g_showrecieved)
{
set_hudmessage(255, 0, 0, 0.45, 0.50, 2, 0.1, 4.0, 0.1, 0.1, -1)
ShowSyncHudMsg(id, g_hudmsg2, "%i^n", damage)
}
if(is_user_connected(attacker))
{
switch(g_enabled)
{
case 1: {
set_hudmessage(0, 100, 200, -1.0, 0.55, 2, 0.1, 4.0, 0.02, 0.02, -1)
ShowSyncHudMsg(attacker, g_hudmsg1, "%i^n", damage)
}
case 2: {
if(fm_is_ent_visible(attacker,id))
{
set_hudmessage(0, 100, 200, -1.0, 0.55, 2, 0.1, 4.0, 0.02, 0.02, -1)
ShowSyncHudMsg(attacker, g_hudmsg1, "%i^n", damage)
}
}
}
}
}
}


public plugin_cfg()
{
gVault = nvault_open("menu");

if(gVault == INVALID_HANDLE)
set_fail_state("[Menu] Can't open nVault file!");
nvault_prune(gVault,0,get_systime() - (30 * 86400));
}

public plugin_end()
{
nvault_close(gVault);
}

public client_putinserver(id)
{
set_bit(g_iBitFirstSet,id);
static szSteamId[32],s_Key[2][40];
get_user_authid(id,szSteamId,charsmax(szSteamId));

formatex(s_Key[0],39,"%sV_1",szSteamId);
formatex(s_Key[1],39,"%sV_2",szSteamId);

giType[id][SCREAN] = nvault_get(gVault,s_Key[0]);
giType[id][DAMAGE] = nvault_get(gVault,s_Key[1]);

set_bit(g_iBitFirstSet,id);
}

public client_disconnect(id)
{
static szSteamId[32],s_Key[2][40],nVaultData[2][8];
get_user_authid(id,szSteamId,charsmax(szSteamId));

formatex(s_Key[0],39,"%sV_1",szSteamId);
formatex(nVaultData[0],7,"%d",giType[id][SCREAN]);

formatex(s_Key[1],39,"%sV_2",szSteamId);
formatex(nVaultData[1],7,"%d",giType[id][DAMAGE]);

nvault_set(gVault,s_Key[0],nVaultData[0]);
nvault_set(gVault,s_Key[1],nVaultData[1]);

clr_bit(g_iBitMenuUsed,id);
clr_bit(g_iBitFirstSet,id);
}

stock ScreenFade( id )
{
message_begin( MSG_ONE, get_user_msgid( "ScreenFade" ), {0,0,0}, id )
write_short( 1<<10 )
write_short( 1<<10 )
write_short( 0x0000 )
write_byte( 0 )
write_byte( 0 )
write_byte( 200 )
write_byte( 40 )
message_end( )
}


Весь код так же прилагаю файлом. Спасибо всем кто откликнется)
Прикрепленные файлы:
Прикрепленный файл  menu_pub.sma ( 6,46 килобайт ) Кол-во скачиваний: 3
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   Цитировать сообщение
oxotnukoff
сообщение 30.9.2015, 11:01
Сообщение #2
Стаж: 13 лет

Сообщений: 164
Благодарностей: 44
Полезность: 128

Спарта я не нашёл старую тему : помоги с эффектом
оффтоп
Код
#include <amxmodx>
#include <engine>
#include <fakemeta>

#define VERSION "5.5"

new const g_szClassname[] = "black_smokenade";

new g_szSmokeSprite;
new g_Cvar_Enabled;

public plugin_init( ) {
   register_plugin( "BulleTgrimS", VERSION, "oxotnukoff" );
    
   register_cvar( "black_smoke", VERSION, FCVAR_SERVER | FCVAR_SPONLY );
   set_cvar_string( "black_smoke", VERSION );
    
  
    
   register_forward( FM_EmitSound, "FwdEmitSound" );
   register_touch( g_szClassname, "worldspawn", "FwdTouch_FakeSmoke" );
   register_think( g_szClassname, "FwdThink_FakeSmoke" );
}

public plugin_precache( ) {
  
    
   precache_sound( "weapons/grenade_hit1.wav" );
}

public FwdEmitSound( iOrigEnt, iChannel, const szSample[], Float:fVol, Float:fAttn, iFlags, iPitch ) {
   new iCvar = get_pcvar_num( g_Cvar_Enabled );
   if( iCvar > 0 ) {
      
      
      if( equal( szSample, szSmokeSound ) ) {
         // cache origin, angles and model
         new Float:vOrigin[ 3 ], Float:vAngles[ 3 ], szModel[ 64 ];
         entity_get_vector( iOrigEnt, EV_VEC_origin, vOrigin );
         entity_get_vector( iOrigEnt, EV_VEC_angles, vAngles );
         entity_get_string( iOrigEnt, EV_SZ_model, szModel, charsmax( szModel ) );
          
         // remove entity from world
         entity_set_vector( iOrigEnt, EV_VEC_origin, Float:{ 10.0, 10.0, 10.0 } );
         entity_set_int( iOrigEnt, EV_INT_flags, FL_KILLME );
          
         // create new entity
         new iEntity = create_entity( "info_target" );
         if( iEntity > 0 ) {
            entity_set_string( iEntity, EV_SZ_classname, g_szClassname );
            
            entity_set_origin( iEntity, vOrigin );
            entity_set_vector( iEntity, EV_VEC_angles, vAngles );
            
            entity_set_int( iEntity, EV_INT_movetype, MOVETYPE_TOSS );
            entity_set_int( iEntity, EV_INT_solid, SOLID_BBOX );
            
            entity_set_float( iEntity, EV_FL_nextthink, get_gametime( ) + 21.5 );
            entity_set_float( iEntity, EV_FL_gravity, 0.5 );
            entity_set_float( iEntity, EV_FL_friction, 0.8 );
            
            entity_set_model( iEntity, szModel );
            
            new Float:vVelocity[ 3 ];
            vVelocity[ 0 ] = random_float( -10.0, 10.0 );
            vVelocity[ 1 ] = random_float( -10.0, 10.0 );
            vVelocity[ 2 ] = random_float(  10.0, 20.0 );
            entity_set_vector( iEntity, EV_VEC_velocity, vVelocity );
            
            emit_sound( iEntity, iChannel, szSample, fVol, fAttn, iFlags, iPitch );
            
            // Store the smoke number in entity, we will use it later
            message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
            write_byte( TE_FIREFIELD );
            engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
            engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
            engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] + 30 );
            write_short( 30 );
            write_short( g_szSmokeSprite );
            write_byte( 50 );
            write_byte( TEFIRE_FLAG_ALPHA );
            write_byte( 1000 );
            message_end();
            
            message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
            write_byte( TE_FIREFIELD );
            engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
            engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
            engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] + 50 );
            write_short( 1 );
            write_short( g_szSmokeSprite );
            write_byte( 1 );
            write_byte( TEFIRE_FLAG_ALPHA | TEFIRE_FLAG_SOMEFLOAT );
            write_byte( 1 );
            message_end( );
         }
      }
   }
}

public FwdTouch_FakeSmoke( iEntity, iWorld ) {
   if( !is_valid_ent( iEntity ) )
      return PLUGIN_CONTINUE;
    
   // Bounce sound
   emit_sound( iEntity, CHAN_VOICE, "weapons/grenade_hit1.wav", 0.25, ATTN_NORM, 0, PITCH_NORM );
    
   new Float:vVelocity[ 3 ];
   entity_get_vector( iEntity, EV_VEC_velocity, vVelocity );
    
   if( vVelocity[ 1 ] <= 0.0 && vVelocity[ 2 ] <= 0.0 ) {
      new Float:vOrigin[ 3 ];
      entity_get_vector( iEntity, EV_VEC_origin, vOrigin );
      
      // Make small smoke near grenade on ground
      message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
      write_byte( TE_FIREFIELD );
      engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
      engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
      engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] + 10 );
      write_short( 2 );
      write_short( g_szSmokeSprite );
      write_byte( 2 );
      write_byte( TEFIRE_FLAG_ALLFLOAT | TEFIRE_FLAG_ALPHA );
      write_byte( 30 );
      message_end();
   }
    
   return PLUGIN_CONTINUE;
}

public FwdThink_FakeSmoke( iEntity ) {
   if( !is_valid_ent( iEntity ) )
      return PLUGIN_CONTINUE;
    
   remove_entity( iEntity );
    
   return PLUGIN_CONTINUE;
}
при повороте дымок тоже поворачивает
Перейти в начало страницы         Просмотр профиля    Отправить личное сообщение
   + Цитировать сообщение
  Ответить в данную темуНачать новую тему
 
0 пользователей и 1 гостей читают эту тему: