AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [Req] Spawning entities without sv_cheats (https://forums.alliedmods.net/showthread.php?t=307528)

Throst68 05-14-2018 00:26

[Req] Spawning entities without sv_cheats
 
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.)

LenHard 05-15-2018 04:50

Re: [Req] Spawning entities without sv_cheats
 
Quote:

Originally Posted by Throst68 (Post 2592089)
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 clientint 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(sCmd100);
            
            
float fCOrigin[3]; GetClientEyePosition(clientfCOrigin);
            
float fCAngles[3]; GetClientEyeAngles(clientfCAngles);
        
            
Handle hTraceRay TR_TraceRayFilterEx(fCOriginfCAnglesMASK_PLAYERSOLIDRayType_InfiniteFilterPlayers);
        
            if (
TR_DidHit(hTraceRay)) TR_GetEndPosition(fCOriginhTraceRay);
            
delete hTraceRay;
            
            
GetClientAbsAngles(clientfCAngles);
            
            
int iEnt CreateEntityByName(sCmd);
            
            if (
IsValidEntity(iEnt) && DispatchSpawn(iEnt))
                
TeleportEntity(iEntfCOriginfCAnglesNULL_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 iEntityany aContentsMask
{
    if (
iEntity <= MaxClients)
        return 
false;
    return 
true;


Not sure if I did what you asked, but here.

ThatKidWhoGames 05-15-2018 11:32

Re: [Req] Spawning entities without sv_cheats
 
Quote:

Originally Posted by LenHard (Post 2592236)
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 clientint 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(sCmd100);
            
            
float fCOrigin[3]; GetClientEyePosition(clientfCOrigin);
            
float fCAngles[3]; GetClientEyeAngles(clientfCAngles);
        
            
Handle hTraceRay TR_TraceRayFilterEx(fCOriginfCAnglesMASK_PLAYERSOLIDRayType_InfiniteFilterPlayers);
        
            if (
TR_DidHit(hTraceRay)) TR_GetEndPosition(fCOriginhTraceRay);
            
delete hTraceRay;
            
            
GetClientAbsAngles(clientfCAngles);
            
            
int iEnt CreateEntityByName(sCmd);
            
            if (
IsValidEntity(iEnt) && DispatchSpawn(iEnt))
                
TeleportEntity(iEntfCOriginfCAnglesNULL_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 iEntityany aContentsMask
{
    if (
iEntity <= MaxClients)
        return 
false;
    return 
true;


Not sure if I did what you asked, but here.

Wouldn't it be a lot better to check if the entity is valid before performing all of those other operations?

Rachnus 05-15-2018 18:00

Re: [Req] Spawning entities without sv_cheats
 
https://forums.alliedmods.net/showthread.php?t=307573


All times are GMT -4. The time now is 14:43.

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