Re: [hlcoders] Removing entities

2004-05-04 Thread Matt Judge

David Anderson wrote:
while (!FNullEnt(tEnt)) {
const char *model = STRING(model);
Sorry, spent a few days doing other stuff, but found the problem :)
const char *model = STRING(tEnt-v.model);
Nice function, and thanks for your help.  And apologies to valve for
accusing them for breaking something they hadn't :)
Matt.
___
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders


RE: [hlcoders] Removing entities

2004-04-30 Thread Deadman Standing
1] You cannot add new spawns dynamically to CS 1.6 anymore.
2] You cannot remove spawns dynamically from CS 1.6 anymore.

Double check how you were creating entities as CREATE_NAMED_ENTITY() and
REMOVE_ENTITY() work fine in CS 1.6.



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



RE: [hlcoders] Removing entities

2004-04-30 Thread David Anderson
No, they don't.  As has been stated before, they are cached internally.
When I delete or add spawns, I get spawned at 0,0,0 and then the game
crashes.  You can CREATE_NAMED_ENTITY() just about anything but a spawn
point, and you can REMOVE_ENTITY() only things you created with
CREATE_NAMED_ENTITY().  This may have changed since I first found this out
(mid February), but try it yourself...

 -David BAILOPAN Anderson

On Fri, 30 Apr 2004, Deadman Standing wrote:

 1] You cannot add new spawns dynamically to CS 1.6 anymore.
 2] You cannot remove spawns dynamically from CS 1.6 anymore.

 Double check how you were creating entities as CREATE_NAMED_ENTITY() and
 REMOVE_ENTITY() work fine in CS 1.6.



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





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



Re: [hlcoders] Removing entities

2004-04-30 Thread Matt Judge
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


RE: [hlcoders] Removing entities

2004-04-30 Thread Deadman Standing
Aw by spawn you mean creating the entities: info_player_deathmatch,
info_player_start, or info_vip_start, if I understand you correctly?
Never tried those. I know removing any of the entities that originate in
a map is problematic. I can say I have never had issues adding or
removing the entities: info_target, func_wall, or trigger_auto as I use
them all the time. If I get some spare time I'll try playing with the
spawn entities.


No, they don't.  As has been stated before, they are cached
internally.
When I delete or add spawns, I get spawned at 0,0,0 and then the game
crashes.  You can CREATE_NAMED_ENTITY() just about anything but a
spawn
point, and you can REMOVE_ENTITY() only things you created with
CREATE_NAMED_ENTITY().  This may have changed since I first found this
out
(mid February), but try it yourself...




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



Re: [hlcoders] Removing entities

2004-04-30 Thread Matt
along the same lines.. i made a mod that worked for 1.5 that gave every
player all weapons, now in 1.6 it get to 4/5 and crashes, the code im using
is:

  for (int i=0;iMAX_CWEAPONS;i++)
  {
   edict_t *r = CREATE_NAMED_ENTITY(MAKE_STRING(cWeapons[i]));
   r-v.spawnflags |= SF_NORESPAWN;
   r-v.origin = a-v.origin + Vector(1,1,1);
   pEntity = (CBaseEntity *)GET_PRIVATE(r);
   if (pEntity)
   {
pEntity-pev-absmin = pEntity-pev-origin - Vector(1,1,1);
pEntity-pev-absmax = pEntity-pev-origin + Vector(1,1,1);
pEntity-Spawn();
  }
  }

anyone have any ideas why it crashes?


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



RE: [hlcoders] Removing entities

2004-04-30 Thread Deadman Standing
I just did a test of creating an info_player_deathmatch entity
(Terrorist spawn point in CS) and had no server crash. I was also able
to remove the spawn point without a crash. I can not guarantee that hlds
actually would use the spawn point since I have no easy way of testing
that functionality.

I looked back in the emails and found your original question David
posted on 2/15/2004 about your deathmatch mod. My geuss your problem
steamed from:

 I have tried blocking REMOVE_ENTITY calls from the CS Engine, and that
