There are serval things you're doing wrong here:
1) You cant set spawn locations with z_spawn, there is no argument for it.
2) Why are you creating fake clients to execute a command? Get a random client instead.
3) You should use z_spawn_old instead, z_spawn seems broken in special cases (like z_spawn auto doesn't work at all).
4) In some maps or gamemodes (versus) VScripts may interfere with spawning use
Director Unlocker to uncap the limits.
PHP Code:
#include <sourcemod>
#include <sdktools>
int g_lastSpawn;
public void OnPluginStart()
{
HookEvent("player_spawn", OnPlayerSpawn);
}
public void OnPlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
g_lastSpawn = client;
}
void SpawnInfected()
{
//Get random client to execute command.
int client;
for (int i = 1; i <= MaxClients; i++)
{
if (!IsClientInGame(i))
continue;
client = i;
break;
}
//If no client was found, we should abort.
if (client < 1)
return;
//Spawn infected
//Make 'name' static, keeps it in memory so it doesn't need to initalize everytime. Doesn't change anyways.
static char spawn[][32] = {"charger", "spitter", "jockey"};
for (int i = 1; i <= 6; i++)
{
//Set the it to -1 so we can check if the spawn was successfull or not.
g_lastSpawn = -1;
//z_spawn spawns an infected, which executes player_spawn in the same frame and fills the g_lastSpawn variable with its index.
//If you want to spawn them automatically use "z_spawn_old auto" instead. Without the teleport below.
CheatCommand(client, "z_spawn_old", spawn[GetRandomInt(0, sizeof(spawn) - 1)]);
int infected = g_lastSpawn;
if (infected > 0)
{
TeleportEntity(infected, pos, NULL_VECTOR, NULL_VECTOR);
}
}
}
Quote:
Originally Posted by Halt
Perhaps you could try
PHP Code:
SetCommandFlags("z_minion_limit", (GetCommandFlags("z_minion_limit") - FCVAR_CHEAT));
Changes the command flags.
|
That makes no difference. And you using it incorrecly, use
bitwise operators for flags.