Проверенный
Пользователь
- Сообщения
- 1,032
- Реакции
- 828
- Помог
- 10 раз(а)
Да.Шапку некому обновить?
#define LOWER_LIMIT_OF_ENTITIES 100
#define var_last_time var_pitch_speed
CSmokeWallPuff__SpawnEntity( const Float: vecEnd[ 3 ], const Float: vecPlaneNormal[ 3 ], const Float: flScale = 0.5, const Float: flColor[ 3 ] = { 40.0, 40.0, 40.0 } )
{
static iMaxEntities; if ( !iMaxEntities ) iMaxEntities = global_get( glb_maxEntities );
if ( iMaxEntities - engfunc( EngFunc_NumberOfEntities ) <= LOWER_LIMIT_OF_ENTITIES )
return NULLENT;
new pSprite = rg_create_entity( "env_sprite" );
if ( is_nullent( pSprite ) )
return NULLENT;
new szSprite[ MAX_RESOURCE_PATH_LENGTH ]; formatex( szSprite, charsmax( szSprite ), "sprites/wall_puff%i.spr", random_num( 1, 4 ) );
new Float: vecEndPos[ 3 ]; xs_vec_add_scaled( vecEnd, vecPlaneNormal, 3.0, vecEndPos );
new Float: vecDirectory[ 3 ]; xs_vec_mul_scalar( vecPlaneNormal, random_float( 25.0, 30.0 ), vecDirectory );
set_entvar( pSprite, var_classname, "ent_smokepuff_x" );
set_entvar( pSprite, var_movetype, MOVETYPE_NOCLIP );
set_entvar( pSprite, var_framerate, float( engfunc( EngFunc_ModelFrames, engfunc( EngFunc_ModelIndex, szSprite ) ) ) );
set_entvar( pSprite, var_rendermode, kRenderTransAdd );
set_entvar( pSprite, var_rendercolor, flColor );
set_entvar( pSprite, var_renderamt, random_float( 100.0, 180.0 ) );
set_entvar( pSprite, var_scale, flScale );
set_entvar( pSprite, var_velocity, vecDirectory );
set_entvar( pSprite, var_origin, vecEndPos );
set_entvar( pSprite, var_last_time, get_gametime( ) );
set_entvar( pSprite, var_nextthink, get_gametime( ) );
engfunc( EngFunc_SetModel, pSprite, szSprite );
SetThink( pSprite, "CSmokeWallPuff__Think" );
return pSprite;
}
public CSmokeWallPuff__Think( const pSprite )
{
if ( is_nullent( pSprite ) )
return;
static Float: flFrame; flFrame = get_entvar( pSprite, var_frame );
static Float: flFrameRate; flFrameRate = get_entvar( pSprite, var_framerate );
static Float: flLastTime; flLastTime = get_entvar( pSprite, var_last_time );
static Float: flGameTime; flGameTime = get_gametime( );
flFrame += ( flFrameRate * ( flGameTime - flLastTime ) );
set_entvar( pSprite, var_frame, flFrame );
if ( flFrame >= flFrameRate )
{
UTIL_KillEntity( pSprite );
return;
}
static Float: vecVelocity[ 3 ]; get_entvar( pSprite, var_velocity, vecVelocity );
if ( flFrame > 7.0 )
{
xs_vec_mul_scalar( vecVelocity, 0.97, vecVelocity );
vecVelocity[ 2 ] += 0.7;
if ( vecVelocity[ 2 ] > 70.0 ) vecVelocity[ 2 ] = 70.0;
}
if ( flFrame > 6.0 )
{
static bool: bDirection[ 2 ] = { true, true };
static Float: flMagnitude[ 2 ];
for ( new i; i < 2; i++ )
{
flMagnitude[ i ] += 0.075;
if ( flMagnitude[ i ] > 5.0 ) flMagnitude[ i ] = 5.0;
if ( bDirection[ i ] ) vecVelocity[ i ] += flMagnitude[ i ];
else vecVelocity[ i ] -= flMagnitude[ i ];
if ( !random_num( 0, 10 ) && flMagnitude[ i ] > 3.0 )
{
flMagnitude[ i ] = 0.0;
bDirection[ i ] = !bDirection[ i ];
}
}
}
set_entvar( pSprite, var_velocity, vecVelocity );
set_entvar( pSprite, var_last_time, flGameTime );
set_entvar( pSprite, var_nextthink, flGameTime + 0.05 );
}
stock UTIL_KillEntity( const pEntity )
{
set_entvar( pEntity, var_flags, FL_KILLME );
set_entvar( pEntity, var_nextthink, get_gametime( ) );
SetThink( pEntity, "" );
}
native smoke_wallpuff_draw( const Float: vecEnd[ 3 ], const Float: vecPlaneNormal[ 3 ], const Float: flScale = 0.5, const Float: flColor[ 3 ] = { 40.0, 40.0, 40.0 } );
/* -> Dynamic Crosshair <- */
stock UTIL_IncreaseCrosshair( const pPlayer, const pItem, iFakePosition = 13, iFakeWeaponId = CSW_MAC10 )
{
if ( get_member( pPlayer, m_iFOV ) < 55 || get_member( pPlayer, m_iHideHUD ) & HIDEHUD_CROSSHAIR )
return;
static iMsgId_CurWeapon; if ( !iMsgId_CurWeapon ) iMsgId_CurWeapon = get_user_msgid( "CurWeapon" );
set_msg_block( iMsgId_CurWeapon, BLOCK_ONCE );
if ( rg_get_iteminfo( pItem, ItemInfo_iSlot ) != 0 )
{
new pWeapon = get_member( pPlayer, m_rgpPlayerItems, PRIMARY_WEAPON_SLOT );
if ( !is_nullent( pWeapon ) && get_member( pWeapon, m_iId ) == iFakeWeaponId )
iFakePosition = 12, iFakeWeaponId = CSW_XM1014;
}
UTIL_WeaponList( MSG_ONE, pPlayer, pItem, .iPosition = iFakePosition, .iWeaponId = iFakeWeaponId );
UTIL_CurWeapon( MSG_ONE, pPlayer, true, iFakeWeaponId, get_member( pItem, m_Weapon_iClip ) );
set_member( pItem, m_Weapon_flNextReload, get_gametime( ) + 0.04 );
}
stock UTIL_ResetCrosshair( const pPlayer, const pItem )
{
if ( get_member( pItem, m_Weapon_flNextReload ) && get_member( pItem, m_Weapon_flNextReload ) <= get_gametime( ) )
{
UTIL_CurWeapon( MSG_ONE, pPlayer, true, get_member( pItem, m_iId ), get_member( pItem, m_Weapon_iClip ) );
set_member( pItem, m_Weapon_flNextReload, 0.0 );
}
}
/* -> CurWeapon <- */
stock UTIL_CurWeapon( const iDest, const pPlayer, const bool: bIsActive, const iWeaponId, const iClipAmmo )
{
static iMsgId_CurWeapon; if ( !iMsgId_CurWeapon ) iMsgId_CurWeapon = get_user_msgid( "CurWeapon" );
message_begin( iDest, iMsgId_CurWeapon, .player = pPlayer );
write_byte( bIsActive );
write_byte( iWeaponId );
write_byte( iClipAmmo );
message_end( );
}
/* -> Weapon List <- */
stock UTIL_WeaponList( const iDest, const pPlayer, const pItem, const szWeaponName[ MAX_NAME_LENGTH ] = "", const iPrimaryAmmoType = -2, iMaxPrimaryAmmo = -2, iSecondaryAmmoType = -2, iMaxSecondaryAmmo = -2, iSlot = -2, iPosition = -2, iWeaponId = -2, iFlags = -2 )
{
new szBuffer[ sizeof szWeaponName ];
szWeaponName[ 0 ] == EOS ? rg_get_iteminfo( pItem, ItemInfo_pszName, szBuffer, charsmax( szBuffer ) ) : copy( szBuffer, charsmax( szBuffer ), szWeaponName );
static iMsgId_Weaponlist; if ( !iMsgId_Weaponlist ) iMsgId_Weaponlist = get_user_msgid( "WeaponList" );
message_begin( iDest, iMsgId_Weaponlist, .player = pPlayer );
write_string( szBuffer );
write_byte( ( iPrimaryAmmoType <= -2 ) ? get_member( pItem, m_Weapon_iPrimaryAmmoType ) : iPrimaryAmmoType );
write_byte( ( iMaxPrimaryAmmo <= -2 ) ? rg_get_iteminfo( pItem, ItemInfo_iMaxAmmo1 ) : iMaxPrimaryAmmo );
write_byte( ( iSecondaryAmmoType <= -2 ) ? get_member( pItem, m_Weapon_iSecondaryAmmoType ) : iSecondaryAmmoType );
write_byte( ( iMaxSecondaryAmmo <= -2 ) ? rg_get_iteminfo( pItem, ItemInfo_iMaxAmmo2 ) : iMaxSecondaryAmmo );
write_byte( ( iSlot <= -2 ) ? rg_get_iteminfo( pItem, ItemInfo_iSlot ) : iSlot );
write_byte( ( iPosition <= -2 ) ? rg_get_iteminfo( pItem, ItemInfo_iPosition ) : iPosition );
write_byte( ( iWeaponId <= -2 ) ? rg_get_iteminfo( pItem, ItemInfo_iId ) : iWeaponId );
write_byte( ( iFlags <= -2 ) ? rg_get_iteminfo( pItem, ItemInfo_iFlags ) : iFlags );
message_end( );
}
stock bool:is_weekend(&day = 0)
{
new szTime[3];
get_time("%u", szTime, charsmax(szTime));
if (!(1 < (day = str_to_num(szTime)) < 7))
return true;
return false;
}
if (is_weekend()) {
// your code
}
new iDay;
is_weekend(iDay);
if (iDay == 6) {
// its saturday
}
if (iDay == 7) {
// its sunday
}
Можно условие лаконичнее сделать, но не обязательноISO 8601 weekday as number with Monday as 1 (1-7)
#define ClearEnumData(%0,%1) {new __clear%1; %0 = __clear;}
// Пример
enum _AuthTypeData
{
iTotalConnectAuth,
Float: fTotalTimeInGameAuth,
iNewPlayerAuth,
iOrdinaryPlayerAuth,
iRegularPlayerAuth,
iRejectionPlayerAuth
}
new g_AuthTypeData[client_auth_type][_AuthTypeData];
public clear_enum()
{
ClearEnumData(g_AuthTypeData, [client_auth_type][_AuthTypeData]) // Очистит всё
ClearEnumData(g_AuthTypeData[CA_TYPE_REVEMU], [_AuthTypeData]) // Очистит всё только в CA_TYPE_REVEMU
}
/*
// [ PVS = Potential Visibility Set ]
// Функция проверяет, видит ли обьект координаты.
// iEntity -> Объект.
// Float: vecViewOrigin[3] -> Проверяемые координаты.
// fRadius -> Радиус, в котором будет проверка. 0.0 - радиус проверяться не будет.
// fFovMultiply -> Множитель FOV. Лучше не трогать. Влияет на смещение в сторону самого fCustomFov.
// iCheckFractionType -> Чтоб проверялось и то, чтоб начальная координата (объекта) доходила до конечно точки.
// fCustomFov -> Установка своего диапазона обзора (FOV - Поле зрения). Она и есть радиус охвата.
// @return:
// 1 => OK. Объект видит координаты.
// 0 => FAILED. Большой радиус.
// -1 => FAILED. Координаты за спиной игрока, он их не видит.
// -2 => FAILED. Игрок видит координаты, но они спрятаны за преградой.
// NOTE:
// iCheckFractionType: 0 - проверки на касание не будет. 1 - игнорировать существ. 2 - существа игнорироваться не будут.
// fCustomFov = 70.0 - видимость в половину модели (короче, 180 градусов)
*/
stock EntityCheckPVS(
iEntity,
Float:vecViewOrigin[3],
Float:fRadius = 0.0,
Float:fFovMultiply = 30.0,
iCheckFractionType = 0,
Float:fCustomFov = 0.0
) {
static Float:vecOrigin[2][3];
get_entvar(iEntity, var_origin, vecOrigin[0]);
xs_vec_copy(vecViewOrigin, vecOrigin[1])
if(fRadius != 0.0 && get_distance_f(vecOrigin[0], vecOrigin[1]) >= fRadius) { return 0; }
static Float:vecAngle[3], Float:glbvecForward[3];
get_entvar(iEntity, var_angles, vecAngle);
engfunc(EngFunc_MakeVectors, vecAngle);
angle_vector(vecAngle, ANGLEVECTOR_FORWARD, glbvecForward);
static Float:vecViewOfs[3];
get_entvar(iEntity, var_view_ofs, vecViewOfs);
xs_vec_add(vecOrigin[0], vecViewOfs, vecOrigin[0]);
static Float:fFov;
if(fCustomFov == 0.0) {
if(iEntity <= MAX_PLAYERS) { fFov = floatcos(float(get_entvar(iEntity, var_fov) / 2), degrees) * fFovMultiply; }
else { fFov = floatcos(45.0, degrees) * fFovMultiply; }
} else { fFov = floatcos(fCustomFov, degrees) * fFovMultiply; }
xs_vec_sub(vecOrigin[1], vecOrigin[0], vecOrigin[1]);
if(xs_vec_dot(vecOrigin[1], glbvecForward) < fFov) { return -1; }
if(iCheckFractionType) {
engfunc(EngFunc_TraceLine, vecOrigin[0], vecOrigin[1], iCheckFractionType == 1 ? IGNORE_MONSTERS : DONT_IGNORE_MONSTERS, iEntity, 0);
static Float:fFraction;
get_tr2(0, TR_flFraction, fFraction);
if(fFraction != 1.0) { return -2; }
}
return 1;
}
{
static Float:vecOrigin[3]; get_entvar(iAttacker, var_origin, vecOrigin);
if(EntityCheckPVS(iVictim, vecOrigin, 80.0, _, 0, 70.0) != 1) { return HAM_IGNORED; }
}
stock FindEntityByPVS(iEntity, &iFindEntity, Float:fRadius = 160.0, Float:fCustomFov = 70.0, iCheckFractionType = 0) {
static Float:vecOrigin[3], Float:vecEnemyOrigin[3];
get_entvar(iEntity, var_origin, vecOrigin);
while((iFindEntity = engfunc(EngFunc_FindEntityInSphere, iFindEntity, vecOrigin, fRadius))) {
if(is_nullent(iFindEntity)) { continue; }
get_entvar(iFindEntity, var_origin, vecEnemyOrigin);
if(EntityCheckPVS(iEntity, vecEnemyOrigin, _, _, iCheckFractionType, fCustomFov) != 1) { continue; }
return iFindEntity;
}
return (iFindEntity = 0);
}
@PVS(pId) {
static iEntity, szBuffer[128], iLen; iEntity = 0;
iLen = formatex(szBuffer, charsmax(szBuffer), "Enemy: ^n");
while((iEntity = FindEntityByPVS(pId, iEntity, 320.0))) {
if(!is_user_alive(iEntity) || iEntity == pId) { continue; }
iLen += formatex(szBuffer[iLen], charsmax(szBuffer) - iLen, "[%n] %s - HP: %0.f^n", iEntity,
get_user_team(pId) == get_user_team(iEntity) ? "СОЮЗНИК" : "ВРАГ",
Float:get_entvar(iEntity, var_health));
}
show_menu(pId, (1<<9), szBuffer);
}
Компилятор ругаться не будет на оператор присваивания в условии?return (iFindEntity = 0);
И как по-твоему он должен понять о чём именно ты, когда даже ссылку на пост не оставил?Garey, а есть полностью рабочий пример?
stock bool:is_point_at_player_eyes(const id, Float:fPoint[3], Float:fDist = 16.0)
{
new iOriginStart[3];
get_user_origin( id, iOriginStart, Origin_Eyes );
new Float:fOriginStart[ 3 ];
IVecFVec( iOriginStart, fOriginStart );
new iOriginEnd[3];
get_user_origin( id, iOriginEnd, Origin_AimEndEyes );
new Float:fOriginEnd[ 3 ];
IVecFVec( iOriginEnd, fOriginEnd );
new fMaxDistance = floatround(get_distance_f(fOriginStart,fOriginEnd));
new fCurDistance = floatround(get_distance_f(fOriginStart,fPoint));
if (fCurDistance > fMaxDistance - fDist)
{
return false;
}
new Float:fVelocityValue[ 3 ];
velocity_by_aim( id, fCurDistance, fVelocityValue );
new Float:fTargetEyesOrigin[ 3 ];
xs_vec_add( fOriginStart, fVelocityValue, fTargetEyesOrigin );
return get_distance_f(fTargetEyesOrigin,fPoint) < fDist;
}
stock bool:is_ent_at_player_eyes(const id, const ent, Float:fDist = 16.0)
{
new Float:fOriginEnt[3];
get_entvar(ent,var_origin,fOriginEnt);
return is_point_at_player_eyes(id,fOriginEnt,fDist);
}
public WeatherBoxThink(ent)
{
if(!pev_valid(ent))
return;
switch(pev(ent, pev_impulse))
{
case CREATE:
{
LieFlat(ent);
set_pev(ent, pev_impulse, SHOW);
}
case SHOW:
{
new Float:fMaxAmount = 127.0;
if(pev(ent, pev_renderamt) >= fMaxAmount)
{
set_pev(ent, pev_impulse, DEL);
set_pev(ent, pev_nextthink, get_gametime() + LIFE_MODEL_TIME);
return;
}
else
{
set_pev(ent, pev_renderamt, floatmin(fMaxAmount, pev(ent, pev_renderamt) + DELETE_MODEL_TIME));
}
}
case DEL:
{
if(pev(ent, pev_renderamt) > 0.0)
{
set_pev(ent, pev_renderamt, floatmax(0.0, pev(ent, pev_renderamt) - DELETE_MODEL_TIME));
}
else
{
set_pev(ent, pev_flags, FL_KILLME);
}
}
}
set_pev(ent, pev_nextthink, get_gametime() + 0.1)
}