Quote:
Originally Posted by Throst68
i feel like this should already exist but for some reason i haven't been able to find it.
all entities, not just halloween bosses. (health packs, sentry guns, spell books, ect.)
|
PHP Code:
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1
#pragma newdecls required
public void OnPluginStart()
{
RegConsoleCmd("sm_spawnentity", Cmd_SpawnEntity, "Spawns an entity by name");
}
public Action Cmd_SpawnEntity(int client, int args)
{
if (IsClientInGame(client))
{
if (IsPlayerAlive(client))
{
if (args == 0)
{
ReplyToCommand(client, "[SM] Usage: sm_spawnentity [entity name]");
return Plugin_Handled;
}
char[] sCmd = new char[100];
GetCmdArgString(sCmd, 100);
float fCOrigin[3]; GetClientEyePosition(client, fCOrigin);
float fCAngles[3]; GetClientEyeAngles(client, fCAngles);
Handle hTraceRay = TR_TraceRayFilterEx(fCOrigin, fCAngles, MASK_PLAYERSOLID, RayType_Infinite, FilterPlayers);
if (TR_DidHit(hTraceRay)) TR_GetEndPosition(fCOrigin, hTraceRay);
delete hTraceRay;
GetClientAbsAngles(client, fCAngles);
int iEnt = CreateEntityByName(sCmd);
if (IsValidEntity(iEnt) && DispatchSpawn(iEnt))
TeleportEntity(iEnt, fCOrigin, fCAngles, NULL_VECTOR);
else ReplyToCommand(client, "[SM] The entity '%s' is invalid.", sCmd);
}
else ReplyToCommand(client, "[SM] You must be alive to use this command.");
}
return Plugin_Handled;
}
public bool FilterPlayers(int iEntity, any aContentsMask)
{
if (0 < iEntity <= MaxClients)
return false;
return true;
}
Not sure if I did what you asked, but here.
__________________