| Depresie |
10-21-2015 07:34 |
Re: server crash
Try
btw let the first code i posted there aswell, in case the player leaves the task must be removed in order to avoid errors and crashes
PHP Code:
#include <amxmodx> #include <biohazard> #include <fakemeta> #include <fakemeta_util> #include <hamsandwich> #define PLUGIN "[Bio] Zombie: Finger" #define AUTHOR "Aragon*" #define VERSION "1.0" #define ZOMBIE_NAME "Finger (Run)" //Zombie Name #define ZOMBIE_DESC "press G Run" //Zobmie Description #define ZOMBIE_MODEL "models/player/bio30_finger/bio30_finger.mdl" //Zombie Model #define ZOMBIE_CLAWS "models/player/bio30_finger/claws_finger.mdl" //Claws Model #define ZOMBIE_HEALTH 555.0 //Health value #define ZOMBIE_SPEED 300.0 //Speed value #define ZOMBIE_GRAVITY 1.0 //Gravity multiplier #define ZOMBIE_ATTACK 1.5 //Zombie damage multiplier #define ZOMBIE_REGENDLY 0.25 //Regeneration delay value #define ZOMBIE_KNOCKBACK 0.0 //Knockback multiplier #define TASKID_FASTRUN_HEARTBEAT 12314 #define TASKID_START_POWER 2131 new FastRun_Sound[][] = { "Biohazard30/bio30_finger/pukricide.wav" } new const Tag[ ] = "[Biohazard]"; new Class, FastRun[33], FastRun_Countdown[33] new cvar_fastrun_duration, cvar_fastrun_countdown, cvar_fastrun_speed; public plugin_init() { register_plugin(PLUGIN,AUTHOR,VERSION) is_biomod_active() ? plugin_init2() : pause("ad") } public plugin_init2() { Class = register_class(ZOMBIE_NAME, ZOMBIE_DESC ) set_class_pmodel(Class, ZOMBIE_MODEL) set_class_wmodel(Class, ZOMBIE_CLAWS) set_class_data(Class, DATA_HEALTH, ZOMBIE_HEALTH); set_class_data(Class, DATA_SPEED, ZOMBIE_SPEED); set_class_data(Class, DATA_GRAVITY, ZOMBIE_GRAVITY); set_class_data(Class, DATA_ATTACK, ZOMBIE_ATTACK); set_class_data(Class, DATA_REGENDLY, ZOMBIE_REGENDLY); set_class_data(Class, DATA_KNOCKBACK, ZOMBIE_KNOCKBACK); register_clcmd( "drop", "CMD_FastRun"); register_event("DeathMsg", "EVENT_Death", "a") register_forward(FM_PlayerPreThink,"FWD_PlayerPreThink") RegisterHam(Ham_Spawn, "player", "HAM_Spawn_Post", 1); cvar_fastrun_duration = register_cvar("bio_fastrun_duration", "13.0") cvar_fastrun_countdown = register_cvar("bio_fastrun_countdown", "7.0") cvar_fastrun_speed = register_cvar("bio_fastrun_speed", "500.0") } public plugin_precache() { precache_model(ZOMBIE_CLAWS) precache_model(ZOMBIE_MODEL) for(new i = 0; i < sizeof FastRun_Sound; i++ ) precache_sound(FastRun_Sound[i]); } public client_disconect(id) { remove_task(id + TASKID_FASTRUN_HEARTBEAT) } public EVENT_Death() { FastRun[read_data(2)] = 0 FastRun_Countdown[read_data(2)] = 0 remove_task(read_data(2) + TASKID_FASTRUN_HEARTBEAT) } public event_infect(victim, attacker) { if(get_user_class(victim) == Class) { FastRun[victim] = 0 FastRun_Countdown[victim] = 0 remove_task(victim + TASKID_FASTRUN_HEARTBEAT) ColorChat(victim, "^x04%s^x01 Pentru a folosi^x03 ultra viteza^x01 apasa tasta^x03 G^x01.", Tag) } } public FWD_PlayerPreThink(id) { if(is_user_alive(id) && FastRun[id]) { if(fm_get_user_maxspeed(id) < get_pcvar_float(cvar_fastrun_speed) && fm_get_user_maxspeed(id) > 1.0) fm_set_user_maxspeed(id, get_pcvar_float(cvar_fastrun_speed)) } if(get_user_weapon(id) != CSW_KNIFE && task_exists(id + TASKID_START_POWER)) remove_task(id + TASKID_START_POWER) } public HAM_Spawn_Post(id) { FastRun[id] = 0 FastRun_Countdown[id] = 0 remove_task(id + TASKID_FASTRUN_HEARTBEAT) } public CMD_FastRun(id) { new Float:NextAttack = get_pdata_float(id, 83, 5); if(is_user_alive(id) && get_user_class(id) == Class && is_user_zombie(id) && get_user_weapon(id) == CSW_KNIFE && NextAttack <= 0.0) { if(!FastRun[id] && !FastRun_Countdown[id]) { set_pdata_float(id, 83, 1.6, 5); set_weapon_anim(id, 9) set_task(1.50, "StartRun", id + TASKID_START_POWER); } return PLUGIN_HANDLED } return PLUGIN_CONTINUE } public StartRun(id) { id -= TASKID_START_POWER engclient_cmd(id, "weapon_knife"); set_pdata_float(id, 83, 1.56, 5); set_weapon_anim(id, 10) EffectFastrun(id, 95) emit_sound(id, CHAN_VOICE, FastRun_Sound[0], 1.0, ATTN_NORM, 0, PITCH_NORM) set_task(2.0, "FastRunHeartBeat", id + TASKID_FASTRUN_HEARTBEAT, _, _, "b") FastRun[id] = get_pcvar_num(cvar_fastrun_duration); if(FastRun[id]) { new Message[256]; formatex(Message,sizeof(Message)-1,"Fast Run^n(%d second%s remaining).",FastRun[id], FastRun[id] > 1 ? "s" : ""); HudMessage(id, Message, _, _, _, _, _, _, _, 0.9); set_task(1.0, "TASK_CountDown", id); } } public TASK_CountDown(id) { if (!is_user_alive(id) || !is_user_zombie(id) || get_user_class(id) != Class) { FastRun[id] = 0 } else if(is_user_alive(id) && FastRun[id] > 1) { FastRun[id] --; new Message[256]; formatex(Message,sizeof(Message)-1,"Fast Run^n(%d second%s remaining).",FastRun[id], FastRun[id] > 1 ? "s" : ""); HudMessage(id, Message, _, _, _, _, _, _, _, 0.9); set_task(1.0, "TASK_CountDown", id); } else if(FastRun[id] <= 1) { FastRun[id] = 0 remove_task(id + TASKID_FASTRUN_HEARTBEAT) fm_set_user_maxspeed(id, ZOMBIE_SPEED) EffectFastrun(id) FastRun_Countdown[id] = get_pcvar_num(cvar_fastrun_countdown) if(FastRun_Countdown[id]) { new Message[256]; formatex(Message,sizeof(Message)-1,"Fast Run not ready.^n(%d second%s remaining).",FastRun_Countdown[id], FastRun_Countdown[id] > 1 ? "s" : ""); HudMessage(id, Message, _, _, _, _, _, _, _, 0.9); set_task(1.0, "TASK_CountDown2", id); } } } public TASK_CountDown2(id) { if (!is_user_alive(id) || !is_user_zombie(id) || get_user_class(id) != Class) FastRun_Countdown[id] = 0 else if(is_user_alive(id) && FastRun_Countdown[id] > 1) { FastRun_Countdown[id] --; new Message[256]; formatex(Message,sizeof(Message)-1,"Fast Run not ready.^n(%d second%s remaining).",FastRun_Countdown[id], FastRun_Countdown[id] > 1 ? "s" : ""); HudMessage(id, Message, _, _, _, _, _, _, _, 0.9); set_task(1.0, "TASK_CountDown2", id); } else if(FastRun_Countdown[id] <= 1) { new Message[256]; formatex(Message,sizeof(Message)-1,"Fast Run is ready."); HudMessage(id, Message, _, _, _, _, _, _, _, 0.9); FastRun_Countdown[id] = 0; } } public FastRunHeartBeat(id) { id -= TASKID_FASTRUN_HEARTBEAT if (is_user_connected(id) && FastRun[id]) { emit_sound(id, CHAN_VOICE, FastRun_Sound[random_num(1, sizeof FastRun_Sound - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM) if(is_user_connected(id)) { new Color[3] Color[0] = 200 Color[1] = 0 Color[2] = 0 UTIL_ScreenFade(id, Color, 0.5, 0.5, 125) } } } EffectFastrun(id, num = 90) { if(is_user_connected(id)) { message_begin(MSG_ONE, get_user_msgid("SetFOV"), {0,0,0}, id) write_byte(num) message_end() } } stock FixedUnsigned16(Float:flValue, iScale) { new iOutput; iOutput = floatround(flValue * iScale); if ( iOutput < 0 ) iOutput = 0; if ( iOutput > 0xFFFF ) iOutput = 0xFFFF; return iOutput; } stock UTIL_ScreenFade(id=0,iColor[3]={0,0,0},Float:flFxTime=-1.0,Float:flHoldTime=0.0,iAlpha=0,iFlags=0x0000,bool:bReliable=false,bool:bExternal=false) { if( id && !is_user_connected(id)) return; new iFadeTime; if( flFxTime == -1.0 ) { iFadeTime = 4; } else { iFadeTime = FixedUnsigned16( flFxTime , 1<<12 ); } static gmsgScreenFade; if( !gmsgScreenFade ) { gmsgScreenFade = get_user_msgid("ScreenFade"); } new MSG_DEST; if( bReliable ) { MSG_DEST = id ? MSG_ONE : MSG_ALL; } else { MSG_DEST = id ? MSG_ONE_UNRELIABLE : MSG_BROADCAST; } if( bExternal ) { emessage_begin( MSG_DEST, gmsgScreenFade, _, id ); ewrite_short( iFadeTime ); ewrite_short( FixedUnsigned16( flHoldTime , 1<<12 ) ); ewrite_short( iFlags ); ewrite_byte( iColor[0] ); ewrite_byte( iColor[1] ); ewrite_byte( iColor[2] ); ewrite_byte( iAlpha ); emessage_end(); } else { message_begin( MSG_DEST, gmsgScreenFade, _, id ); write_short( iFadeTime ); write_short( FixedUnsigned16( flHoldTime , 1<<12 ) ); write_short( iFlags ); write_byte( iColor[0] ); write_byte( iColor[1] ); write_byte( iColor[2] ); write_byte( iAlpha ); message_end(); } } stock UTIL_FadeToBlack(id,Float:fxtime=3.0,bool:bReliable=false,bool:bExternal=false) { UTIL_ScreenFade(id, _, fxtime, fxtime, 255, 0x0001|0x0004,bReliable,bExternal); } stock set_weapon_anim(id, anim) { set_pev(id, pev_weaponanim, anim); if(is_user_connected(id)) { message_begin(MSG_ONE, SVC_WEAPONANIM, _, id); write_byte(anim); write_byte(pev(id, pev_body)); message_end(); } } #define clamp_byte(%1) ( clamp( %1, 0, 255 ) ) #define pack_color(%1,%2,%3) ( %3 + ( %2 << 8 ) + ( %1 << 16 ) ) stock HudMessage(const id, const message[], red = 0, green = 160, blue = 0, Float:x = -1.0, Float:y = 0.65, effects = 2, Float:fxtime = 0.01, Float:holdtime = 3.0, Float:fadeintime = 0.01, Float:fadeouttime = 0.01) { new count = 1, players[32]; if(id) players[0] = id; else get_players(players, count, "ch"); { for(new i = 0; i < count; i++) { if(is_user_connected(players[i])) { new color = pack_color(clamp_byte(red), clamp_byte(green), clamp_byte(blue)) message_begin(MSG_ONE_UNRELIABLE, SVC_DIRECTOR, _, players[i]); write_byte(strlen(message) + 31); write_byte(DRC_CMD_MESSAGE); write_byte(effects); write_long(color); write_long(_:x); write_long(_:y); write_long(_:fadeintime); write_long(_:fadeouttime); write_long(_:holdtime); write_long(_:fxtime); write_string(message); message_end(); } } } } stock ColorChat(const id, const input[], any:...) { new count = 1, players[32]; static msg[191]; vformat(msg, 190, input, 3); replace_all(msg, 190, "!g", "^4"); replace_all(msg, 190, "!y", "^1"); replace_all(msg, 190, "!t", "^3"); if(id) players[0] = id; else get_players(players, count, "ch"); { for(new i = 0; i < count; i++) { if(is_user_connected(players[i])) { message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]); write_byte(players[i]); write_string(msg); message_end(); } } } } /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par } */
|