sort of works... not.  CS is still making illegal calls (and apparently,
doesn't check to see if they're valid or not).

The basic rule seems to be create it through api calls, free it through
api calls. Don't tamper with its free mechanism or pointers will get
unhappy :)

I can see blocking the REMOVE_ENTITY call as a procedure that would get
the cache out of sync.

Hope this helps.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of David
Anderson
Sent: Friday, April 30, 2004 12:01 PM
To: [EMAIL PROTECTED]
Subject: RE: [hlcoders] Removing entities

No, they don't.  As has been stated before, they are cached internally.
When I delete or add spawns, I get spawned at 0,0,0 and then the game
crashes.  You can CREATE_NAMED_ENTITY() just about anything but a spawn
point, and you can REMOVE_ENTITY() only things you created with
CREATE_NAMED_ENTITY().  This may have changed since I first found this
out
(mid February), but try it yourself...

 -David BAILOPAN Anderson

On Fri, 30 Apr 2004, Deadman Standing wrote:

 1] You cannot add new spawns dynamically to CS 1.6 anymore.
 2] You cannot remove spawns dynamically from CS 1.6 anymore.

 Double check how you were creating entities as CREATE_NAMED_ENTITY()
and
 REMOVE_ENTITY() work fine in CS 1.6.



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





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





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



RE: [hlcoders] Removing entities

2004-04-30 Thread Deadman Standing
You are referencing CBaseEntity. Since we do not have the schema they
use for that class is CS you would get crashes.

It appears the class schema differs between the SDK and Counter-Strike.
Methods or attributes were probability added to the classes.

Bottom line is you can only access edict_t data types and can use none
of the SDK class hierarchy.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Matt
Sent: Friday, April 30, 2004 4:18 PM
To: [EMAIL PROTECTED]
Subject: Re: [hlcoders] Removing entities

along the same lines.. i made a mod that worked for 1.5 that gave every
player all weapons, now in 1.6 it get to 4/5 and crashes, the code im
using
is:

  for (int i=0;iMAX_CWEAPONS;i++)
  {
   edict_t *r = CREATE_NAMED_ENTITY(MAKE_STRING(cWeapons[i]));
   r-v.spawnflags |= SF_NORESPAWN;
   r-v.origin = a-v.origin + Vector(1,1,1);
   pEntity = (CBaseEntity *)GET_PRIVATE(r);
   if (pEntity)
   {
pEntity-pev-absmin = pEntity-pev-origin - Vector(1,1,1);
pEntity-pev-absmax = pEntity-pev-origin + Vector(1,1,1);
pEntity-Spawn();
  }
  }

anyone have any ideas why it crashes?


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





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



Re: [hlcoders] Removing entities

2004-04-29 Thread Jeffrey \botman\ Broome
Matt Judge wrote:

I have seen a number of posts and articales on this, is there any chance
that you can enable people to remove entities without crashing the server?
Huh?  Are you talking about removing entities from the SDK (or from a
MOD)?  If it's MOD related, whether you can remove and entity or not
would depend on what the MOD used it for.  As an example, maps would be
completely useless if you remove the player spawn point entity from them.
We can spawn entities, look them up, modify certain aspects, why the
hell can't we delete them?
You can.

Please can we have this *bug* fixed.  I see this as a setback to anyone
trying to create a mod.
What entities specifically can't you remove if you are creating your own
MOD?
--
Jeffrey botman Broome
___
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders


Re: [hlcoders] Removing entities

2004-04-29 Thread Matt Judge


Jeffrey botman Broome wrote:

We can spawn entities, look them up, modify certain aspects, why the
hell can't we delete them?


You can.

Please can we have this *bug* fixed.  I see this as a setback to anyone
trying to create a mod.


What entities specifically can't you remove if you are creating your own
MOD?


Oh, this looks like I have got the wrong end of the stick :)

I am looking to be able to add or remove spawn points, and also remove
weapons from the CS.
Is this possible?

