Raised This Month: $32 Target: $400
 8% 

[Req] Spawning entities without sv_cheats


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Throst68
Junior Member
Join Date: Apr 2018
Old 05-14-2018 , 00:26   [Req] Spawning entities without sv_cheats
Reply With Quote #1

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.)
Throst68 is offline
LenHard
Senior Member
Join Date: Jan 2016
Old 05-15-2018 , 04:50   Re: [Req] Spawning entities without sv_cheats
Reply With Quote #2

Quote:
Originally Posted by Throst68 View Post
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.
__________________
LenHard is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 05-15-2018 , 11:32   Re: [Req] Spawning entities without sv_cheats
Reply With Quote #3

Quote:
Originally Posted by LenHard View Post
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?
ThatKidWhoGames is offline
Rachnus
Senior Member
Join Date: Jun 2016
Location: Funland
Old 05-15-2018 , 18:00   Re: [Req] Spawning entities without sv_cheats
Reply With Quote #4

https://forums.alliedmods.net/showthread.php?t=307573
__________________
Github: https://github.com/jimppan
Steam: http://steamcommunity.com/id/jimppan
_____________________________________________ _________
Taking private requests
Rachnus is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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