Есть такой плагин как knife-realism
https://forums.alliedmods.net/showthread.php?t=236720так как я не могу там написать , прошу помощи тут , исправить ошибки в логах
Код:
/*
Blizzards Plugins Comply With GNU General Public License
Knife Realism is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Under no circumstances are you allowed to redistribute and/or modify
it claming that you are the original author of such plugin/modification.
Knife Realism is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Knife Realism 2014
==================
Plugin Thread
-------------
https://forums.alliedmods.net/showthread.php?t=236720
Description
-----------
This Plugin Adds More Realism With Knife Attacks.
When A Player Attacks With Knife, There Knife and Hands Will Get Coverd In Blood And Drip Blood Onto Floor.
The Victim Will Also Drip Blood And Spray Blood ( If Set In Cvar ).
You Can Set A Timeout Feature Where After "X" Amount of Secs The Blood And Or Spray Effects Will Stop.
You Can Also Set The Knife To Reset Back To Default Knife ( Without Blood ) In The Same Timeout Feature ( If Set In Cvar ).
EveryTime The Attacker Knifes The Same Person Or Another The Timeout Feature Gets "X" Added To It So The Effect Stays Active While Your Continuing Attacking.
So Basicly The Timeout Feature Starts To Countdown From Last Knife Attack On Victim.
Cvars
-----
amx_kr_timeout "10" // Secs.
amx_kr "abce" // Default
// "a" Victim Bleeds
// "b" Attacker Knife Drips
// "c" Victim Blood Sprays
// "d" Attacker Blood Sprays
// "e" Blood Effects Timeout
// "f" KR Works With FriendlyFire ( when mp_friendlyfire set to 1 )
// "g" Remove Bloody Knife At Timeout Also
ToDo/Ideas
----------
None?
Credits
-------
jtp10181 - Bleeding Snippet( Ultimate Gore Plugin )
ChangeLog
---------
Tuesday 14/10/2014
- v0.0.6 - [ CHANGED ] OFFSET_WEAPONOWNER to suggested m_pPlayer
Cached get_user_team in TakeDamage
now call get_kr_flags in correct check
changed TE_BLOODSTREAM broadcast to MSG_PVS
Removed plugin_cfg forward
Added Support For Pause/Unpause
edited szFlags buffer down from 24 to 7
Tuesday 14/10/2014
- v0.0.5 - [ CHANGED ] Removed NewRound Replaced With Plugin_Cfg
Replaced CSW_KNIFE check with xmod_is_melee_wpn
Sunday 16/03/2014
- v0.0.4 - [ FIXED ] Fixed Bug of knife model being set on guns.
- v0.0.3 - [ CHANGED ] Attackers Knife Now Stays Bloody Till Death/New Round By Default.
Timeout Feature Now Starts Counting Down From Last Attack.
Added Support For CZ With Blood Decals ( Any Bugs Let Me Know ).
Wednesday 12/03/2014
- v0.0.2 - [ CHANGED ] victim bleeds
victim blood sprays
attacker knife drips
attacker knife sprays blood
[ NEW ] KR now works with Friendlyfire when enabled.
Monday 10/03/2014
- v0.0.1 - [ RELEASE ] Inital Release.
*/
#include < amxmodx >
#include < amxmisc >
#include < hamsandwich >
#include < fakemeta >
#include < engine >
#include < csx >
#pragma semicolon 1
#pragma reqclass xstats
#if !defined AMXMODX_NOAUTOLOAD
#pragma defclasslib xstats csx
#pragma defclasslib xstats dodx
#pragma defclasslib xstats tfcx
#pragma defclasslib xstats tsx
#endif
#define PLUGIN "Knife Realism"
#define VERSION "0.0.6"
#define AUTHOR "Blizzard_87"
#define cm(%0) ( sizeof(%0) - 1 )
#define BitSet(%0,%1) ( %0 |= ( 1 << ( %1 & 31 ) ) )
#define BitClear(%0,%1) ( %0 &= ~( 1 << ( %1 & 31 ) ) )
#define BitCheck(%0,%1) ( %0 & ( 1 << ( %1 & 31 ) ) )
#define KR_VBLEEDS ( 1<<0 ) // "a" Victim Bleeds
#define KR_ABLEEDS ( 1<<1 ) // "b" Attacker Bleeds
#define KR_VSPRAYS ( 1<<2 ) // "c" Victim Sprays
#define KR_ASPRAYS ( 1<<3 ) // "d" Attacker Sprays
#define KR_BETIMEOUT ( 1<<4 ) // "e" Bleeding Effects Timeout
#define KR_FRIENDLYFIRE ( 1<<5 ) // "f" KR Works With FriendlyFired
#define KR_BLOODYKNIFE ( 1<<6 ) // "g" Remove Bloody Knife At Timeout Also
new BitBloodSpray, BitBloodDrip, BitBloodKnife;
// Constants
new const g_szDefault_V_Model[ ] = { "models/v_knife.mdl" };
new const g_szDefault_P_Model[ ] = { "models/p_knife.mdl" };
new const g_szKnife_V_Model[ ] = { "models/knife-realism/v_knife.mdl" };
new const g_szKnife_P_Model[ ] = { "models/knife-realism/p_knife.mdl" };
const m_pPlayer = 41;
const XO_WEAPON = 4;
// HamHooks
new HamHook:_CBasePlayer_TakeDamage_P;
new HamHook:_OnCBasePlayerWeapon_Deploy_P;
new HamHook:_CBasePlayer_Spawn_P;
new HamHook:_CBasePlayer_Killed_P;
// Strings
new g_szGameMod[ 32 ];
// Cvars
new g_pTimer, g_pKrBits, g_pFriendlyFire;
// Integers
new g_iFriendlyFire, g_iPlayerTimer[ 33 ], g_iTimer, g_iBloodIndex;
public plugin_precache( )
{
precache_model( g_szKnife_V_Model );
precache_model( g_szKnife_P_Model );
precache_model( g_szDefault_V_Model );
precache_model( g_szDefault_P_Model );
g_iBloodIndex = engfunc( EngFunc_DecalIndex, "{blood1" );
}
public plugin_init( )
{
register_plugin( PLUGIN, VERSION, AUTHOR );
register_cvar( "knife_realism_version", VERSION, FCVAR_SERVER|FCVAR_SPONLY );
get_modname( g_szGameMod, cm( g_szGameMod ) );
// Register Ham
_CBasePlayer_TakeDamage_P = RegisterHam( Ham_TakeDamage, "player", "CBasePlayer_TakeDamage_P", .Post = 1 );
_OnCBasePlayerWeapon_Deploy_P = RegisterHam( Ham_Item_Deploy, "weapon_knife", "OnCBasePlayerWeapon_Deploy_P", .Post = 1 );
_CBasePlayer_Spawn_P = RegisterHam( Ham_Spawn, "player", "CBasePlayer_Spawn_P", .Post = 1 );
_CBasePlayer_Killed_P = RegisterHam( Ham_Killed, "player", "CBasePlayer_Killed_P", .Post = 1 );
// Register Cvars
g_pTimer = register_cvar( "amx_kr_timeout", "10" ); // How Many Secs Before Timeout
g_pKrBits = register_cvar( "amx_kr", "abceg" );
// Cvar Pointers
g_pFriendlyFire = get_cvar_pointer( "mp_friendlyfire" );
// Cache Cvars
g_iTimer = get_pcvar_num( g_pTimer );
g_iFriendlyFire = get_pcvar_num( g_pFriendlyFire );
}
public plugin_natives()
{
set_module_filter("module_filter");
set_native_filter("native_filter");
}
public module_filter(const module[])
{
if (equal(module, "xstats") && !(cstrike_running() || equal(g_szGameMod,"dod") || equal(g_szGameMod,"tfc") || equal(g_szGameMod,"ts")))
{
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public CBasePlayer_Spawn_P( index )
{
Remove_BloodKnife( index );
Remove_Bleeding( index );
}
public CBasePlayer_TakeDamage_P( index, iInflictor, iAttacker, Float:Dmg, Damage_Type )
{
if( iAttacker && xmod_is_melee_wpn( get_user_weapon( iAttacker ) ) )
{
new vTeam = get_user_team( index );
new aTeam = get_user_team( iAttacker );
if( vTeam != aTeam )
{
Set_KnifeRealism( index, iAttacker );
}
else if( vTeam == aTeam )
{
new iFlags = get_kr_flags( );
if( iFlags & KR_FRIENDLYFIRE )
{
if( g_iFriendlyFire )
{
Set_KnifeRealism( index, iAttacker );
}
}
}
}
}
public CBasePlayer_Killed_P( index )
{
Remove_BloodKnife( index );
Remove_Bleeding( index );
remove_task( index );
}
public OnCBasePlayerWeapon_Deploy_P( ent )
{
new iOwner = get_pdata_cbase( ent, m_pPlayer, XO_WEAPON);
if( BitCheck( BitBloodKnife, iOwner ) )
{
SetKnife( iOwner, true );
}
else
{
SetKnife( iOwner, false );
}
}
public Event_PlayerBleed( index )
{
new iOrigin[ 3 ], iFlags = get_kr_flags( );
get_user_origin( index, iOrigin );
if( BitCheck( BitBloodSpray, index ) )
{
FX_BloodStream( iOrigin );
}
if( BitCheck( BitBloodDrip, index ) )
{
FX_KnifeDrip( iOrigin);
}
if( iFlags & KR_BETIMEOUT && g_iPlayerTimer[ index ] <= get_systime( ) )
{
Remove_Bleeding( index );
if( iFlags & KR_BLOODYKNIFE )
{
Remove_BloodKnife( index );
}
}
}
public get_kr_flags( )
{
new szFlags[ 7 ];
get_pcvar_string( g_pKrBits, szFlags, cm( szFlags ) );
return read_flags( szFlags );
}
public plugin_pause( )
{
DisableHamForward( _CBasePlayer_TakeDamage_P );
DisableHamForward( _OnCBasePlayerWeapon_Deploy_P );
DisableHamForward( _CBasePlayer_Spawn_P );
DisableHamForward( _CBasePlayer_Killed_P );
new iPlayers[ 32 ], iNum, i, Players;
get_players( iPlayers, iNum );
for( i = 0; i < iNum; i++ )
{
Players = iPlayers[ i ];
Remove_BloodKnife( Players );
Remove_Bleeding( Players );
remove_task( Players );
}
}
public plugin_unpause( )
{
EnableHamForward( _CBasePlayer_TakeDamage_P );
EnableHamForward( _OnCBasePlayerWeapon_Deploy_P );
EnableHamForward( _CBasePlayer_Spawn_P );
EnableHamForward( _CBasePlayer_Killed_P );
}
/*-------------------------------
- Private Functions -
-------------------------------*/
Set_KnifeRealism( index, iAttacker )
{
new iFlags = get_kr_flags( );
// Sets Blood Knife For Attacker
if( !BitCheck( BitBloodKnife, iAttacker ) )
{
SetKnife( iAttacker, true );
}
// Checks Victims Knife Realism
if( !BitCheck( BitBloodDrip, index ) || !BitCheck( BitBloodSpray, index ) )
{
if( iFlags & KR_VBLEEDS ) BitSet( BitBloodDrip, index );
if( iFlags & KR_VSPRAYS ) BitSet( BitBloodSpray, index );
set_task( random_float( 1.0, 1.5 ), "Event_PlayerBleed", index, "", 0, "b" );
}
// Checks Attackers Knife Realism
if( !BitCheck( BitBloodDrip, iAttacker ) || !BitCheck( BitBloodSpray, iAttacker ) )
{
if( iFlags & KR_ABLEEDS ) BitSet( BitBloodDrip, iAttacker );
if( iFlags & KR_ASPRAYS ) BitSet( BitBloodSpray, iAttacker );
set_task( random_float( 1.0, 1.5 ), "Event_PlayerBleed", iAttacker, "", 0, "b" );
}
// If Bleeding Effects Timeout Active This Sets The Times
if( iFlags & KR_BETIMEOUT )
{
g_iPlayerTimer[ index ] = get_systime( g_iTimer );
g_iPlayerTimer[ iAttacker ] = get_systime( g_iTimer );
// Sets Countdown Time From The Last Knife Attack
}
}
SetKnife( index, bBlood = true )
{
if( bBlood )
{
set_pev( index, pev_viewmodel2, g_szKnife_V_Model );
set_pev( index, pev_weaponmodel2, g_szKnife_P_Model );
BitSet( BitBloodKnife, index );
}
else
{
set_pev( index, pev_viewmodel2, g_szDefault_V_Model );
set_pev( index, pev_weaponmodel2, g_szDefault_P_Model );
BitClear( BitBloodKnife, index );
}
}
Remove_BloodKnife( index )
{
if( BitCheck( BitBloodKnife, index ) )
{
if( get_user_weapon( index ) == CSW_KNIFE )
{
SetKnife( index, false );
}
else
{
BitClear( BitBloodKnife, index );
}
}
}
Remove_Bleeding( index )
{
if( BitCheck( BitBloodDrip, index ) || BitCheck( BitBloodSpray, index ) )
{
BitClear( BitBloodDrip, index );
BitClear( BitBloodSpray, index );
remove_task( index );
}
}
// Bleeding Effects
FX_BloodStream( origin [ 3 ] )
{
message_begin( MSG_PVS, SVC_TEMPENTITY );
write_byte( TE_BLOODSTREAM );
write_coord( origin[ 0 ] );
write_coord( origin[ 1 ] );
write_coord( origin[ 2 ] + 2 );
write_coord( random_num( -360,360 ) );
write_coord( random_num( -360,360 ) );
write_coord( -10 );
write_byte( 70 );
write_byte( random_num( 50,100 ) );
message_end();
}
FX_KnifeDrip( origin[ 3 ] )
{
message_begin( MSG_BROADCAST,SVC_TEMPENTITY );
write_byte( TE_WORLDDECAL );
write_coord( origin[ 0 ] );
write_coord( origin[ 1 ] );
write_coord( origin[ 2 ] - 36 );
write_byte( g_iBloodIndex - random_num( 0, 7 ) );
message_end( );
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang3081\\ f0\\ fs16 \n\\ par }
*/
Код
[AMXX] Run time error 19 (plugin "Knife-Realism.amxx") - debug not enabled!
[AMXX] Function not found: (null)
Invalid player id 109
[AMXX] Displaying debug trace (plugin "Knife-Realism.amxx")
[AMXX] Run time error 10: native error (native "get_user_weapon")
[AMXX] [0] Knife-Realism.sma::CBasePlayer_TakeDamage_P (line 215)
Отредактировал: Kasper55, - 23.5.2015, 1:06