Senior Member
|
08-02-2020
, 15:02
Re: Run time error 4: index out of bounds
|
#12
|
PHP Code:
#include <amxmodx> #include <fakemeta> #include <fun> #include <hamsandwich> #include <zombieplague>
#define PLUGIN "Regular Zombie CSO-LIKE" #define VERSION "1.0" #define AUTHOR "DeclineD"
#define countdowntimer 20.0 #define countdown2timer 10.0 #define countdownover 20 #define countdown2over 10 #define countdown 10 #define countdowntwo 5 #define abilityend 10.0
//TaskIds// #define taskhud 32135 #define taskhud1 23124 #define taskhud2 42151 #define taskhud3 29311 #define taskability 31276 #define taskability1 5132 #define taskend 62343 #define taskready 77345 #define taskready1 482731
const hp = 15000 const speed = 240 new Float:gravity = 0.300 new Float:knockback = 1.0 new Ready[33] new Ready2[33] new abilityended[33] new abilitystarted[33]
new g_ent_playermodel[33] new regular new saytext new const zombieh[] = { "v_regular.mdl" } new const zombiemodel1[] = { "regularzombie" } new const zombiemodel2[] = { "regularzombiehost"} new const bothmodels[] = { "regularzombie", "regularzombiehost" } new const ability1start[] = { "csolike/zombiepressure.wav" } new const ability1pre[] = { "csolike/pre1.wav" } new const ability1end[] = { "csolike/pre2.wav" } new const infectsound[] = { "csolike/regularinfect.wav" } new const hit[] = { "csolike/hit1.wav", "csolike/hit2.wav"} new const deathsound[] = { "csolike/death1.wav", "csolike/death2.wav" } new const health[] = { 2000, 3000, 4000, 5000 }
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_clcmd("+drop","ability1") register_clcmd("+reload","ability2") register_concmd("+drop","ability1") register_concmd("+reload","ability2") regular = zp_register_zombie_class("\r[\yCSO-LIKE\r]Regular Zombie","\r[\yBerserk\r|\yReproduce\r]",bothmodels ,zombieh,hp,speed,gravity,knockback) RegisterHam(Ham_TakeDamage,"player","dmg") saytext = get_user_msgid("SayText") register_event("DeathMsg","death","a") } public plugin_precache() { precache_sound(ability1start) precache_sound(ability1end) precache_sound(ability1pre) precache_sound(infectsound) precache_sound(hit) precache_sound(deathsound) precache_model("models/player/regularzombiehost/regularzombiehost.mdl") precache_model("models/player/regularzombie/regularzombie.mdl") } public death(id) { if(!zp_get_user_zombie(id) && zp_get_user_zombie_class(id) != regular && zp_get_user_nemesis(id)) return PLUGIN_CONTINUE; emit_sound(id, CHAN_VOICE, deathsound, 1.0, ATTN_NORM, 0, PITCH_NORM) return PLUGIN_HANDLED } public zp_user_infected_post(id) { if((zp_get_user_zombie_class(id) == regular) && zp_get_user_zombie(id) && !zp_get_user_nemesis(id)) return
if(zp_get_user_first_zombie(id)) { fm_set_playermodel_ent(id,zombiemodel2,0) emit_sound(id,CHAN_VOICE,infectsound,1.0,ATTN_NORM,0,PITCH_NORM) Ready[id] = 1 Ready2[id] = 1 set_task(1.0,"hudready",id - taskready,_,_,"b") set_task(1.0,"hudready1",id - taskready1,_,_,"b") } else { fm_set_playermodel_ent(id,zombiemodel1,0) emit_sound(id,CHAN_VOICE,infectsound,1.0,ATTN_NORM,0,PITCH_NORM) Ready[id] = 1 Ready2[id] = 1 set_task(1.0,"hudready",id - taskready,_,_,"b") set_task(1.0,"hudready1",id - taskready1,_,_,"b") } }
public zp_user_humanized_post(task) { new id = task - taskhud new id1 = task - taskhud1 new id2 = task - taskhud2 new id3 = task - taskhud3 new id4 = task - taskability new id5 = task - taskend new id6 = task - taskready new id7 = task - taskability1 remove_task(id) remove_task(id1) remove_task(id2) remove_task(id3) remove_task(id4) remove_task(id5) remove_task(id6) remove_task(id7) } public hudready(id) { set_hudmessage(127, 255, 85, -1.0, 0.83, 0, 6.0, 0.9) show_hudmessage(id, "[Berserk - Ready] [G]") } public hudready1(id) { set_hudmessage(127, 255, 85, -1.0, 0.83, 0, 6.0, 0.9) show_hudmessage(id, "^n[Reproduce - Ready] [R]") } public hudrecharge(id) { new cooldown = (countdownover + 1) set_hudmessage(127, 255, 85, -1.0, 0.83, 0, 6.0, 0.9) show_hudmessage(id, "[Berserk - %d] [G]",cooldown - 1) } public hudrecharge1(id) { new cooldown2 = (countdown2over + 1) set_hudmessage(127, 255, 85, -1.0, 0.83, 0, 6.0, 0.9) show_hudmessage(id, "^n[Reproduce - %d] [R]",cooldown2 - 1) } public ability1(id) { new fov = 130 new uspeed = 700
switch(Ready[id]) { case 1:{ fm_set_rendering(id, kRenderFxGlowShell,255,0,0,kRenderNormal,20) set_pev(id,pev_fov, fov) set_pev(id,pev_maxspeed, uspeed)
set_task(abilityend,"abend",id - taskend) set_task(countdowntimer,"ready",id - taskready) set_task(1.0,"hudrecharge",id - taskhud2,_,_,"b")
abilityended[id] = 0 abilitystarted[id] = 1 Ready[id] = 0 emit_sound(id,CHAN_VOICE,ability1start,1.0,ATTN_NORM,0,PITCH_NORM) } case 0: { message_begin(MSG_ONE,saytext,{0,0,0},id) write_byte(id) write_string("^x04[ZOMBIE]^x01Wait 'till Berserk is available") message_end() } } return PLUGIN_CONTINUE }
public abend(id) { abilityended[id] = 1 abilitystarted[id] = 0 new fovn = 110 set_pev(id,pev_fov, fovn) set_pev(id,pev_maxspeed, speed) } public ready(id) { Ready[id] = 1 set_task(1.0,"hudready",id - taskhud,_,_,"b") } public ready2(id) { Ready2[id] = 1 set_task(1.0,"hudready1",id - taskhud1,_,_,"b") } public ability2(id) { if(!zp_get_user_zombie(id) && zp_get_user_zombie_class(id) != regular && zp_get_user_nemesis(id)) return PLUGIN_CONTINUE;
switch(Ready2[id]) { case 1:{ new healthnum
healthnum = random_num(0,charsmax(health)) new userhealth[33] userhealth[id] = get_user_health(id) set_user_health(id,userhealth[id] + health[healthnum]) set_task(countdown2timer,"hudrecharge1",id - taskready1,_,_,"b") emit_sound(id,CHAN_VOICE,ability1pre,1.0,ATTN_NORM,0,PITCH_NORM) Ready2[id] = 0 } case 0: { message_begin(MSG_ONE,saytext,{0,0,0},id) write_byte(id) write_string("^x04[ZOMBIE]^x01Wait 'till Reproduce is available") message_end() } } return PLUGIN_CONTINUE }
public dmg(victim, inflictor, id, Float:damage, damagebits) { new Human[33] Human[inflictor] = !zp_get_user_zombie(inflictor) new class[33] class[inflictor] = zp_get_user_zombie_class(inflictor) == regular if(!Human[inflictor] && class[inflictor]) { switch(abilityended[id]) { case 0: { SetHamParamFloat(4,damage * 2.0) } case 1: { SetHamParamFloat(4,damage * 1.0) } } } if(Human[inflictor]) { emit_sound(id,CHAN_VOICE,hit,1.0,ATTN_NORM,0,PITCH_NORM) } }
stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16) { static Float:color[3] color[0] = float(r) color[1] = float(g) color[2] = float(b) set_pev(entity, pev_renderfx, fx) set_pev(entity, pev_rendercolor, color) set_pev(entity, pev_rendermode, render) set_pev(entity, pev_renderamt, float(amount)) } stock fm_set_playermodel_ent(id, const modelname[],anim) { fm_set_rendering(id, kRenderFxNone, 255, 255, 255, kRenderTransTexture, 1) static modelpath[100] formatex(modelpath, sizeof modelpath - 1, "models/player/%s/%s.mdl", modelname, modelname) if (!pev_valid(g_ent_playermodel[id])) { g_ent_playermodel[id] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target")) if (!pev_valid(g_ent_playermodel[id])) return set_pev(g_ent_playermodel[id], pev_classname, "finger_classname") set_pev(g_ent_playermodel[id], pev_movetype, MOVETYPE_FOLLOW) set_pev(g_ent_playermodel[id], pev_aiment, id) set_pev(g_ent_playermodel[id], pev_animtime, get_gametime()+0.1) set_pev(g_ent_playermodel[id], pev_framerate, 1.0) set_pev(g_ent_playermodel[id], pev_sequence, anim) set_pev(g_ent_playermodel[id], pev_owner, id) } engfunc(EngFunc_SetModel, g_ent_playermodel[id], modelpath) }
That s the full code of what i did , the last 2 stocks i copied from another plugin.
My tasks aren t working.... , it s always confuzing the id with the taskid , im using amxx 1.8.1 and looking better at my codei wrote something bad at dmg and going to solve it
!IMPORTANT!
I want to tank everyone bcs wanted to help me
Last edited by AnimalMonster; 08-02-2020 at 15:07.
|
|