| Neeeeeeeeeel.- |
07-29-2011 13:58 |
Delete entity problem
Hi, i have a problem deleting an entity... i dont know much about entitys so i can't repair it, the code is not mine.
Edit: I forgot the global vars
PHP Code:
new const MODEL_KIT[] = { "models/winebottle.mdl" } new gGMsgFade; new gGMsgItemPickup; new const gMedKitClassname[] = "medkit_entity"; #define MEDKIT_MINSZ Float:{ -23.160000, -13.660000, -0.050000 } #define MEDKIT_MAXSZ Float:{ 11.470000, 12.780000, 6.720000 }
Here i create the entity:
Its called when someone die.
PHP Code:
public drop_kit() { new victim = read_data(2); static Float:origin[3]; pev(victim, pev_origin, origin); new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target")); origin[2] -= 36; engfunc(EngFunc_SetOrigin, ent, origin); if(!pev_valid(ent)) return PLUGIN_HANDLED; set_pev(ent, pev_classname, gMedKitClassname); engfunc(EngFunc_SetModel, ent, MODEL_KIT); dllfunc(DLLFunc_Spawn, ent); set_pev(ent, pev_solid, SOLID_BBOX); set_pev(ent, pev_movetype, MOVETYPE_NONE); engfunc(EngFunc_SetSize, ent, MEDKIT_MINSZ, MEDKIT_MAXSZ); engfunc(EngFunc_DropToFloor, ent); fm_set_rendering(ent, kRenderFxGlowShell, 255, 255, 255, kRenderFxNone, 27); return PLUGIN_HANDLED; }
And here when someone touch the entity i give him random ammopacks, then some effects and at the end i delete the entity:
PHP Code:
public ForwardTouch(ent, id) { if(!pev_valid(ent)) return FMRES_IGNORED; new classname[32]; pev(ent, pev_classname, classname, charsmax(classname)); if(!equal( classname, gMedKitClassname)) return FMRES_IGNORED; new count = random_num(10, 200) ChatColor(id,"!g[ZP]!y Ganaste %d ammopacks por tomar un ale.", count) g_ammopacks[id] += count check_level(id) message_begin(MSG_ONE_UNRELIABLE, gGMsgItemPickup, _, id); // line 2075 write_string("item_healthkit"); message_end(); message_begin( MSG_ONE_UNRELIABLE, gGMsgFade , _, id); write_short(1<<10); write_short(1<<10); write_short(FFADE_IN); write_byte(255); write_byte(0); write_byte(0); write_byte(75); message_end(); engfunc( EngFunc_RemoveEntity, ent ); return FMRES_IGNORED; }
These are the errorlogs:
Code:
L 07/29/2011 - 14:25:14: [AMXX] Displaying debug trace (plugin "zp-infernus.amxx")
L 07/29/2011 - 14:25:14: [AMXX] Run time error 10: native error (native "message_begin")
L 07/29/2011 - 14:25:14: [AMXX] [0] zp-infernus.sma::ForwardTouch (line 2075)
L 07/29/2011 - 14:25:14: [AMXX] [1] zp-infernus.sma::ForwardTouch (line 2073)
L 07/29/2011 - 14:25:14: Plugin called message_begin with an invalid message id (0).
Thanks.
|