AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   TF2Items (https://forums.alliedmods.net/forumdisplay.php?f=146)
-   -   MethodMap for TF2Items API (https://forums.alliedmods.net/showthread.php?t=265980)

nergal 07-08-2015 12:08

MethodMap for TF2Items API
 
I do not know if Ash has already made methodmaps for tf2items but here's a custom made one since tf2items utilizes handles

PHP Code:

methodmap TF2Item Handle 

    
// C O N S T R U C T O R =============================================================== 
    
public TF2Item(int iFlags
    { 
        return 
view_as<TF2Item>( TF2Items_CreateItem(iFlags) ); 
    } 
    
// ===================================================================================== 
 
    // P R O P E R T I E S ================================================================= 
    
property int Flags 
    

        public 
get() { return TF2Items_GetFlags(this); } 
        public 
setint iFlags ) { TF2Items_SetFlags(thisiFlags); } 
    } 
 
    
property int ItemIndex 
    

        public 
get() {return TF2Items_GetItemIndex(this);} 
        public 
setint iItemDefIndex ) {TF2Items_SetItemIndex(thisiItemDefIndex);} 
    } 
 
    
property int Quality 
    

        public 
get() {return TF2Items_GetQuality(this);} 
        public 
setint iEntityQuality ) {TF2Items_SetQuality(thisiEntityQuality);} 
    } 
 
    
property int Level 
    

        public 
get() {return TF2Items_GetLevel(this);} 
        public 
setint iEntityLevel ) {TF2Items_SetLevel(thisiEntityLevel);} 
    } 
 
    
property int NumAttribs 
    

        public 
get() {return TF2Items_GetNumAttributes(this);} 
        public 
setint iNumAttributes ) {TF2Items_SetNumAttributes(thisiNumAttributes);} 
    } 
    
//======================================================================================= 
 
    
public int GiveNamedItem(int iClient
    { 
        return 
TF2Items_GiveNamedItem(iClientthis); 
    } 
 
    public 
void SetClassname(char[] strClassName
    { 
        
TF2Items_SetClassname(thisstrClassName); 
    } 
 
    public 
void GetClassname(char[] strDestint iDestSize
    { 
        
TF2Items_GetClassname(thisstrDestiDestSize); 
    } 
 
    public 
void SetAttribute(int iSlotIndexint iAttribDefIndexfloat flValue
    { 
        
TF2Items_SetAttribute(thisiSlotIndexiAttribDefIndexflValue); 
    } 
 
    public 
int GetAttribID(int iSlotIndex
    { 
        return 
TF2Items_GetAttributeId(thisiSlotIndex); 
    } 
 
    public 
float GetAttribValue(int iSlotIndex
    { 
        return 
TF2Items_GetAttributeValue(thisiSlotIndex); 
    } 
}; 

How to use!

PHP Code:

    TF2Item hWep = new TF2Item(OVERRIDE_ALL|PRESERVE_ATTRIBUTES|FORCE_GENERATION);
    
hWep.SetClassname("tf_weapon_example"); 
    
hWep.Quality 6
    
hWep.Level 1
    
hWep.NumAttribs 0;
    
delete hWep


Zeusington 08-12-2015 15:44

Re: MethodMap for TF2Items API
 
I was already using a methodmap for this, but I think I'll lift yours. OOP syntax is so much cleaner.

nergal 11-10-2015 23:58

Re: MethodMap for TF2Items API
 
Hey Asher, can I get this stickied?

WildCard65 11-11-2015 09:44

Re: MethodMap for TF2Items API
 
I think TF2Item would be a better methodmap name then TF2Items

nergal 11-11-2015 09:53

Re: MethodMap for TF2Items API
 
Quote:

Originally Posted by WildCard65 (Post 2362060)
I think TF2Item would be a better methodmap name then TF2Items

done ^^

humbugtheman 02-16-2016 04:54

Re: MethodMap for TF2Items API
 
Thanks for this!

nergal 02-16-2016 11:28

Re: MethodMap for TF2Items API
 
Quote:

Originally Posted by humbugtheman (Post 2393356)
Thanks for this!

no problem ^^


All times are GMT -4. The time now is 22:33.

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