AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] find_sphere_class On Bots (https://forums.alliedmods.net/showthread.php?t=317891)

hellmonja 08-03-2019 15:01

[HELP] find_sphere_class On Bots
 
So I'm using find_sphere_class to find players around a certain area but it only works when I'm near said area. When only the bots are there nothing happens. First my question is does find_sphere_class work on bots? And if it doesn't, how do I include the bots?...

hellmonja 08-03-2019 15:05

Re: [HELP] find_sphere_class On Bots
 
I'm sorry. Somehow it works now. I'm not sure what happened the first few times I tried it. You can close the thread now. Sorry again for the bother...

edon1337 08-03-2019 15:49

Re: [HELP] find_sphere_class On Bots
 
It doesn't skip bots.
PHP Code:

static cell AMX_NATIVE_CALL find_sphere_class(AMX *amxcell *params// find_sphere_class(aroundent, _lookforclassname[], Float:radius, entlist[], maxents, Float:origin[3] = {0.0, 0.0, 0.0}); // 6 params
{
    
// params[1] = index to find around, if this is less than 1 then use around origin in last parameter.
    // params[2] = classname to find
    
int len;
    
charclassToFind MF_GetAmxString(amxparams[2], 0, &len);
    
// params[3] = radius, float...
    
REAL radius =amx_ctof(params[3]);
    
// params[4] = store ents in this list
    
cell *entList MF_GetAmxAddr(amxparams[4]);
    
// params[5] = maximum ents to store in entlist[] in params[4]
    // params[6] = origin, use this if params[1] is less than 1

    
vec3_t vecOrigin;
    if (
params[1] > 0) {
        
CHECK_ENTITY(params[1]);

        
edict_tpEntity TypeConversion.id_to_edict(params[1]);
        
vecOrigin pEntity->v.origin;
    } else {
        
cell *cAddr MF_GetAmxAddr(amxparams[6]);
        
vecOrigin Vector(amx_ctof(cAddr[0]), amx_ctof(cAddr[1]), amx_ctof(cAddr[2]));
    }
    
    
int entsFound 0;
    
edict_tpSearchEnt TypeConversion.id_to_edict(0);

    while (
entsFound params[5]) {
        
pSearchEnt FIND_ENTITY_IN_SPHERE(pSearchEntvecOriginradius); // takes const float origin
        
if (FNullEnt(pSearchEnt))
            break;
        else {
            if (
strcmp(STRING(pSearchEnt->v.classname), classToFind) == 0) {
                
// Add to entlist (params[4])
                
entList[entsFound++] = TypeConversion.edict_to_id(pSearchEnt); // raise entsFound
            
}
        }
    }

    return 
entsFound;




All times are GMT -4. The time now is 17:22.

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