Raised This Month: $ Target: $400
 0% 

[TUT] Better Methodmaps tut


Post New Thread Reply   
 
Thread Tools Display Modes
nergal
Veteran Member
Join Date: Apr 2012
Old 12-26-2015 , 12:23   Re: [TUT] Better Methodmaps tut
Reply With Quote #11

ok there, the examples have real backing fields now.

I also modified the custom example that most plugins would likely use.
__________________

Last edited by nergal; 12-26-2015 at 12:36.
nergal is offline
CSGOT
New Member
Join Date: Feb 2016
Old 02-07-2016 , 11:07   Re: [TUT] Better Methodmaps tut
Reply With Quote #12

Nice Tutorial.
This really helped me alot.
Thanks OP
CSGOT is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 02-07-2016 , 12:59   Re: [TUT] Better Methodmaps tut
Reply With Quote #13

Quote:
Originally Posted by CSGOT View Post
Nice Tutorial.
This really helped me alot.
Thanks OP
no problem. If you have anymore questions, please don't hesitate to ask.
__________________
nergal is offline
StSatan
Senior Member
Join Date: Apr 2010
Old 02-09-2016 , 05:12   Re: [TUT] Better Methodmaps tut
Reply With Quote #14

Quote:
Originally Posted by nergal View Post

PHP Code:

int iHealth
[MAXPLAYERS+1];
int iAmmo[MAXPLAYERS+1];
float flSpeed[MAXPLAYERS+1];

methodmap Player
{
    public 
Player(int playerindex//constructor
    
{
        return 
view_as<Player>(playerindex); //make sure you do validity check on players
    
}
     
property int index 
    

        public 
get()                { return view_as<int>(this); } 
    }
    
property int Health
    
{
        public 
get() { return iHealth[this.index]; }
        public 
setint value ) { iHealth[this.index] = value; }
    }
    
property int Ammo
    
{
        public 
get() { return iAmmo[this.index]; }
        public 
setint value ) { iAmmo[this.index] = value; }
    }
    
property float Speed
    
{
        public 
get() { return flSpeed[this.index]; }
        public 
setfloat value ) { flSpeed[this.index] = value; }
    }
    public 
void GiveAmmo(int amount)
    {
        
this.Ammo += amount;
    }
    public 
void RemoveAmmo(int amount)
    {
        
this.Ammo -= amount;
    }
}

public 
void OnClientPutInServer(int client)
{
    
Playur player Player(client);
    if (
player.Health 1player.Health 100;
    if (
player.Ammo 1player.Ammo 50;
    if (
player.Speed 1.0player.Speed 300.0;

So in "normal" situation we can simply increase array:

PHP Code:
iHealth[index]++ 
or decrease

PHP Code:
iHealth[index]-- 
but with using methodmaps we can't type:

PHP Code:
index.Health++ 
am I right?
StSatan is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 02-09-2016 , 08:14   Re: [TUT] Better Methodmaps tut
Reply With Quote #15

Quote:
Originally Posted by StSatan View Post
So in "normal" situation we can simply increase array:

PHP Code:
iHealth[index]++ 
or decrease

PHP Code:
iHealth[index]-- 
but with using methodmaps we can't type:

PHP Code:
index.Health++ 
am I right?
Nope.
Basically, what happens is SP will get the return value from the get() method and increment that by one, then it will call the set() method with the new value.
example:
PHP Code:
T.LOL.set(tT.LOL.get(t)++); //T is methodmap, LOL is property(type int), t is variable(type T) 

Last edited by WildCard65; 02-09-2016 at 08:14.
WildCard65 is offline
humbugtheman
Member
Join Date: Jan 2012
Old 02-21-2016 , 19:19   Re: [TUT] Better Methodmaps tut
Reply With Quote #16

Thanks for the tut - very clear!
humbugtheman is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 05-27-2016 , 13:45   Re: [TUT] Better Methodmaps tut
Reply With Quote #17

Quote:
Originally Posted by humbugtheman View Post
Thanks for the tut - very clear!
No problem. If you have any questions, don't hesitate to ask!
__________________
nergal is offline
sdz
Senior Member
Join Date: Feb 2012
Old 05-27-2016 , 15:07   Re: [TUT] Better Methodmaps tut
Reply With Quote #18

Don't understand the tut at all honestly.
See this is why I just stay away from newdecls.
sdz is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 05-27-2016 , 18:49   Re: [TUT] Better Methodmaps tut
Reply With Quote #19

Quote:
Originally Posted by EasSidezz View Post
Don't understand the tut at all honestly.
See this is why I just stay away from newdecls.
what part do you not understand?
__________________
nergal is offline
sdz
Senior Member
Join Date: Feb 2012
Old 05-27-2016 , 23:27   Re: [TUT] Better Methodmaps tut
Reply With Quote #20

Quote:
Originally Posted by nergal View Post
what part do you not understand?
It's not you, it's me.
sdz 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 22:06.


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