PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <engine>
#include <hamsandwich>
#include <xs>
#define PLUGIN "NPC - Non Playar Character - Oyuncu Olmayan Karakter"
#define VERSION "1.0"
#define AUTHOR "peNgueN"
new bool: g_NpcOldu[ 512 ];
new const NpcClass[] = "entity_npc";
new const g_NpcIdleAnimations[] = { 1, 3, 4, 5, 6 };
new const g_NpcDamageAnimations[] = { 57,58, 59 };
new const g_NpcDeathAnimations[] = { 54, 55, 56, 49, 53, 51 };
new const g_NpcTalkAnimations[] = { 59, 60, 61, 62, 63 };
new npc_kan_spr, npc_kan_spr_sprey;
new const g_NpcModel[] = "models/hostageC.mdl";
new NpcSayisi;
new yuruyor = 1, gerisibende
public plugin_init()
{
register_plugin( PLUGIN, VERSION, AUTHOR );
register_clcmd( "say /npc", "NpcMenu" );
register_clcmd( "say_team /npc", "NpcMenu" );
RegisterHam( Ham_TakeDamage, "info_target", "fw_NpcTakeDamage" );
RegisterHam( Ham_Killed, "info_target", "fw_NpcKilled" );
RegisterHam( Ham_Think, "info_target", "fw_NpcThink" );
RegisterHam( Ham_TraceAttack, "info_target", "fw_NpcTraceAttack" );
RegisterHam( Ham_Touch, "info_target", "fw_NpcTouch" );
}
public plugin_precache( )
{
npc_kan_spr = precache_model( "sprites/blood.spr" );
npc_kan_spr_sprey = precache_model( "sprites/bloodspray.spr" );
precache_model( g_NpcModel );
}
public NpcMenu( id )
{
new iMenu[ 64 ];
formatex( iMenu, charsmax( iMenu ), "NPC - Oyuncu Olmayan Karakter" );
new menu = menu_create( iMenu, "NpcMenu_go" );
formatex( iMenu, charsmax( iMenu ), "\wNPC Olustur \y( Aim ile yer belirleyin )" );
menu_additem( menu, iMenu, "1" );
formatex( iMenu, charsmax( iMenu ), "\wNPC Kaldir \y( Aim ile secin )" );
menu_additem( menu, iMenu, "2" );
formatex( iMenu, charsmax( iMenu ), "\wButun NPC'leri Kaldir^n \y %d NPC Mevcut", NpcSayisi );
menu_additem( menu, iMenu, "3" );
menu_setprop( menu, MPROP_EXIT, MEXIT_ALL);
menu_setprop( menu, MPROP_EXITNAME, "\rCIKIS" );
menu_display(id, menu);
return PLUGIN_HANDLED;
}
public NpcMenu_go( id, menu, item )
{
if( item == MENU_EXIT )
{
menu_destroy( menu );
return PLUGIN_HANDLED;
}
new info[ 6 ], szName[ 64 ];
new access, callback;
menu_item_getinfo( menu, item, access, info, charsmax( info ), szName, charsmax( szName ), callback );
new key = str_to_num( info );
switch( key )
{
case 1:
{
if( !is_user_alive( id ) ) return PLUGIN_HANDLED;
NpcOlustur( id );
}
case 2:
{
if( !is_user_alive( id ) ) return PLUGIN_HANDLED;
new iEnt, Vucut, NPC[ 64 ];
get_user_aiming( id, iEnt, Vucut );
if ( is_valid_ent( iEnt ) )
{
entity_get_string( iEnt, EV_SZ_classname, NPC, charsmax( NPC ) );
if ( equal( NPC, NpcClass ) )
{
remove_entity( iEnt );
NpcSayisi--;
client_print( id, print_chat, "[NPC] Bir NPC Kaldirildi." );
}
}
}
case 3:
{
remove_entity_name( NpcClass );
NpcSayisi = 0;
client_print( id, print_chat, "[NPC] Butun NPC'ler Kaldirildi." );
}
}
menu_destroy(menu);
return PLUGIN_HANDLED;
}
public fw_NpcTouch( iEnt, id )
{
if( !is_user_alive( id ) )
return HAM_SUPERCEDE;
static Float: gametime, Float: Cooldown[ 32 ];
gametime = get_gametime();
if(gametime - 1.0 > Cooldown[ id ]) {
new NPC[ 64 ];
entity_get_string( iEnt, EV_SZ_classname, NPC, charsmax( NPC ) );
if( equali( NPC, NpcClass ) ) {
Util_PlayAnimation( iEnt, g_NpcTalkAnimations[ random( sizeof g_NpcTalkAnimations ) ] );
}
Cooldown[ id ] = gametime;
}
return HAM_IGNORED;
}
public fw_NpcTakeDamage( iEnt, inflictor, attacker, Float:damage, bits ) {
new NPC[ 64 ];
entity_get_string( iEnt, EV_SZ_classname, NPC, charsmax( NPC ) );
if( equali( NPC, NpcClass ) ) {
Util_PlayAnimation( iEnt, g_NpcDamageAnimations[ random( sizeof g_NpcDamageAnimations ) ], 1.25 );
}
}
public fw_NpcKilled( iEnt, Killer ){
new NPC[ 64 ];
entity_get_string( iEnt, EV_SZ_classname, NPC, charsmax( NPC ) );
if( equali( NPC, NpcClass ) ) {
g_NpcOldu[ iEnt ] = true;
Util_PlayAnimation(iEnt, g_NpcDeathAnimations[ random( sizeof g_NpcDeathAnimations ) ] );
entity_set_int( iEnt, EV_INT_solid, SOLID_NOT );
entity_set_int( iEnt, EV_INT_deadflag, DEAD_DEAD );
entity_set_float(iEnt, EV_FL_takedamage, 0.0 );
client_print( Killer, print_chat, "[NPC] NPC'yi oldurdunuz." );
set_task( 5.0, "NpcOluyuKaldir", iEnt );
}
return HAM_SUPERCEDE;
}
public NpcOluyuKaldir( Npc ) {
remove_entity( Npc );
}
public fw_NpcThink( iEnt ) {
if( !is_valid_ent( iEnt ) )
return HAM_SUPERCEDE;
new NPC[ 64 ];
entity_get_string( iEnt, EV_SZ_classname, NPC, charsmax( NPC ) );
if( !equali( NPC, NpcClass ) )
return HAM_SUPERCEDE;
if( g_NpcOldu[ iEnt ] )
return HAM_SUPERCEDE;
if(yuruyor == 0) {
Util_PlayAnimation(iEnt, g_NpcIdleAnimations[ random( sizeof g_NpcIdleAnimations ) ] );
}
if(yuruyor == 1) {
UselessFunction(iEnt)
if(gerisibende == 0) {
Util_PlayAnimation(iEnt,13)
set_task(0.7,"dbnde",iEnt)
}
}
if(yuruyor == 0) {
entity_set_float( iEnt, EV_FL_nextthink, get_gametime() + 5.0 );
}
if(yuruyor == 1) {
entity_set_float( iEnt, EV_FL_nextthink, get_gametime() + 0.7 );
}
return HAM_IGNORED;
}
public dbnde(iEnt) {
gerisibende = 1
Util_PlayAnimation(iEnt,13)
set_task(0.7,"dbnde",iEnt)
}
public fw_NpcTraceAttack(iEnt, attacker, Float: damage, Float: direction[3], trace, damageBits) {
if( !is_valid_ent( iEnt ) )
return HAM_SUPERCEDE;
new NPC[ 64 ];
entity_get_string( iEnt, EV_SZ_classname, NPC, charsmax( NPC ) );
if( equali( NPC, NpcClass ) ) {
if( entity_get_float( iEnt, EV_FL_takedamage ) == 0.0 )
return HAM_SUPERCEDE;
new Float: end[ 3 ];
get_tr2( trace, TR_vecEndPos, end );
message_begin( MSG_BROADCAST,SVC_TEMPENTITY );
write_byte( TE_BLOODSPRITE );
engfunc( EngFunc_WriteCoord, end[ 0 ] );
engfunc( EngFunc_WriteCoord, end[ 1 ] );
engfunc( EngFunc_WriteCoord, end[ 2 ] );
write_short( npc_kan_spr_sprey );
write_short( npc_kan_spr );
write_byte( 247 );
write_byte( random_num( 5, 15 ) );
message_end();
}
return HAM_IGNORED;
}
stock Util_PlayAnimation(index, sequence, Float: framerate = 1.0) {
entity_set_float(index, EV_FL_animtime, get_gametime());
entity_set_float(index, EV_FL_framerate, framerate);
entity_set_float(index, EV_FL_frame, 0.0);
entity_set_int(index, EV_INT_sequence, sequence);
}
stock get_user_hitpoint(id, Float:hOrigin[3]) {
if ( ! is_user_alive( id ))
return 0;
new Float:fOrigin[3], Float:fvAngle[3], Float:fvOffset[3], Float:fvOrigin[3], Float:feOrigin[3];
new Float:fTemp[3];
pev(id, pev_origin, fOrigin);
pev(id, pev_v_angle, fvAngle);
pev(id, pev_view_ofs, fvOffset);
xs_vec_add(fOrigin, fvOffset, fvOrigin);
engfunc(EngFunc_AngleVectors, fvAngle, feOrigin, fTemp, fTemp);
xs_vec_mul_scalar(feOrigin, 9999.9, feOrigin);
xs_vec_add(fvOrigin, feOrigin, feOrigin);
engfunc(EngFunc_TraceLine, fvOrigin, feOrigin, 0, id);
global_get(glb_trace_endpos, hOrigin);
return 1;
}
public NpcOlustur( id ) {
new Float: Origin[ 3 ], Float: Angle[ 3 ];
new iEnt = create_entity( "info_target" );
entity_set_string( iEnt, EV_SZ_classname, NpcClass );
get_user_hitpoint( id, Origin );
Origin[ 2 ] += 70.0;
entity_set_origin( iEnt, Origin );
entity_get_vector(id, EV_VEC_angles, Angle );
Angle[ 0 ] = 0.0;
entity_set_vector( iEnt, EV_VEC_angles, Angle );
entity_set_model( iEnt, g_NpcModel );
entity_set_int(iEnt, EV_INT_movetype, MOVETYPE_PUSHSTEP );
entity_set_int(iEnt, EV_INT_solid, SOLID_BBOX );
entity_set_float( iEnt, EV_FL_takedamage, 1.0 );
entity_set_float( iEnt, EV_FL_health, 500.0 );
new Float: mins[3] = {-12.0, -12.0, 0.0 };
new Float: maxs[3] = { 12.0, 12.0, 75.0 };
entity_set_size(iEnt, mins, maxs);
entity_set_byte( iEnt, EV_BYTE_controller1, 125 );
drop_to_floor( iEnt );
g_NpcOldu[ iEnt ] = false;
NpcSayisi++;
entity_set_float( iEnt, EV_FL_nextthink, get_gametime() + 1.0 );
}
public UselessFunction( iEnt) {
Util_PlayAnimation(iEnt,13)
new Float:fOrigin[3]
new Float:fVelocity[3]
//new Float:fAngels[3]
pev( iEnt, pev_origin, fOrigin )
fVelocity[0] = -80.0
yuruyor = 1
//fAngels[0] = -80.0
//set_pev(iEnt,pev_angles,fAngels)
set_pev( iEnt, pev_velocity, fVelocity )
set_task( 10.0, "PutMeBackPLZ", iEnt )
}
public PutMeBackPLZ(iEnt) {
new Float:fVelocity[3]
fVelocity[0] = 0.0
set_pev( iEnt, pev_velocity, fVelocity )
yuruyor = 0
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1055\\ f0\\ fs16 \n\\ par }
*/