|
AMX Mod X Beta Tester
Join Date: Jul 2004
Location: Poland
|

04-20-2008
, 01:29
Re: Back Weapons v1.86
|
#266
|
Quote:
Originally Posted by Cheap_Suit
The problem is that the function it was hooked on wasnt catching when weapons are dropped. This should be fixed in v1.86. However, there is a bug when weapons are stripped. Im still trying to find a way to catch when it happens.
|
OK - now I know what might be the reason You have troubles with bots... The function which catches the weapon drop event doesn't work at all on bots. You cannot use it with bots. We had the same problem with CSDM - the bot was droping the weapon, and the weapon instead disapearing was laying on the ground. In the effect - the amount of laying weapons was increasing (the amount of entities) and the server was starting to lag as hell... I have found the method to solve this - with SetModel function.
Code:
in plugin_init()
register_forward(FM_SetModel, "forward_set_model")
later
public forward_set_model(ent, const model[])
{
if (!csdm_active())
return FMRES_IGNORED
if (!pev_valid(ent) || !equali(model, g_wbox_model) && !equali(model, g_shield_model))
return FMRES_IGNORED
new id = pev(ent, pev_owner)
if (!(1 <= id <= g_max_clients))
return FMRES_IGNORED
new args[2]
args[0] = ent
args[1] = id
set_task(0.2, "delay_find_weapon", ent, args, 2) // You need this delay - believe me...
return FMRES_IGNORED
}
public delay_find_weapon(args[])
{
new ent = args[0]
new id = args[1]
new class[32]
if (!pev_valid(ent))
return
if (!is_user_connected(id))
return
pev(ent, pev_classname, class, sizeof class - 1)
if (equali(class, "weaponbox"))
run_drop_wbox(id, ent)
else if (equali(class, "weapon_shield"))
run_drop_wbox(id, -1)
}
run_drop_wbox(id, ent)
{
new ret
new model[32]
ExecuteForward(g_drop_fwd, ret, id, ent, 0)
if (ret == CSDM_DROP_REMOVE)
{
csdm_remove_weaponbox(id, ent, 0, 1)
return 1
}
else if (ret == CSDM_DROP_IGNORE)
{
return 0
}
if (g_StayTime > 20 || g_StayTime < 0)
{
return 0
}
if (ent == -1)
{
csdm_remove_weapon(id, "weapon_shield", g_StayTime, 1)
return 1
}
if (ent)
{
pev(ent, pev_model, model, 31)
if (((equali(model,"models/w_usp.mdl")) || (equali(model,"models/w_glock18.mdl")))
&& (g_StripWeapons))
csdm_remove_weaponbox(id, ent, 0, 0)
else if ((equali(model,"models/w_backpack.mdl")) && (g_RemoveBomb))
csdm_remove_weaponbox(id, ent, 0, 0)
else
csdm_remove_weaponbox(id, ent, g_StayTime, 1)
return 1
}
return 0
}
and in the csdm module:
Code:
static cell AMX_NATIVE_CALL csdm_remove_weaponbox(AMX *amx, cell *params)
{
// Check index.
unsigned int owner = params[1];
unsigned int ent = params[2];
if (owner < 1 || owner > (unsigned int)gpGlobals->maxClients)
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", owner);
return 0;
} else if (!MF_IsPlayerIngame(owner)) {
MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not in game", owner);
return 0;
}
edict_t *searchEnt = INDEXENT(ent);
if (FNullEnt(searchEnt))
{
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid weaponbox %d", ent);
return 0;
} else if (strcmp(STRING(searchEnt->v.classname),"weaponbox") != 0) {
MF_LogError(amx, AMX_ERR_NATIVE, "Not a weaponbox %d", ent);
return 0;
}
edict_t *pEdict = MF_GetPlayerEdict(owner);
edict_t *pWeapEdict = g_engfuncs.pfnPEntityOfEntIndex(gpGlobals->maxClients + 1);
for (int i = gpGlobals->maxClients + 1; i < gpGlobals->maxEntities; i++, pWeapEdict++)
{
if (pWeapEdict == NULL)
continue;
if (pWeapEdict->free)
continue;
if ((pWeapEdict->v.flags & FL_FAKECLIENT) || (pWeapEdict->v.flags & FL_CLIENT))
continue;
if (pWeapEdict->v.owner == searchEnt)
{
if (!params[3] || !params[4])
{
if (NotifyForRemove(owner, pWeapEdict, searchEnt))
{
REMOVE_ENTITY(pWeapEdict);
REMOVE_ENTITY(searchEnt);
}
/*
else
ALERT(at_logged, "CSDM - can't remove weapon of %s - notify for remove failed....\n", STRING(pEdict->v.netname));
*/
}
else
{
FindWeapon *p = FindWeapon::NewFindWeapon(pEdict, STRING(pWeapEdict->v.classname), params[3]);
g_Timer.AddTask(p, 0.1);
return 1;
RemoveWeapon::SchedRemoval(params[3], pEdict, searchEnt, pWeapEdict);
}
return 1;
}
}
return 0;
}
There is a lot of things You don't need, like removing the weapon after certain time with SchedRemoval, but I believe if You will read carefully this You will get the point...BAILOPAN didn't like my method, by since he haven't have time to better figure it out, this method works perfectly in my CSDM beta. I hope that can help You a bit.
__________________
The Fullpack of podbot mm V3B22 - 24 apr 2012!!! is available here.
The All-In-One 3.2a package - 02 jun 2013 ( AMX X 1.8.2 [with ATAC 3.0.1b , CSDM2.1.3c beta, CM OE 0.6.5, podbot mm V3B22c and mm 1.20) is available here.
The newest Beta V3B23a (rel. 28 august 2018!!!) is available here.
|
|