Доброго времени суток. Вообщем сегодня увидел такую штуку, что начала в логах какать вот таким:
Код:
L 11/21/2015 - 19:30:37: Start of error session.
L 11/21/2015 - 19:30:37: Info (map "35hp_2") (file "addons/amxmodx/logs/error_22.log")
L 11/21/2015 - 19:30:37: Invalid player id 230
L 11/21/2015 - 19:30:37: [AMXX] Displaying debug trace (plugin "trainkiller.amxx")
L 11/21/2015 - 19:30:37: [AMXX] Run time error 10: native error (native "get_user_weapon")
L 11/21/2015 - 19:30:37: [AMXX] [0] trainkiller.sma::Ham_CBasePlayer_Killed (line 94)
Исходник:
Код:
#include < amxmodx >
#include < fakemeta >
#include < engine >
#include < cstrike >
#include < hamsandwich >
#include < xs >
new g_szPluginInfo[ 3 ][ 13 ] = { "Train Killer", "1.0", "Pastout!" }
#define m_LastHitGroup 75
#define MarkUserConnection(%0) g_bitConnection |= ( 1 << ( %0&31 ) )
#define ClearUserConnection(%0) g_bitConnection &= ~( 1 << ( %0&31 ) )
#define GetUserConnection(%0) g_bitConnection & ( 1 << ( %0&31 ) )
#define CLAMP_SHORT(%1) clamp( %1, 0, 0xFFFF )
#define CLAMP_BYTE(%1) clamp( %1, 0, 0xFF )
new const g_szTrackTrain[ ] = "tracktrain"
new const g_szTrainSound[ ] = "trainer.wav"
new g_iMsgDeathMsg, g_iMsgSetFov, g_iMsgScreenFade
new Float:g_iFeet = 35.0
new g_pCvarSound,
g_pCvarPunishment, g_pCvarAllowedKillAngle
new g_bitConnection
new Trie:g_iPunishMethods
enum PunishMethod {
Punish_Off,
Punish_Slay,
Punish_Slap,
Punish_Drug,
Punish_Blind
}
public plugin_init( ) {
register_plugin( g_szPluginInfo[ 0 ], g_szPluginInfo[ 1 ], g_szPluginInfo[ 2 ] )
register_cvar( g_szTrackTrain, g_szPluginInfo[ 1 ], FCVAR_SERVER | FCVAR_SPONLY )
g_pCvarSound = register_cvar( "train_sound", "0" )
g_pCvarPunishment = register_cvar( "train_punishment", "kill" )
g_pCvarAllowedKillAngle = register_cvar( "train_killangle", "145" )
g_iPunishMethods = TrieCreate( )
TrieSetCell( g_iPunishMethods, "no", Punish_Off )
TrieSetCell( g_iPunishMethods, "off", Punish_Off )
TrieSetCell( g_iPunishMethods, "none", Punish_Off )
TrieSetCell( g_iPunishMethods, "slay", Punish_Slay )
TrieSetCell( g_iPunishMethods, "kill", Punish_Slay )
TrieSetCell( g_iPunishMethods, "slap", Punish_Slap )
TrieSetCell( g_iPunishMethods, "smack", Punish_Slap )
TrieSetCell( g_iPunishMethods, "drug", Punish_Drug )
TrieSetCell( g_iPunishMethods, "dope", Punish_Drug )
TrieSetCell( g_iPunishMethods, "blind", Punish_Blind )
TrieSetCell( g_iPunishMethods, "sightless", Punish_Blind )
g_iMsgDeathMsg = get_user_msgid( "DeathMsg" )
g_iMsgSetFov = get_user_msgid( "SetFOV" )
g_iMsgScreenFade = get_user_msgid( "ScreenFade" )
new g_szPlayer[ ] = "player"
RegisterHam( Ham_Killed, g_szPlayer, "Ham_CBasePlayer_Killed", .Post = false )
}
public plugin_precache( )
precache_sound( g_szTrainSound )
public client_putinserver( id )
MarkUserConnection( id )
public client_disconnect( id )
ClearUserConnection( id )
public plugin_pause( )
Check_Connections( false )
public plugin_unpause( )
Check_Connections( true )
public Check_Connections( bool:g_bPluginStatus ) {
static iPlayers[ 32 ], iNum
get_players( iPlayers, iNum )
for( new i = 0; i < iNum; i++ )
g_bPluginStatus ? ( MarkUserConnection( iPlayers[ i ] ) ) : ( ClearUserConnection( iPlayers[ i ] ) )
}
public Ham_CBasePlayer_Killed( iVictim, iKiller ) {
if( GetUserConnection( iVictim )
&& GetUserConnection( iKiller )
&& get_user_weapon( iKiller ) == CSW_KNIFE )
{
new g_iOriginV[ 3 ], g_iOriginP[ 3 ]
get_user_origin( iVictim, g_iOriginV )
new flDistance, g_RoundDistance
new bool:g_iHasBeenTrained = false
new g_iPlayers[ 32 ], iPlayer, iNum
get_players( g_iPlayers, iNum, "a" )
for ( new i=0; i < iNum; i++ )
{
iPlayer = g_iPlayers[ i ]
if( iPlayer == iKiller || iPlayer == iVictim )
continue
get_user_origin( iPlayer, g_iOriginP )
flDistance = get_distance( g_iOriginV, g_iOriginP )
g_RoundDistance = floatround( flDistance/g_iFeet )
//Print( 0, "Angle of kill: %.f", getPlayersAngle_B( iKiller, iVictim, iPlayer ) )
if( cs_get_user_team( iPlayer ) == cs_get_user_team( iVictim )
&& g_RoundDistance <= 1
&& getPlayersAngle_B( iKiller, iVictim, iPlayer ) > clamp( get_pcvar_num( g_pCvarAllowedKillAngle ), 0, 180 ) )
{
static szNameVic[ 32 ]; get_user_name( iVictim, szNameVic, charsmax( szNameVic ) )
static szNameTrain[ 32 ]; get_user_name( iPlayer, szNameTrain, charsmax( szNameTrain ) )
static szNameKiller[ 32 ]; get_user_name( iKiller, szNameKiller, charsmax( szNameKiller ) )
static PunishMethod:g_PunishMethod
g_PunishMethod = GetPunishMethod( )
switch( g_PunishMethod )
{
case Punish_Slay:
{
user_kill( iPlayer, 1 )
}
case Punish_Slap:
{
user_slap( iPlayer, 1 )
set_task( 1.0, "PunishSlap", iPlayer, _, _, "a", 4 )
}
case Punish_Drug:
{
message_begin( MSG_ONE, g_iMsgSetFov, { 0, 0, 0 }, iPlayer )
write_byte( 180 )
message_end( )
set_task( 10.0, "PunishDrugReset", iPlayer )
}
case Punish_Blind:
{
UTIL_ScreenFade( iPlayer, 6.0, 10.0 )
}
}
g_iHasBeenTrained = true
}
}
if( g_iHasBeenTrained )
{
if( !!get_pcvar_num( g_pCvarSound ) )
emit_sound( iKiller, CHAN_STATIC, g_szTrainSound, 1.0, ATTN_NORM, 0, PITCH_NORM )
set_msg_block( g_iMsgDeathMsg, BLOCK_ONCE )
message_begin( MSG_ALL, g_iMsgDeathMsg )
write_byte( iKiller )
write_byte( iVictim )
write_byte( get_pdata_int( iVictim, m_LastHitGroup, 5 ) == HIT_HEAD ? 1 : 0 )
write_string( g_szTrackTrain )
message_end( )
g_iHasBeenTrained = false
}
}
}
stock Float:getPlayersAngle_B( playerA, playerB, playerC ) {
// 1. Grab position of all players (ignore Z positions)
new Float:vecOriginA[ 3 ], Float:vecOriginB[ 3 ],
Float:vecOriginC[ 3 ]
entity_get_vector( playerA, EV_VEC_origin, vecOriginA )
entity_get_vector( playerB, EV_VEC_origin, vecOriginB )
entity_get_vector( playerC, EV_VEC_origin, vecOriginC )
vecOriginA[ 2 ] = vecOriginB[ 2 ] = vecOriginC[ 2 ] = 0.0
// 2. Grab the line vectors for all sides
new Float:vecLineAB[ 3 ], Float:vecLineBC[ 3 ],
Float:vecLineAC[ 3 ]
xs_vec_sub( vecOriginA, vecOriginB, vecLineAB )
xs_vec_sub( vecOriginB, vecOriginC, vecLineBC )
xs_vec_sub( vecOriginA, vecOriginC, vecLineAC )
// 3. Grab the length of each side we'll need
new Float:flLineAB = vector_length( vecLineAB ), Float:flLineBC = vector_length( vecLineBC ),
Float:flLineAC = vector_length( vecLineAC )
// 4. Use the law of cosines to find the angle of B
// cos B = (AB^2 + BC^2 - AC^2) / 2(AB)(BC)
// B = acos (AB^2 + BC^2 - AC^2) / 2(AB)(BC)
return floatacos( ( flLineAB * flLineAB + flLineBC * flLineBC - flLineAC * flLineAC ) / ( 2 * flLineAB * flLineBC ), degrees )
}
PunishMethod:GetPunishMethod( ) {
new methodString[ 32 ], PunishMethod:method;
get_pcvar_string( g_pCvarPunishment, methodString, charsmax( methodString ) )
if( is_str_num( methodString ) )
{
method = PunishMethod:str_to_num( methodString )
if( !( Punish_Off <= method < PunishMethod ) )
method = GetDefaultPunishMethod( )
} else {
strtolower( methodString )
if( !TrieGetCell( g_iPunishMethods, methodString, method ) )
method = GetDefaultPunishMethod( )
}
return method
}
PunishMethod:GetDefaultPunishMethod( ) {
set_pcvar_string( g_pCvarPunishment, "off" )
return Punish_Off;
}
public PunishSlap( iClient )
if( GetUserConnection( iClient ) )
user_slap( iClient, 1 )
public PunishDrugReset( iClient ) {
if( GetUserConnection( iClient ) )
{
message_begin( MSG_ONE, g_iMsgSetFov, { 0, 0, 0 }, iClient )
write_byte( 90 )
message_end( )
}
}
UTIL_ScreenFade( iClient, Float:fDuration, Float:fHoldTime ) {
message_begin( MSG_ONE_UNRELIABLE, g_iMsgScreenFade, _, iClient )
write_short( CLAMP_SHORT( floatround( 4096 * fDuration ) ) )
write_short( CLAMP_SHORT( floatround( 4096 * fHoldTime ) ) )
write_short( 0x0000 )
write_byte( 0 )
write_byte( 0 )
write_byte( 0 )
write_byte( 255 )
message_end( )
}
Что-то голову ломал сидел, сидел, в итоге так и не понял почему он ругается на "get_user_weapon"..
Может быть кто-то подскажет в чем проблема?