This is all new to me, and I am only part way through coding my first
plugin for metamod.  google searches and other peoples code have been
invaluable in finding most things I needed to know.  I have even
downloaded the archived hlcoders mailing list before posting, and my
interpretation of previous posts was that weapons could not be removed
from the game.
2 other questions I have :)

1) Is there a way to force a client to drop a weapon without issuing the
CLIENT_COMMAND(pEntity, drop)?
2) Is there an easy way to see if a shield is being carried but not
deployed?  I have these 2 bits of code which hint on a solution, but I
am hoping that asking here will give me a better insight.
// Block Server-Crash exploit
if( pPlayer-v.sequence == 86 )
   // Block shield exploit
if( pPlayer-v.sequence == 98 )
Cheers,

Matt.

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


Re: [hlcoders] Removing entities

2004-04-29 Thread Jeffrey \botman\ Broome
Matt Judge wrote:

I am looking to be able to add or remove spawn points, and also remove
weapons from the CS.
Is this possible?
Yes.  There are many people that have taken the standard 20 player maps
and made 32 player maps from them.  If you want to play around with a
metamod plugin that allows dynamically adding and remove stuff to/from a
map, take a look at my Stripper2 plugin...
http://planethalflife.com/botman/stripper2.shtml

Make sure that spawn points that are added to the map aren't placed to
close to world geometry that would collide with the player (otherwise
the player will be stuck and can't move).
2 other questions I have :)

1) Is there a way to force a client to drop a weapon without issuing the
CLIENT_COMMAND(pEntity, drop)?
That's the only method that I know of.  Clients can't block this command
(unless they are running some clientside cheat that sneaks past VAC and
intercepts server commands).
2) Is there an easy way to see if a shield is being carried but not
deployed?  I have these 2 bits of code which hint on a solution, but I
am hoping that asking here will give me a better insight.
I don't know nuthin' about no shields in Counter-Strike.

--
Jeffrey botman Broome
___
To unsubscribe, edit your list preferences, or view the list archives, please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders


Re: [hlcoders] Removing entities

2004-04-29 Thread Matt Judge


Jeffrey botman Broome wrote:

Yes.  There are many people that have taken the standard 20 player maps
and made 32 player maps from them.  If you want to play around with a
metamod plugin that allows dynamically adding and remove stuff to/from a
map, take a look at my Stripper2 plugin...
http://planethalflife.com/botman/stripper2.shtml
Adding and removing of weapons works with 1.6?  All my attempts to
remove a spawned weapon causes the server to crash :(
I have looked at your code, but I shall revisit it now :)

Matt.

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


RE: [hlcoders] Removing entities

2004-04-29 Thread Deadman Standing
Any entities you create can be removed without issue (I do it all the
time).

Deleting entities created by the game (like map spawned entities) may
cause issues with the caching mechanism introduced a few releases ago.
At least that is the word as I recall it.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Matt Judge
Sent: Thursday, April 29, 2004 4:59 PM
To: [EMAIL PROTECTED]
Subject: Re: [hlcoders] Removing entities



Jeffrey botman Broome wrote:

 Yes.  There are many people that have taken the standard 20 player
maps
 and made 32 player maps from them.  If you want to play around with a
 metamod plugin that allows dynamically adding and remove stuff to/from
a
 map, take a look at my Stripper2 plugin...

 http://planethalflife.com/botman/stripper2.shtml

Adding and removing of weapons works with 1.6?  All my attempts to
remove a spawned weapon causes the server to crash :(

I have looked at your code, but I shall revisit it now :)

Matt.


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





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



Re: [hlcoders] Removing entities

2004-04-29 Thread Matt Judge


Deadman Standing wrote:

Any entities you create can be removed without issue (I do it all the
time).
Deleting entities created by the game (like map spawned entities) may
cause issues with the caching mechanism introduced a few releases ago.
At least that is the word as I recall it.


Any sample code for me to borrow? ;)

Matt.

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


Re: [hlcoders] Removing entities

2004-04-29 Thread David Anderson

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