AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to recreate some entities (https://forums.alliedmods.net/showthread.php?t=52124)

KWo 03-03-2007 16:40

How to recreate some entities
 
With the new CSDM 2.1 at activating the mod some entities get removed from the map (hostage rescue zones, hostages, bomb zones, bomb, vip escape zones, some weapons they are on fy_xx maps on the ground etc). My problem is - if someone wants to disable CSDM - these entities should be recreated to continue the game with normal CS playing.
I have no idea what the data should I store (to use it later to recreate those entities), how to do it (in which moment I should store it etc). And also I don't know how should look the correct procedure with setting the properties of the recreated entity and the right moment with recreating it.
I'm a person which can get the idea of coding when I have the working example of code and some theory. If there is only the theory - it's nothing for me.
So if someone could write for me the working example of recreating for one of these entities listed above with eventually the info what should I store and then use with recreate for others entities - it would be sufficient for me and I will be very thankful.

XxAvalanchexX 03-03-2007 18:04

Re: How to recreate some entities
 
Example of brush-based entites (tested and works):

Code:
#include <amxmodx>  #include <fakemeta>  #define MAX_RZONES 10  #define CLASS_RZONE    "func_hostage_rescue"  new rZoneCount, Float:rZoneMins[MAX_RZONES], Float:rZoneMaxs[MAX_RZONES];  public plugin_init()  {     register_clcmd("say kill","kill");     register_clcmd("say make","make");     new ent;     while((ent = engfunc(EngFunc_FindEntityByString,ent,"classname",CLASS_RZONE)) != 0)     {         pev(ent,pev_absmin,rZoneMins[rZoneCount]);         pev(ent,pev_absmax,rZoneMaxs[rZoneCount]);         if(++rZoneCount >= MAX_RZONES) break;     }  }  public kill(id)  {     new ent;     while((ent = engfunc(EngFunc_FindEntityByString,ent,"classname",CLASS_RZONE)) != 0)         engfunc(EngFunc_RemoveEntity,ent);     client_print(id,print_chat,"* Removed entities");     return PLUGIN_HANDLED;  }  public make(id)  {     new i, ent;     for(i=0;i<rZoneCount;i++)     {         ent = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,CLASS_RZONE));         dllfunc(DLLFunc_Spawn,ent);         engfunc(EngFunc_SetSize,ent,rZoneMins[i],rZoneMaxs[i]);     }     client_print(id,print_chat,"* Remade entites");     return PLUGIN_HANDLED;  }

Still working on point-based entities.

XxAvalanchexX 03-03-2007 18:22

Re: How to recreate some entities
 
This works on point-based entities.

Code:
#include <amxmodx>  #include <fakemeta>  #define MAX_HOSTAGES   10  #define CLASS_HOSTAGE  "hostage_entity"  new hostageCount, Float:hostageOrigin[MAX_HOSTAGES][3], Float:hostageAngles[MAX_HOSTAGES][3],  hostageModel[MAX_HOSTAGES][32], hostageSkin[MAX_HOSTAGES];  public plugin_init()  {     register_clcmd("say kill","kill");     register_clcmd("say make","make");     new ent;     while((ent = engfunc(EngFunc_FindEntityByString,ent,"classname",CLASS_HOSTAGE)) != 0)     {         pev(ent,pev_origin,hostageOrigin[hostageCount]);         pev(ent,pev_angles,hostageAngles[hostageCount]);         pev(ent,pev_model,hostageModel[hostageCount],31);         hostageSkin[hostageCount] = pev(ent,pev_skin);         if(++hostageCount >= MAX_HOSTAGES) break;     }  }  public kill(id)  {     new ent;     while((ent = engfunc(EngFunc_FindEntityByString,ent,"classname",CLASS_HOSTAGE)) != 0)         engfunc(EngFunc_RemoveEntity,ent);     client_print(id,print_chat,"* Removed entities");     return PLUGIN_HANDLED;  }  public make(id)  {     new i, ent;     for(i=0;i<hostageCount;i++)     {         ent = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,CLASS_HOSTAGE));         engfunc(EngFunc_SetModel,ent,hostageModel[i]);         set_pev(ent,pev_skin,hostageSkin[i]);         dllfunc(DLLFunc_Spawn,ent);         engfunc(EngFunc_SetOrigin,ent,hostageOrigin[i]);         set_pev(ent,pev_angles,hostageAngles[i]);     }     client_print(id,print_chat,"* Remade entites");     return PLUGIN_HANDLED;  }

However, there is a catch: this doesn't work with Condition Zero hostages; the game crashes shortly after spawning them. However, I tested it in regular Counter-Strike, and it worked succesfully.

teame06 03-03-2007 19:18

Re: How to recreate some entities
 
Code:
    register_clcmd("say kill","kill");  public kill(id)  {     new ent;     while((ent = engfunc(EngFunc_FindEntityByString,ent,"classname",CLASS_HOSTAGE)) != 0)         engfunc(EngFunc_RemoveEntity,ent);     client_print(id,print_chat,"* Removed entities");     return PLUGIN_HANDLED;  }

This code will make linux server crash when hostages are removed.

XxAvalanchexX 03-03-2007 19:25

Re: How to recreate some entities
 
Oh. What for?

teame06 03-03-2007 21:10

Re: How to recreate some entities
 
Counter Strike cache the hostage into memory somewhere. For windows it doesn't care if you remove hostage but for linux it does care. It will crash the server on the hostage removal. You have to hook FM_Spawn and remove it before the server caches the hostage.

KWo 03-04-2007 15:19

Re: How to recreate some entities
 
Quote:

Originally Posted by XxAvalanchexX (Post 448188)
Example of brush-based entites (tested and works):

Code:
(...)  public plugin_init()  {     register_clcmd("say kill","kill");     register_clcmd("say make","make");     new ent;     while((ent = engfunc(EngFunc_FindEntityByString,ent,"classname",CLASS_RZONE)) != 0)     {         pev(ent,pev_absmin,rZoneMins[rZoneCount]);         pev(ent,pev_absmax,rZoneMaxs[rZoneCount]);         if(++rZoneCount >= MAX_RZONES) break;     }  } (...)  }

