Участник
Пользователь
- Сообщения
- 107
- Реакции
- 10
Добрый день, коллеги и друзья. Прошу подсказать в чем может быть проблема вызова осмотра себя. Брал код из плагина от Нордика.
Сама команда на вызов работает и мне пишет принт по центру.
Но CreateCam( pPlayer ); не хочет запускаться, мое предположение что переводя код с reapi на обычный, то я что-то не так заменил
Весь код целиком:
Сама команда на вызов работает и мне пишет принт по центру.
Код:
public startcam( const pPlayer ) {
if( !is_user_alive( pPlayer ) )
return;
CreateCam( pPlayer );
client_print( pPlayer , print_center , "Yes, good job")
}
Весь код целиком:
Код:
#include < amxmodx >
#include < amxmisc >
#include < hamsandwich >
#include < cstrike >
#include < engine >
#include < fakemeta_util >
#include < zombienightmare >
#define GetCvarDesc(%0) fmt("%L", LANG_SERVER, %0)
enum _:XYZ { Float:X, Float:Y, Float:Z };
new const CAMERA_CLASSNAME[] = "trigger_camera";
new const CAMERA_MODEL[] = "models/rpgrocket.mdl";
new g_iRotatingSide[33];
new g_iCameraEnt[33];
new g_iPreviousPlayerView[33];
public plugin_init() {
register_plugin(
"[ZN] Addon: Camera Rotation",
"1.0 (Beta)",
"..."
);
register_clcmd( "camshot", "startcam" );
}
public plugin_precache() {
precache_model( CAMERA_MODEL );
}
public startcam( const pPlayer ) {
if( !is_user_alive( pPlayer ) )
return;
CreateCam( pPlayer );
client_print( pPlayer , print_center , "Yes, good job")
}
public client_disconnected( pPlayer ) {
RemoveCam( pPlayer, false );
g_iPreviousPlayerView[ pPlayer ] = 0;
}
public fw_PlayerSpawn_Post( pPlayer ) {
if( !is_user_connected( pPlayer ) )
return;
RemoveCam(pPlayer, true);
}
public CreateCam( pPlayer ) {
new iCameraEnt = create_entity( CAMERA_CLASSNAME );
if( !iCameraEnt )
return;
engfunc( EngFunc_SetModel, iCameraEnt, CAMERA_MODEL );
set_pev( iCameraEnt, pev_owner, pPlayer );
set_pev( iCameraEnt, pev_solid, SOLID_NOT );
set_pev( iCameraEnt, pev_movetype, MOVETYPE_NOCLIP );
set_pev( iCameraEnt, pev_rendermode, kRenderTransColor );
g_iPreviousPlayerView[ pPlayer ] = pev( pPlayer, pev_viewmodel );
set_view( pPlayer, iCameraEnt );
client_cmd( pPlayer, "stopsound" );
set_pev( iCameraEnt, pev_nextthink, get_gametime() + 0.01 );
set_task( 0.01, "OnCamThink", iCameraEnt);
g_iCameraEnt[ pPlayer ] = iCameraEnt;
}
public RemoveCam( pPlayer, bool:bAttachViewToPlayer ) {
if( bAttachViewToPlayer ) {
set_view( pPlayer, g_iPreviousPlayerView[ pPlayer ] );
client_cmd( pPlayer, "stopsound" );
}
new iCameraEnt = MaxClients;
while( ( iCameraEnt = fm_find_ent_by_class( iCameraEnt, CAMERA_CLASSNAME ) ) ) {
if( !iCameraEnt )
continue;
if( pev( iCameraEnt, pev_owner ) == pPlayer && g_iCameraEnt[ pPlayer ] == iCameraEnt ) {
set_pev( iCameraEnt, pev_flags, FL_KILLME );
g_iCameraEnt[ pPlayer ] = 0;
break;
}
}
}
public OnCamThink( iCameraEnt ) {
new pPlayer = pev( iCameraEnt, pev_owner );
if( !is_user_alive( pPlayer ) || !iCameraEnt )
return;
/* --- Рассчёт движения камеры по окружности --- */
static Float:flPlayerOrigin[ XYZ ], Float:flCamOrigin[ XYZ ]
pev( pPlayer, pev_origin, flPlayerOrigin );
static Float:flAngle[ 3 ];
flAngle[ pPlayer ] += 0.005;
flCamOrigin[ X ] = flPlayerOrigin[ X ] + 150.0 * ( g_iRotatingSide[ pPlayer ] ? floatcos(flAngle[ pPlayer ], radian ) : floatsin( flAngle[ pPlayer ], radian ) );
flCamOrigin[ Y ] = flPlayerOrigin[ Y ] + 150.0 * ( g_iRotatingSide[ pPlayer ] ? floatsin(flAngle[ pPlayer ], radian ) : floatcos( flAngle[ pPlayer ], radian ) );
flCamOrigin[ Z ] = flPlayerOrigin[ Z ] + 120.0;
engfunc( EngFunc_TraceLine, flPlayerOrigin, flCamOrigin, IGNORE_MONSTERS, pPlayer, 0 );
new Float:flFraction;
get_tr2( 0, TR_flFraction, flFraction );
flCamOrigin[ X ] = flPlayerOrigin[ X ] + flFraction * 150.0 * ( g_iRotatingSide[ pPlayer ] ? floatcos( flAngle[ pPlayer ], radian ) : floatsin( flAngle[ pPlayer ], radian ) );
flCamOrigin[ Y ] = flPlayerOrigin[ Y ] + flFraction * 150.0 * ( g_iRotatingSide[ pPlayer ] ? floatsin( flAngle[ pPlayer ], radian ) : floatcos( flAngle[ pPlayer ], radian ) );
flCamOrigin[ Z ] = flPlayerOrigin[ Z ] + flFraction * 120.0;
set_pev( iCameraEnt, pev_origin, flCamOrigin );
/* --- */
/* --- Рассчёт того, чтобы камера смотрела на игрока --- */
static Float:flCamAngles[ XYZ ];
xs_vec_sub( flPlayerOrigin, flCamOrigin, flCamAngles );
vector_to_angle( flCamAngles, flCamAngles );
flCamAngles[X] *= -1.0;
set_pev( iCameraEnt, pev_angles, flCamAngles )
/* --- */
set_pev( iCameraEnt, pev_nextthink, get_gametime() + 0.01 );
}
/*CreateCvars() {
bind_pcvar_float( create_cvar( "afk_cam_height", "120.0",
.description = GetCvarDesc( "AFK_CAM_HEIGHT" ) ),
g_pCvarValue[ CAM_HEIGHT ] );
bind_pcvar_float( create_cvar( "afk_cam_distance", "150.0",
.description = GetCvarDesc( "AFK_CAM_DISTANCE" ) ),
g_pCvarValue[ CAM_DISTANCE ] );
bind_pcvar_float( create_cvar( "afk_cam_rotation_speed", "0.005",
.description = GetCvarDesc( "AFK_CAM_ROTATION_SPEED" ) ),
g_pCvarValue[ CAM_ROTATION_SPEED ] );
}*/