Raised This Month: $32 Target: $400
 8% 

Solved Natives and Methodmaps


Post New Thread Reply   
 
Thread Tools Display Modes
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 06-07-2018 , 19:31   Re: Natives and Methodmaps
Reply With Quote #11

-1, GetNativeCell and GetClientUserId are all ints, so you don't really need to use view_as at all in that implementation. Will still work fine but just cleaner without the view_as.
hmmmmm is offline
iGANGNAM
AlliedModders Donor
Join Date: Sep 2012
Location: Lithuania
Old 06-12-2018 , 15:13   Re: Natives and Methodmaps
Reply With Quote #12

I have question again... Here is my methodmap
Code:
methodmap ZombieClass {
      // Constructor
      public native ZombieClass(char[] name, char[] desc, char[] model, int health, float damage, float speed, float gravity, bool excluded = false);
      // Methods
      property int ID {
            public native get();
      }
      property int Health {
            public native get();
            public native set(const int val);
      }
      property float Speed {
            public native get();
            public native set(const float val);
      }
      property float Gravity {
            public native get();
            public native set(const float val);
      }
      property float Damage {
            public native get();
            public native set(const float val);
      }
      property bool Excluded {
            public native get();
            public native set(const bool val);
      }
      // Zombie class related
      public native void GetName(char[] text, int size);
      public native void SetName(char[] text, int size);
      public native void GetDesc(char[] text, int size);
      public native void SetDesc(char[] text, int size);
      public native void GetModel(char[] text, int size);
      public native void SetModel(char[] text, int size);
}
And there are properties with float, but natives doesn't allow to return float, what I should do to keep it as property?
__________________
iGANGNAM is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 06-12-2018 , 17:48   Re: Natives and Methodmaps
Reply With Quote #13

Quote:
Originally Posted by iGANGNAM View Post
And there are properties with float, but natives doesn't allow to return float, what I should do to keep it as property?
You should be able to return floats just fine, what does "not allowing" mean, exactly? If it's the tag mismatch, just go ahead and view_as<int>(), the bits will end up being interpreted correctly in the end.

Last edited by headline; 06-12-2018 at 17:49.
headline 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 20:08.


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