Help!


(I have never coded for 1.5, but I am beginning to wish I had.  Are they
going to make it this hard for us to do stuff in HL2?)

The DeleteCSWeapon is not working for me.

DeleteCSWeapon("models/w_awp.mdl","weapon_awp",index);

Am I using this wrong?

If I call this function when the player is carrying an AWP and there is
also an AWP on the floor, the server crashes.

Here is my code (I added your solidstate stuff to it):

void GiveNamedItem(edict_t *pEdict, const char *pszName)
{
       if(strncmp(pszName,"weapon_",7) == 0||
strncmp(pszName,"item_",5) == 0|| strncmp(pszName,"ammo_",5) == 0)
       {
               edict_t *pent;
               int istr = MAKE_STRING(pszName);
               pent = CREATE_NAMED_ENTITY(istr);
               if(FNullEnt(pent))
               {
                       ALERT(at_console, "NULL Ent in GiveNamedItem!\n");
                       return;
               }

               VARS(pent)->origin = VARS(pEdict)->origin;
               pent->v.spawnflags |= SF_NORESPAWN;

               (*gpGamedllFuncs->dllapi_table->pfnSpawn)(pent);
               int solidstate = pent->v.solid;
               (*gpGamedllFuncs->dllapi_table->pfnTouch)(pent, pEdict);

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

And your code copied as is (pretty much).
void DeleteWeapon(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);
               UTIL_LogPrintf("DeleteWeapon: %s\n",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
}




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



Reply via email to