Veteran Member
Join Date: Dec 2009
Location: Sweden Rock Festival
|
02-07-2011
, 11:55
Re: Massive error output?
|
#6
|
Well, so..... I cleaned the code up a lot, and I actually made it not crash the server at all. Though I get 2 tag mismatches on compile, so I guess thats what causing this shit not to cause any damage. I did make one version do damage, but it was the funniest bug Ive ever encountered. Instead of making damage within a radius of the exploded grenade, it made damage to all enemies no matter if they were in range, IF I were in the radius of the exploded grenade...
At first I though I must have failed some check, but then I came up with another thing: Maybe the use of ptr in the damage forward called poison isnt the best way, but heck I got the damage working once so I guess its possible.. And I dont see what can cause it.
So, any help would be nice
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 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") new Float:fl_vExplodeAt[3]
pev(ptr, pev_origin, fl_vExplodeAt) 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") set_task(get_pcvar_float(pCvarTime), "poison", victim, _, _, "a", 40) }
message_begin(MSG_BROADCAST, SVC_TEMPENTITY) write_byte(TE_FIREFIELD) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[0]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[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[0] + 60) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[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[0] - 60) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[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[0] + 30) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[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[0] - 30) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[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[0] + 60) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[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[0] - 60) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[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[0] + 30) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[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[0] - 30) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[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[0]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[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[0]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[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[0] + 60) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[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[0] - 60) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[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[0] + 30) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[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[0] - 30) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[1]) engfunc(EngFunc_WriteCoord, fl_vExplodeAt[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(ptr) { new id = pev(ptr, pev_owner) client_print(id, print_console, "Poison forward, classnames, id")
new Float: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] new Float:fl_vExplodeAt[3] pev(ptr, pev_origin, fl_vExplodeAt) new players[SH_MAXSLOTS], playerCount, victim get_players(players, playerCount, "ah")
for ( new i = 0; i < playerCount; i++ ) { victim = players[i] pev(victim, pev_origin, vicOrigin) distanceBetween = vector_distance(fl_vExplodeAt, 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) } } } } //----------------------------------------------------------------------------------------- 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) } } //----------------------------------------------------------------------------------------------
Tag mismatches on sh_extradamage and the second print in poison.
__________________
|
|