Raised This Month: $ Target: $400
 0% 

How to use methodmap ????


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lingzhidiyu
Senior Member
Join Date: Mar 2014
Old 01-14-2016 , 19:33   How to use methodmap ????
Reply With Quote #1

PHP Code:
methodmap Player
{
    
property int Health {
        public 
set(int amount) {
            
SetEntityHealth(this.Indexamount);
        }
        public 
get() {
            return 
GetClientHealth(this.Index);
        }
    }
    
property int Index {
        public 
get() {
            return 
int(this);
        }
    }

PHP Code:
    I want to use
    
client.Health 200;
    if (
client.Health == 100) {} 

Last edited by lingzhidiyu; 01-14-2016 at 19:34.
lingzhidiyu is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 01-14-2016 , 19:50   Re: How to use methodmap ????
Reply With Quote #2

What you don't get?
WildCard65 is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 01-15-2016 , 01:06   Re: How to use methodmap ????
Reply With Quote #3

player = Player (client)
client.Health is the accessor
__________________
Neuro Toxin is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 01-15-2016 , 07:32   Re: How to use methodmap ????
Reply With Quote #4

Quote:
Originally Posted by Neuro Toxin View Post
player = Player (client)
or it could be: Player player = view_as<Player>(client); as the Player methodmap is based around the client index anyway.
WildCard65 is offline
statistician
Member
Join Date: Jan 2016
Location: Finland
Old 01-16-2016 , 16:40   Re: How to use methodmap ????
Reply With Quote #5

You mean you want a settable Health property? try this:

Code:
int g_iPlayerHealth[MAXPLAYERS];

methodmap Player {
    public Player(int index) {
        return view_as<Player>(index);
    }

    property int Index {
        public get() {
            return view_as<int>(this);
        }
    }

    property int Health {
        public get() {
            return g_iPlayerHealth[this.Index];
        }

        public set(int health) {
            g_iPlayerHealth[this.Index] = health;
        }
    }
}
statistician is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 01-16-2016 , 16:45   Re: How to use methodmap ????
Reply With Quote #6

Quote:
Originally Posted by statistician View Post
You mean you want a settable Health property?
That is what is currently being done in original methodmap, but it sets the client's health instead of modifying an array.
WildCard65 is offline
Reply



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 16:12.


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