View Single Post
nergal
Veteran Member
Join Date: Apr 2012
Old 04-17-2016 , 13:15   Re: New API and Syntax
Reply With Quote #724

question.

Since the methodmaps are just syntactic sugar, does that I mean I can use the constructor function to directly access properties and method functions instead of creating an instance of the methodmap?

Here's what I mean in code.

PHP Code:
methodmap BaseMap
{
    public 
BaseMap (const int indbool uid false)
    {
        if (
uid) {
            return 
view_as<BaseMap>( ind );
        }
        return 
view_as<BaseMap>( GetClientUserId(ind) );
    }

    
property int userid {
        public 
get()                { return view_as<int>(this); }
    }
    
property int index {
        public 
get()                { return GetClientOfUserIdthis.userid ); }
    }

    public 
void Funcz () {}
};

public 
void OnPluginStart ()
{
    
int Arr[MAXPLAYERS+1];

    for (
int i MaxClients ; --i)
    {
        
Arr[i] = BaseMap(i).userid;
        
BaseMap(i).Funcz();
    }

Secondly, would it be more efficient to do that in a loop or create an instance before hand and reassign it each loop?
__________________

Last edited by nergal; 04-17-2016 at 13:16.
nergal is offline