Raised This Month: $75 Target: $400
 18% 

[ANY] Entity Toggler


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Ecclesiastical
New Member
Join Date: Jun 2016
Location: United State of M
Plugin ID:
5263
Plugin Version:
Plugin Category:
General Purpose
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    An Plugin to Enable/Disable Entities.
    Old 06-27-2016 , 07:05   [ANY] Entity Toggler
    Reply With Quote #1

    An Entity Toggler I wrote for Disabling Func_no_builds and other Entities for tf2, but should work for Any Game;


    Code:
    #include <sourcemod>
    #include <sdktools>
     
    public Plugin myinfo =
    {
        name = "Ent Toggler",
        author = "Ecclesiastical",
        description = "Toggle Entities and such",
        version = "3.3.3",
        url = "http://xt6zo6bcjbrrjyvr.onion"
    }
     
    public void OnPluginStart()
    {
        RegAdminCmd("sm_toggleent_admin", Command_EntToggler, ADMFLAG_SLAY);
        RegAdminCmd("sm_enthealth_admin", Command_EntHealth, ADMFLAG_SLAY);
        RegAdminCmd("sm_entcolor_admin", Command_EntColor, ADMFLAG_SLAY);
        RegAdminCmd("sm_entmodel_admin", Command_EntModel, ADMFLAG_SLAY);
        RegConsoleCmd("sm_toggleent", Command_EntToggler, "Toggle an Entity;");
        RegConsoleCmd("sm_enthealth", Command_EntHealth, "Set an Entity's Health;");
        RegConsoleCmd("sm_entcolor", Command_EntColor, "Set an Entity's Color;");
        RegConsoleCmd("sm_entmodel", Command_EntModel, "Set an Entity's Model;");
    }
     
    public Action Command_EntToggler(client, args)
    {
        char arg1[64];
        char arg2[64];
        char name[MAX_NAME_LENGTH];
        
        if (args < 1)
        {
          ReplyToCommand(client, "[SM] Usage: sm_toggleent <Entity> <Input>");
          return Plugin_Handled;
        }
     
        GetCmdArg(1, arg1, sizeof(arg1));
        GetCmdArg(2, arg2, sizeof(arg2));
        
        new horse = FindEntityByClassname(-1, arg1);
            
        for(new x = 0; x > horse; x++) 
        {
            AcceptEntityInput(horse, arg2);
        }
    
        GetClientName(client, name, sizeof(name));
        ReplyToCommand(client, "[SM] You Toggled The %s Entity", arg1);
     
        return Plugin_Handled;
    }
    
    public Action Command_EntHealth(client, args)
    {
        char arg1[64];
        char arg2[64];
        char name[MAX_NAME_LENGTH];
        
        if (args < 2)
        {
          ReplyToCommand(client, "[SM] Usage: sm_enthealth <Entity> <Health>");
          return Plugin_Handled;
        }
     
        GetCmdArg(1, arg1, sizeof(arg1));
        GetCmdArg(2, arg2, sizeof(arg2));
        
        new horse = FindEntityByClassname(-1, arg1);
        new turtle = StringToInt(arg2);
        
        for(new x = 0; x > horse; x++) 
        {
            SetEntityHealth(horse, turtle);
        }
        
        GetClientName(client, name, sizeof(name));
        ReplyToCommand(client, "[SM] %s's Health is now %d", arg1, turtle);
     
        return Plugin_Handled;
    }
    
    public Action Command_EntColor(client, args)
    {
        char arg1[64];
        char arg2[64];
        char arg3[64];
        char arg4[64];
        char arg5[64];
        char name[MAX_NAME_LENGTH];
    
        if (args < 3)
        {
          ReplyToCommand(client, "[SM] Usage: sm_entcolor <entity> <Red 0-255> <Green 0-255> <blue 0-255> <alpha 0-255>");
          return Plugin_Handled;
        }
     
        GetCmdArg(1, arg1, sizeof(arg1));
        GetCmdArg(2, arg2, sizeof(arg2));
        GetCmdArg(3, arg3, sizeof(arg3));
        GetCmdArg(4, arg4, sizeof(arg4));
        GetCmdArg(5, arg5, sizeof(arg5));
        
        new horse = FindEntityByClassname(-1, arg1);
        
        new donkey = StringToInt(arg2);
        new penguin = StringToInt(arg3);
        new anteater = StringToInt(arg4);
        new angel = StringToInt(arg5);
            
        for(new x = 0; x > horse; x++) 
        {
            SetEntityRenderColor(horse, donkey, penguin, anteater, angel);
        }
        
        GetClientName(client, name, sizeof(name));
        ReplyToCommand(client, "[SM] You Changed %s's color Red: %d; Green: %d; Blue: %d; Alpha: %d ", horse, donkey, penguin, anteater, angel);
     
        return Plugin_Handled;
    }
    
    public Action Command_EntModel(client, args)
    {
        char arg1[64];
        char arg2[64];
        char name[MAX_NAME_LENGTH];
        
        if (args < 3)
        {
          ReplyToCommand(client, "[SM] Usage: sm_entmodel <entity > <model>");
          return Plugin_Handled;
        }
     
        GetCmdArg(1, arg1, sizeof(arg1));
        GetCmdArg(2, arg2, sizeof(arg2));
        
        new horse = FindEntityByClassname(-1, arg1);
        
        for(new x = 0; x > horse; x++) 
        {
            SetEntityModel(horse, arg2);
        }
    
        GetClientName(client, name, sizeof(name));
        ReplyToCommand(client, "[SM] The Model for %s has been changed to %s", arg1, arg2);
     
        return Plugin_Handled;
    }
    For Joanne;
    Ecclesiastical is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 06-27-2016 , 10:05   Re: [ANY] Entity Toggler
    Reply With Quote #2

    Interesting, however you should upload a .sp file, instead of posting the code in the thread.
    Also this bothers me:
    Code:
        new horse = FindEntityByClassname(-1, arg1);
        
        for(new x = 0; x > horse; x++) 
        {
            //XXXXXXXXXXX
        }
    How does this code even do anything at all?
    Also your naming conventions is pretty interesting but also inconsiderate to a reader, as it doesn't explain what the variable is storing.
    __________________
    Mitchell is offline
    Horsedick
    AlliedModders Donor
    Join Date: Sep 2011
    Old 06-27-2016 , 19:58   Re: [ANY] Entity Toggler
    Reply With Quote #3

    *the code calls my name....*
    Horsedick is offline
    xXDeathreusXx
    Veteran Member
    Join Date: Mar 2013
    Location: *pPlayer->GetOrigin()
    Old 06-27-2016 , 20:29   Re: [ANY] Entity Toggler
    Reply With Quote #4

    Quote:
    Originally Posted by Mitchell View Post
    Code:
        new horse = FindEntityByClassname(-1, arg1);
        
        for(new x = 0; x > horse; x++) 
        {
            //XXXXXXXXXXX
        }
    How does this code even do anything at all?
    I'm puzzled at this myself, logically, it would do absolutely fuck all

    Quote:
    Originally Posted by Horsedick View Post
    *the code calls my name....*
    You deserve all the internets
    __________________
    Plugins|Steam Group|Profile
    I can do coding and even take requests, but I don't do a bit of modeling

    I'm a smartass by nature, get used to it
    xXDeathreusXx is offline
    Send a message via Skype™ to xXDeathreusXx
    shavit
    AlliedModders Donor
    Join Date: Dec 2011
    Location: Israel
    Old 06-28-2016 , 07:12   Re: [ANY] Entity Toggler
    Reply With Quote #5

    i never laughed so much by just reading code man haha
    __________________
    retired
    shavit is offline
    xines
    Veteran Member
    Join Date: Aug 2013
    Location: Denmark
    Old 06-28-2016 , 09:24   Re: [ANY] Entity Toggler
    Reply With Quote #6

    Quote:
    Originally Posted by Mitchell View Post
    as it doesn't explain what the variable is storing.
    Mitchell, chill brotha its simply storing:

    Code:
    1. A Horse
    2. A Donkey
    3. A Penguin
    4. A Anteater
    5. An Angel
    Rofl u get the point lolol
    __________________
    xines is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 06-28-2016 , 10:13   Re: [ANY] Entity Toggler
    Reply With Quote #7

    With all jokes aside...
    Some use this stock function created by exvel:
    Code:
    stock FindEntityByClassname2(startEnt, const String:classname[])
    {
    	/* If startEnt isn't valid shifting it back to the nearest valid one */
    	while (startEnt > -1 && !IsValidEntity(startEnt)) startEnt--;
    	
    	return FindEntityByClassname(startEnt, classname);
    }
    then use within your code:
    Code:
    new horse = MaxClients;
    while ((horse = FindEntityByClassname2(horse, arg1)) != -1)
    {
        //Do stuff in this block.
    }
    I don't normally use FindEntityByClassname2, so i'm not sure what the advantages are.
    __________________

    Last edited by Mitchell; 06-28-2016 at 10:14.
    Mitchell is offline
    xXDeathreusXx
    Veteran Member
    Join Date: Mar 2013
    Location: *pPlayer->GetOrigin()
    Old 06-28-2016 , 21:30   Re: [ANY] Entity Toggler
    Reply With Quote #8

    Quote:
    Originally Posted by Mitchell View Post
    I don't normally use FindEntityByClassname2, so i'm not sure what the advantages are.
    You can give it a number and it'll shift down the entity list backwards until it finds a valid one, kind of a safety precaution...

    Generally you can just give it -1 and FindEntityByClassname will do it's job
    __________________
    Plugins|Steam Group|Profile
    I can do coding and even take requests, but I don't do a bit of modeling

    I'm a smartass by nature, get used to it
    xXDeathreusXx is offline
    Send a message via Skype™ to xXDeathreusXx
    Reply


    Thread Tools
    Display Modes

    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 09:54.


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