forked from UNLOZE/sm-plugins
SourceMod 1.10 and new OnEntitySpawned forward
This commit is contained in:
@@ -18,6 +18,7 @@ int g_MaxWeaponLifetime;
|
||||
#define MAX_WEAPONS MAXPLAYERS
|
||||
int G_WeaponArray[MAX_WEAPONS][2];
|
||||
|
||||
bool g_bEngineVersionIsCSGO = false;
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
@@ -42,6 +43,8 @@ public void OnPluginStart()
|
||||
|
||||
AutoExecConfig(true, "plugin.WeaponCleaner");
|
||||
|
||||
g_bEngineVersionIsCSGO = (GetEngineVersion() == Engine_CSGO);
|
||||
|
||||
for(int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if(IsClientInGame(client))
|
||||
@@ -104,9 +107,6 @@ public void OnClientPutInServer(int client)
|
||||
|
||||
public void OnClientDisconnect(int client)
|
||||
{
|
||||
SDKUnhook(client, SDKHook_WeaponDropPost, OnWeaponDrop);
|
||||
SDKUnhook(client, SDKHook_WeaponEquipPost, OnWeaponEquip);
|
||||
|
||||
if(!IsClientInGame(client))
|
||||
return;
|
||||
|
||||
@@ -119,14 +119,6 @@ public void OnClientDisconnect(int client)
|
||||
}
|
||||
}
|
||||
|
||||
public void OnEntityCreated(int entity, const char[] classname)
|
||||
{
|
||||
if(IsValidEntity(entity) && strncmp(classname, "weapon_", 7) == 0)
|
||||
{
|
||||
SDKHook(entity, SDKHook_Spawn, OnWeaponSpawned);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnEntityDestroyed(int entity)
|
||||
{
|
||||
// wtf sourcemod?
|
||||
@@ -136,20 +128,12 @@ public void OnEntityDestroyed(int entity)
|
||||
RemoveWeapon(EntIndexToEntRef(EntRefToEntIndex(entity)));
|
||||
}
|
||||
|
||||
public void OnWeaponSpawned(int entity)
|
||||
public void OnEntitySpawned(int entity, const char[] classname)
|
||||
{
|
||||
static bool bEngineVersionIsCSGO;
|
||||
|
||||
// This hook calls twice and before entities are initialized on csgo, delay it by a frame.
|
||||
if (bEngineVersionIsCSGO || GetEngineVersion() == Engine_CSGO)
|
||||
if(strncmp(classname, "weapon_", 7) == 0)
|
||||
{
|
||||
bEngineVersionIsCSGO = true;
|
||||
|
||||
SDKUnhook(entity, SDKHook_Spawn, OnWeaponSpawned);
|
||||
|
||||
RequestFrame(OnWeaponSpawnedPost, entity);
|
||||
OnWeaponSpawnedPost(entity);
|
||||
}
|
||||
else OnWeaponSpawnedPost(entity);
|
||||
}
|
||||
|
||||
public void OnWeaponSpawnedPost(int entity)
|
||||
|
||||
Reference in New Issue
Block a user