Some things I found (while making CSDM) on CS entities:

1] You cannot add new spawns dynamically to CS 1.6 anymore.
2] You cannot remove spawns dynamically from CS 1.6 anymore.
3] You can create weapons in two ways - spawning them (in CS 1.6 they will
disappear after 2 seconds though) or by creating "fake ones" and hooking
Touch()
4] You can remove weapons from CS still... you can look into the archives
and see me begging Alfred to help me with this :] but that was met with
nothing.  Calling a weapon's Think() function will destroy it... in
Metamod that's MDLL_Think(edict_t *).  I have not tested deleting spawns
because that is no longer useful to me (now I created an algorithm to use
the old spawns and set origins.

Note that this is how you should remove
weapons: Find the "weaponbox" that has the target weapon model, then
remove the actual entity that has the weapon as the classname, whose owner
is the weaponbox entity.

5] You can test if a player has a shield by seeing what model they have I
think.  That is how many AMX Mod * plugins do it.

To spawn weapons in CS what I did was make my own internally cached "fake"
weapon entities, which are stored in a hash array... then when a player
touches them, I use the item giving code from OLO's fun module.

I'll give you code because I spent weeks figuring this out :] If Valve
decides to break it again in a future update, I will probably quit because
too many people would harass me to fix it :\ but since they are not
obligated to not break it, be aware that this may not work in the future.

     -----David "BAILOPAN" Anderson
     http://www.amxmodx.org/

Example code for giving a CS weapon:

        int iWeapon = ALLOC_STRING("weapon_awp");
        edict_t *pWeapon = CREATE_NAMED_ENTITY(iWeapon);
        if (FNullEnt(pWeapon))
                return;
        pWeapon->v.origin = pEntity->v.origin;
        pWeapon->v.spawnflags |= SF_NORESPAWN;

        MDLL_Spawn(pWeapon);
        int solidstate = pWeapon->v.solid;
        MDLL_Touch(pWeapon, ENT(pEntity));

        if (pWeapon->v.solid == solidstate)
                REMOVE_ENTITY(pWeapon);

Example code for destroying a CS weapon:

#ifdef STEAM
#define RemoveWeapon(x) MDLL_Think(x)
#else
#define RemoveWeapon(x) REMOVE_ENTITY(x)
#endif

void DeleteCSWeapon(char *weaponmodel, char *weapon, int player)
{
        edict_t *pPlayer = INDEXENT(player);
        edict_t *tEnt = FIND_ENTITY_BY_STRING(NULL, "classname",
"weaponbox");
        edict_t *wEnt = NULL;
        while (!FNullEnt(tEnt)) {
                const char *model = STRING(model);
                if (strcmp(model, weaponmodel)==0) {
                        if (ENTINDEX(tEnt->v.owner)==player) {
                                wEnt = FIND_ENTITY_BY_STRING(NULL,
"classname", weapon);
                                while (!FNullEnt(wEnt)) {
                                        if
(ENTINDEX(wEnt->v.owner)==ENTINDEX(tEnt)) {
                                                RemoveWeapon(wEnt);
                                        }
                                        wEnt = FIND_ENTITY_BY_STRING(wEnt,
"classname", weapon);
                                } //finding wEnts
                        } //owners matched
                        RemoveWeapon(tEnt);
                } //weapon matched
                tEnt = FIND_ENTITY_BY_STRING(tEnt, "classname",
"weaponbox");
        } //finding tEnts
}

Code for spawning a permanent weapon the ground: build your own give
weapon wrapper :]


_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to