Thanks, but I really don't need to have more data stored about func_hostage_rescue?
What about "info_hostage_rescue"? what the data should be stored (as sufficient to recreate it)? The same about the bomb Ts are carrying on their back.

Quote:

Originally Posted by teame06 (Post 448261)
Counter Strike cache the hostage into memory somewhere. For windows it doesn't care if you remove hostage but for linux it does care. It will crash the server on the hostage removal. You have to hook FM_Spawn and remove it before the server caches the hostage.

It does care also for windows CS1.6/CZERO steam. It didn't care for old CS1.5 under windows. :)

teame06 03-04-2007 15:40

Re: How to recreate some entities
 
Quote:

Originally Posted by KWo
It does care also for windows CS1.6/CZERO steam. It didn't care for old CS1.5 under windows.

No, it does not care if you remove hostages in windows. I just tried the code above to remove hostages on windows and on my hlds test server for 1.6.

It is linux server that only care and will crash if you remove hostages at any other time then FM_Spawn from my experience when I had a linux server.
Also that why CSDM and Twisted DeathMatch uses that method.

XxAvalanchexX 03-04-2007 16:01

Re: How to recreate some entities
 
KWo: For info_hostage_rescue, probably all you need to store is the origin. Also, there is no entity for the bomb on a Terrorist's back.

I don't know if it would work for you, but if you can find your way through GunGame's code you can see how I dynamically switch between objectives enabled and disabled (just search for gg_block_objectives).

KWo 03-05-2007 05:28

Re: How to recreate some entities
 
Quote:

Originally Posted by teame06 (Post 448646)
No, it does not care if you remove hostages in windows. I just tried the code above to remove hostages on windows and on my hlds test server for 1.6.

I'll re-phrase then - it was crashing (tested about 6 months ago) depanding of how many players/or bots I had on the server. For some reason - if there was about 8 bots/players on the windows server it wasn't crashing, but when I had there 20 bots it was crashing. No idea why that number of players could deal with that.
@XxAvalanchexX - thank You. I'll try Your methods. :)


All times are GMT -4. The time now is 13:07.

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