AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Delete entity problem (https://forums.alliedmods.net/showthread.php?t=163365)

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(victimpev_originorigin);
    
    new 
ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
    
    
origin[2] -= 36
    
    
engfunc(EngFunc_SetOriginentorigin);
    
    if(!
pev_valid(ent))
        return 
PLUGIN_HANDLED;
    
    
set_pev(entpev_classnamegMedKitClassname);
    
engfunc(EngFunc_SetModelentMODEL_KIT);
    
dllfunc(DLLFunc_Spawnent);
    
set_pev(entpev_solidSOLID_BBOX);
    
set_pev(entpev_movetypeMOVETYPE_NONE);
    
engfunc(EngFunc_SetSizeentMEDKIT_MINSZMEDKIT_MAXSZ);
    
engfunc(EngFunc_DropToFloorent);
    
    
fm_set_rendering(entkRenderFxGlowShell255255255kRenderFxNone27);
    
    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(entid)
{
    if(!
pev_valid(ent))
        return 
FMRES_IGNORED;
    
    new 
classname[32];
    
pev(entpev_classnameclassnamecharsmax(classname));
    
    if(!
equalclassnamegMedKitClassname))
        return 
FMRES_IGNORED;
    
    
    new 
count random_num(10200)
    
ChatColor(id,"!g[ZP]!y Ganaste %d ammopacks por tomar un ale."count)
    
g_ammopacks[id] += count
    check_level
(id)
    
    
message_begin(MSG_ONE_UNRELIABLEgGMsgItemPickup_id); // line 2075
    
write_string("item_healthkit");
    
message_end();
    
message_beginMSG_ONE_UNRELIABLEgGMsgFade _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();
    
    
engfuncEngFunc_RemoveEntityent );
    
    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.

nikhilgupta345 07-29-2011 14:07

Re: Delete entity problem
 
Show where you set gGMsgItemPickup (usually in plugin_init)

Neeeeeeeeeel.- 07-29-2011 14:34

Re: Delete entity problem
 
Ohh that's it, i forgot it... now i' ll test... if still work bad i will replay again.
Thank you :)

Neeeeeeeeeel.- 07-29-2011 14:42

Re: Delete entity problem
 
Works perfectly thanks.


All times are GMT -4. The time now is 00:46.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.