Veteran Member
Join Date: Dec 2009
Location: Sweden Rock Festival
|
02-16-2011
, 08:12
Re: Massive error output?
|
#16
|
Yeah, sorry... I noticed I also used fl_vExplodeAt which should be completely unnecessary, and it is a float aswell.. Forgot that sh_extra_damage couldnt take floats, but had to go before I could edit my previous post. Thanks for all the help, will test it!
EDIT: So, now Ive tested that!..
I get runtime error 10's again:
Code:
L 02/16/2011 - 15:09:20: [AMXX] Run time error 10: native error (native "pev")
L 02/16/2011 - 15:09:20: [AMXX] [0] sh_z_new_gas.sma::poison (line 479)
L 02/16/2011 - 15:09:20: [FAKEMETA] Invalid entity
L 02/16/2011 - 15:09:20: [AMXX] Displaying debug trace (plugin "sh_z_new_gas.amxx")
Line 479 is:
PHP Code:
pev(ptr, pev_origin, fl_vExplodeAt[id])
(In public poison(parm[])
Strangely I only get it on that line, not with the exact same code on line 238, in fm_Touch.
I changed the victim != id to victim == id so I could check it by damaging myself, and well, buggy to say the least:
I am not damaged at all when Im standing in the the gas, and it seems Im only damaged once or several times (didnt see any pattern, mostly just a single 20 points damage) when Im shooting a new grenade after Ive already shot perhaps 10 rounds.
PHP Code:
// Exterminator!
/* CVARS - copy and paste to shconfig.cfg
//Exterminator exterminator_level 22 exterminator_mult 2.0 //Damage multiplyer for mp5 exterminator_grenades 5 //Grenades given exterminator_m203rad 500 //Radius of people affected by a grenade exterminator_m203maxdmg 200 //Max Grenades a mine can cause
*/
// Thanks to the original code of MP5+203 Mod by PaintLancer
#include <superheromod>
// GLOBAL VARIABLES new gHeroID new const gHeroName[] = "Exterminator" new bool:gHasExterminator[SH_MAXSLOTS+1] new gAmmo[SH_MAXSLOTS+1]
new Float:fl_vExplodeAt[SH_MAXSLOTS+1][3]
new const gPowerClass[] = "m203_nade" new const gSoundLaunch[] = "shmod/glauncher.wav" new const gSoundExplode[] = "shmod/a_exm2.wav" new const gModelMP5[] = "models/shmod/exterminator_mp5.mdl" new const gModelGrenade[] = "models/grenade.mdl" new gSpriteTrail
new iGas
new gmsgStatusIcon new pCvarGrenades, pCvarRadius, pCvarMaxDamage, pCvarTime //---------------------------------------------------------------------------------------------- public plugin_init() { // Plugin Info register_plugin("SUPERHERO Exterminator", "1.0", "The Art of War")
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG new pcvarLevel = register_cvar("exterminator_level", "22") new pcvarMult = register_cvar("exterminator_mp5mult", "2.0") pCvarGrenades = register_cvar("exterminator_grenades", "50") pCvarRadius = register_cvar("exterminator_m203rad", "500") pCvarMaxDamage = register_cvar("exterminator_m203maxdmg", "20") pCvarTime = register_cvar("exterminator_time", "0.5")
// FIRE THE EVENT TO CREATE THIS SUPERHERO! gHeroID = sh_create_hero(gHeroName, pcvarLevel) sh_set_hero_info(gHeroID, "Mp5 Gas Grenades", "MP5 Gas Grenade Launcher. Use Your Right Mouse Button To Fire.") sh_set_hero_dmgmult(gHeroID, pcvarMult, CSW_MP5NAVY) sh_set_hero_shield(gHeroID, true)
// REGISTER EVENTS THIS HERO WILL RESPOND TO! register_event("CurWeapon", "weapon_change", "be", "1=1") register_forward(FM_CmdStart, "fm_CmdStart") register_forward(FM_Touch, "fm_Touch")
gmsgStatusIcon = get_user_msgid("StatusIcon") } //---------------------------------------------------------------------------------------------- public plugin_precache() { precache_sound(gSoundLaunch) precache_sound(gSoundExplode) precache_model(gModelMP5) gSpriteTrail = precache_model("sprites/smoke.spr") iGas = precache_model("sprites/shmod/gas.spr") } //---------------------------------------------------------------------------------------------- public sh_hero_init(id, heroID, mode) { if ( gHeroID != heroID ) return
switch(mode) { case SH_HERO_ADD: { gHasExterminator[id] = true gAmmo[id] = get_pcvar_num(pCvarGrenades) exterminator_weapons(id) switchmodel(id) }
case SH_HERO_DROP: { gHasExterminator[id] = false if ( is_user_alive(id) ) { sh_drop_weapon(id, CSW_MP5NAVY, true) } } }
sh_debug_message(id, 1, "%s %s", gHeroName, mode ? "ADDED" : "DROPPED") } //---------------------------------------------------------------------------------------------- public sh_client_spawn(id) { gPlayerInCooldown[id] = false
if ( gHasExterminator[id] ) { exterminator_weapons(id) gAmmo[id] = get_pcvar_num(pCvarGrenades) } } //---------------------------------------------------------------------------------------------- exterminator_weapons(id) { if ( sh_is_active() && is_user_alive(id) && gHasExterminator[id] ) { sh_give_weapon(id, CSW_MP5NAVY) } } //---------------------------------------------------------------------------------------------- switchmodel(id) { if ( !sh_is_active() || !is_user_alive(id) || !gHasExterminator[id] ) return
if ( get_user_weapon(id) == CSW_MP5NAVY ) { set_pev(id, pev_viewmodel2, gModelMP5) } } //---------------------------------------------------------------------------------------------- public weapon_change(id) { if ( !sh_is_active() || !gHasExterminator[id] ) return
//weaponID = read_data(2) if ( read_data(2) != CSW_MP5NAVY ) { ammo_hud(id, 0) return } else { ammo_hud(id, 1) }
switchmodel(id) } //---------------------------------------------------------------------------------------------- public fm_CmdStart(id, uc_handle, seed) { if ( !sh_is_active() || !gHasExterminator[id] || !is_user_alive(id) || sh_is_freezetime() ) return FMRES_IGNORED
if ( (get_uc(uc_handle, UC_Buttons) & IN_ATTACK2) && !(pev(id, pev_oldbuttons) & IN_ATTACK2) ) { if ( get_user_weapon(id) == CSW_MP5NAVY ) { launch_nade(id) } }
return FMRES_IGNORED } //---------------------------------------------------------------------------------------------- launch_nade(id) { if ( gPlayerInCooldown[id] ) { sh_sound_deny(id) return FMRES_IGNORED } if ( gAmmo[id] == 0 ) { client_print(id, print_center, "You are out of Gas grenades!") sh_sound_deny(id) return FMRES_IGNORED }
send_weapon_anim(id, 3)
new Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target")) if ( !Ent ) return FMRES_IGNORED
set_pev(Ent, pev_classname, gPowerClass) engfunc(EngFunc_SetModel, Ent, gModelGrenade)
engfunc(EngFunc_SetSize, Ent, {-1.0, -1.0, -1.0}, {1.0, 1.0, 1.0})
new Float:fl_Origin[3], Float:fl_Angles[3], Float:fl_vAngle[3] // Get users postion and angles pev(id, pev_origin, fl_Origin) pev(id, pev_angles, fl_Angles) pev(id, pev_v_angle, fl_vAngle)
// Change height of entity origin fl_Origin[2] += 10.0
// Set entity postion and angles engfunc(EngFunc_SetOrigin, Ent, fl_Origin) set_pev(Ent, pev_angles, fl_Angles) set_pev(Ent, pev_v_angle, fl_vAngle)
// Set properties of the entity set_pev(Ent, pev_effects, EF_MUZZLEFLASH) set_pev(Ent, pev_solid, SOLID_BBOX) set_pev(Ent, pev_movetype, MOVETYPE_TOSS) set_pev(Ent, pev_owner, id)
new Float:fl_Velocity[3] velocity_by_aim(id, 2000, fl_Velocity)
set_pev(Ent, pev_velocity, fl_Velocity)
emit_sound(id, CHAN_WEAPON, gSoundLaunch, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
// remove an ammo and refresh the hud ammo_hud(id, 0) gAmmo[id]-- ammo_hud(id, 1)
new parm[1] parm[0] = Ent set_task(0.2, "grenade_trail", id, parm, 1) sh_set_cooldown(id, 2.0)
return FMRES_IGNORED } //---------------------------------------------------------------------------------------------- send_weapon_anim(id, iAnim) { set_pev(id, pev_weaponanim, iAnim)
message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id) write_byte(iAnim) write_byte(pev(id, pev_body)) message_end() } //---------------------------------------------------------------------------------------------- public fm_Touch(ptr, ptd) { if ( !sh_is_active() ) return FMRES_IGNORED if ( !pev_valid(ptr) ) return FMRES_IGNORED static classname[32] classname[0] = '^0' pev(ptr, pev_classname, classname, charsmax(classname))
if( equal(classname, gPowerClass) ) { new id = pev(ptr, pev_owner)
client_print(id, print_console, "classnames, floats") pev(ptr, pev_origin, fl_vExplodeAt[id])
new players[SH_MAXSLOTS], playerCount, victim get_players(players, playerCount, "ah")
for ( new i = 0; i < playerCount; i++ ) { victim = players[i] client_print(id, print_console, "Poison Gas Task") new parm[3] parm[0] = victim parm[1] = ptr parm[2] = id set_task(get_pcvar_float(pCvarTime), "poison", 999, parm, 3, "a", 40) }
message_begin(MSG_BROADCAST, SVC_TEMPENTITY) write_byte(TE_FIREFIELD) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][0]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][2] + 60) write_short(100)//radius) (fire is made in a square around origin. -radius, -radius to radius, radius) write_short(iGas)//modelindex) write_byte(10)//count) write_byte(24)//flags) write_byte(200)//duration (in seconds) * 10) (will be randomized a bit) message_end() message_begin(MSG_BROADCAST, SVC_TEMPENTITY) write_byte(TE_FIREFIELD) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][0] + 60) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][2] + 60) write_short(100)//radius) (fire is made in a square around origin. -radius, -radius to radius, radius) write_short(iGas)//modelindex) write_byte(10)//count) write_byte(24)//flags) write_byte(200)//duration (in seconds) * 10) (will be randomized a bit) message_end() message_begin(MSG_BROADCAST, SVC_TEMPENTITY) write_byte(TE_FIREFIELD) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][0] - 60) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][2] + 60) write_short(100)//radius) (fire is made in a square around origin. -radius, -radius to radius, radius) write_short(iGas)//modelindex) write_byte(10)//count) write_byte(24)//flags) write_byte(200)//duration (in seconds) * 10) (will be randomized a bit) message_end() message_begin(MSG_BROADCAST, SVC_TEMPENTITY) write_byte(TE_FIREFIELD) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][0] + 30) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][2] + 60) write_short(100)//radius) (fire is made in a square around origin. -radius, -radius to radius, radius) write_short(iGas)//modelindex) write_byte(10)//count) write_byte(24)//flags) write_byte(200)//duration (in seconds) * 10) (will be randomized a bit) message_end() message_begin(MSG_BROADCAST, SVC_TEMPENTITY) write_byte(TE_FIREFIELD) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][0] - 30) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][2] + 60) write_short(100)//radius) (fire is made in a square around origin. -radius, -radius to radius, radius) write_short(iGas)//modelindex) write_byte(10)//count) write_byte(24)//flags) write_byte(200)//duration (in seconds) * 10) (will be randomized a bit) message_end() message_begin( MSG_BROADCAST, SVC_TEMPENTITY ) write_byte( TE_FIREFIELD ) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][0] + 60) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][2] + 60) write_short(150) write_short(iGas) write_byte(10) write_byte(TEFIRE_FLAG_ALPHA | TEFIRE_FLAG_SOMEFLOAT) write_byte(200) message_end() message_begin( MSG_BROADCAST, SVC_TEMPENTITY ) write_byte( TE_FIREFIELD ) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][0] - 60) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][2] + 60) write_short(150) write_short(iGas) write_byte(10) write_byte(TEFIRE_FLAG_ALPHA | TEFIRE_FLAG_SOMEFLOAT) write_byte(200) message_end() message_begin( MSG_BROADCAST, SVC_TEMPENTITY ) write_byte( TE_FIREFIELD ) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][0] + 30) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][2] + 60) write_short(150) write_short(iGas) write_byte(10) write_byte(TEFIRE_FLAG_ALPHA | TEFIRE_FLAG_SOMEFLOAT) write_byte(200) message_end() message_begin( MSG_BROADCAST, SVC_TEMPENTITY ) write_byte( TE_FIREFIELD ) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][0] - 30) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][2] + 60) write_short(150) write_short(iGas) write_byte(10) write_byte(TEFIRE_FLAG_ALPHA | TEFIRE_FLAG_SOMEFLOAT) write_byte(200) message_end() message_begin( MSG_BROADCAST, SVC_TEMPENTITY ) write_byte( TE_FIREFIELD ) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][0]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][2] + 60) write_short(150) write_short(iGas) write_byte(10) write_byte(TEFIRE_FLAG_ALPHA | TEFIRE_FLAG_SOMEFLOAT) write_byte(200) message_end() // Make small smoke near grenade on ground message_begin( MSG_BROADCAST, SVC_TEMPENTITY ); write_byte(TE_FIREFIELD) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][0]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][2] + 10) write_short(10) write_short(iGas) write_byte(2) write_byte(TEFIRE_FLAG_ALLFLOAT | TEFIRE_FLAG_ALPHA) write_byte(200) message_end() // Make small smoke near grenade on ground message_begin( MSG_BROADCAST, SVC_TEMPENTITY ); write_byte(TE_FIREFIELD) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][0] + 60) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][2] + 10) write_short(10) write_short(iGas) write_byte(2) write_byte(TEFIRE_FLAG_ALLFLOAT | TEFIRE_FLAG_ALPHA) write_byte(200) message_end() // Make small smoke near grenade on ground message_begin( MSG_BROADCAST, SVC_TEMPENTITY ); write_byte(TE_FIREFIELD) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][0] - 60) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][2] + 10) write_short(10) write_short(iGas) write_byte(2) write_byte(TEFIRE_FLAG_ALLFLOAT | TEFIRE_FLAG_ALPHA) write_byte(200) message_end() // Make small smoke near grenade on ground message_begin( MSG_BROADCAST, SVC_TEMPENTITY ); write_byte(TE_FIREFIELD) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][0] + 30) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][2] + 10) write_short(10) write_short(iGas) write_byte(2) write_byte(TEFIRE_FLAG_ALLFLOAT | TEFIRE_FLAG_ALPHA) write_byte(200) message_end() // Make small smoke near grenade on ground message_begin( MSG_BROADCAST, SVC_TEMPENTITY ); write_byte(TE_FIREFIELD) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][0] - 30) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[id][2] + 10) write_short(10) write_short(iGas) write_byte(2) write_byte(TEFIRE_FLAG_ALLFLOAT | TEFIRE_FLAG_ALPHA) write_byte(200) message_end()
emit_sound(ptr, CHAN_WEAPON, gSoundExplode, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
engfunc(EngFunc_RemoveEntity, ptr) }
return FMRES_IGNORED } //---------------------------------------------------------------------------------------------- public poison(parm[]) { new victim = parm[0] new ptr = parm[1] new id = parm[2] client_print(id, print_console, "Poison forward, classnames, id")
new maxDamage = get_pcvar_num(pCvarMaxDamage) new Float:distanceBetween new Float:dmgRadius = get_pcvar_float(pCvarRadius) new FFOn = sh_friendlyfire_on() new CsTeams:idTeam = cs_get_user_team(id) new Float:vicOrigin[3] pev(ptr, pev_origin, fl_vExplodeAt[id]) pev(victim, pev_origin, vicOrigin) distanceBetween = vector_distance(fl_vExplodeAt[id], vicOrigin) if ( distanceBetween <= dmgRadius ) { if ( FFOn || victim == id || idTeam != cs_get_user_team(victim) ) {
client_print(id, print_console, "Poison Gas Damage") sh_extra_damage(victim, id, maxDamage, "gas", _, SH_DMG_NORM, _, true, fl_vExplodeAt[id]) } } } //----------------------------------------------------------------------------------------- ammo_hud(id, show) { new SpriteString[32] formatex(SpriteString, charsmax(SpriteString), "number_%d", gAmmo[id])
if (show && gAmmo[id] > 0) { message_begin(MSG_ONE, gmsgStatusIcon, _, id) write_byte(1) // status (0 = hide, 1 = show, 2 = flash) write_string(SpriteString) write_byte(0) // r, g, b write_byte(160) // r, g, b write_byte(0) // r, g, b message_end() } else { message_begin(MSG_ONE, gmsgStatusIcon, _, id) write_byte(0) // status (0 = hide, 1 = show, 2 = flash) write_string(SpriteString) write_byte(0) // r, g, b write_byte(0) // r, g, b write_byte(0) // r, g, b message_end() } } //---------------------------------------------------------------------------------------------- public grenade_trail(parm[]) { new Ent = parm[0]
if (Ent) { message_begin(MSG_BROADCAST, SVC_TEMPENTITY) write_byte(TE_BEAMFOLLOW) //22 write_short(Ent) write_short(gSpriteTrail) write_byte(10) // life write_byte(5) // width write_byte(255) // r, g, b write_byte(255) // r, g, b write_byte(255) // r, g, b write_byte(100) // brightness message_end() } } //---------------------------------------------------------------------------------------------- public sh_client_death(id) { if ( id < 1 || id > sh_maxplayers() ) return
if ( gHasExterminator[id] ) { ammo_hud(id, 0) } } //---------------------------------------------------------------------------------------------- public sh_round_end() { new players[SH_MAXSLOTS], numplayers, victim get_players(players, numplayers, "ah")
for ( new i = 0; i < numplayers; i++ ) { victim = players[i]
remove_task(999) } }
So I guess setting the task in fm_Touch is not a good idea... Would I be able to solve it by making just the one forward call in fm_Touch and setting the task in there, perhaps? Thanks.
__________________
Last edited by The Art of War; 02-16-2011 at 09:15.
|
|