AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [CSS]Antihostagekill (https://forums.alliedmods.net/showthread.php?t=276764)

backwards 12-27-2015 18:22

[CSS]Antihostagekill
 
1 Attachment(s)
Just made a quick plugin to prevent players from killing the hostages. So they cant ruin the gameplay for people who are trying to do the objective.

Install smx > addons/sourcemod/plugins
sp > addons/sourcemod/scripting

Have fun

ch4os 12-28-2015 08:42

Re: [css/any?] Antihostagekill
 
I think this here is even quicker as it doesn't have to cycle through all the available entities:

PHP Code:

GodModeHostages()
{
    new 
entity = -1;
    while ((
entity FindEntityByClassname(entity"hostage_entity")) != -1)
        
SetEntProp(entityProp_Data"m_takedamage"1);


Untested :3

BTW: In CS:GO you actually can't kill the hostages anymore, so this is only for CSS I guess :wink:

backwards 12-28-2015 12:00

Re: [css/any?] Antihostagekill
 
Quote:

Originally Posted by ch4os (Post 2377242)
I think this here is even quicker as it doesn't have to cycle through all the available entities:

PHP Code:

GodModeHostages()
{
    new 
entity = -1;
    while ((
entity FindEntityByClassname(entity"hostage_entity")) != -1)
        
SetEntProp(entityProp_Data"m_takedamage"1);


Untested :3

BTW: In CS:GO you actually can't kill the hostages anymore, so this is only for CSS I guess :wink:

How do you think FindEntityByClassname works?

Code:

CBaseEntity *CGlobalEntityList::FindEntityByClassname( CBaseEntity *pStartEntity, const char *szName )
{
    const CEntInfo *pInfo = pStartEntity ? GetEntInfoPtr( pStartEntity->GetRefEHandle() )->m_pNext : FirstEntInfo();

    for ( ;pInfo; pInfo = pInfo->m_pNext )
    {
        CBaseEntity *pEntity = (CBaseEntity *)pInfo->m_pEntity;
        if ( !pEntity )
        {
            DevWarning( "NULL entity in global entity list!\n" );
            continue;
        }

        if ( pEntity->ClassMatches(szName) )
            return pEntity;
    }

    return NULL;
}

It enumerates all entities and compares the classname. So this takes the same amount of time but thanks for attempting to correct me. also thanks for updating me on the csgo part.

404UserNotFound 12-15-2017 01:10

Re: [CSS]Antihostagekill
 
Calling a function when it's only used in one spot?

You suck, dude.


All times are GMT -4. The time now is 05:45.

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