Raised This Month: $ Target: $400
 0% 

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
VoiDeD
AlliedModders Donor
Join Date: Mar 2009
Location: Illinois, USA
Old 07-13-2014 , 15:57   Re: New API and Syntax
Reply With Quote #1

For developers looking to harness the methodmap syntax for an object-oriented API for interacting with game entities, check out these helpers includes.

Example of usage:
PHP Code:
stock void GiveObjectHatCBaseObject objectEnt, const char hatModelPLATFORM_MAX_PATH ] )
{
    
CBaseEntity hatProp Entity_CreateByName"prop_dynamic_override" );

    if ( 
hatProp.IsValid )
    {
        
hatProp.SetModelhatModel );
        
hatProp.Spawn();

        
hatProp.AcceptInput"DisableCollision" );
        
hatProp.AcceptInput"DisableShadow" );

        
ParentHathatPropobjectEnt );
    }
}

stock void ParentHatCBaseEntity hatPropCBaseObject objectEnt )
{
    
char hatModelPLATFORM_MAX_PATH ];
    
hatProp.GetModelhatModelsizeofhatModel ) );

    
float modelScale 1.0;
    
float modelOffset 0.0;

    if ( !
Config_GetHatByModelhatModelmodelOffsetmodelScale ) )
    {
        
LogError"Unable to find hat config for hat: %s"hatModel );
        return;
    }

    
hatProp.Skin objectEnt.Builder.Team 2;
    
hatProp.ModelScale modelScale;

    
char attachmentName128 ];
    
GetAttachmentNameobjectEntattachmentNamesizeofattachmentName ) );

    
hatProp.SetParentobjectEnt );
    
hatProp.SetParentAttachmentattachmentName );

    
float vecPos]; float angRot];
    
hatProp.GetLocalOriginvecPos );
    
hatProp.GetLocalAnglesangRot );

    
// apply z offset
    
vecPos] += modelOffset;

    
// apply position/angle fixes based on object type
    
OffsetAttachmentPositionobjectEntvecPosangRot );

    
hatProp.TeleportvecPosangRotNULL_VECTOR );

__________________
VoiDeD is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 07-13-2014 , 16:10   Re: New API and Syntax
Reply With Quote #2

If I may keep it short.
<---------------------------
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.
Dr. Greg House is offline
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 22:24.


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