AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   native returns float (https://forums.alliedmods.net/showthread.php?t=86598)

MPNumB 02-28-2009 01:20

native returns float
 
I am wondering how can I create a native what returns float?

AntiBots 02-28-2009 01:36

Re: native returns float
 
public Float:return_float(id)


native Float:return_float(id)

EDIT: Use Style 1

danielkza 02-28-2009 02:20

Re: native returns float
 
Since Pawn has no real types, every variable is a cell, so the tag you return doesn't actually mather, in none of the styles. Just make sure the native declaration has the Float tag so you don't get 'tag mismatch' warnings.

Code:

native Float:MyPrettyFloatNative(Float:blah)

MPNumB 02-28-2009 04:19

Re: native returns float
 
Quote:

Originally Posted by AntiBots (Post 770720)
public Float:return_float(id)


native Float:return_float(id)

EDIT: Use Style 1

Thanks. Discussion over. =)

Quote:

Originally Posted by danielkza (Post 770737)
Since Pawn has no real types, every variable is a cell, so the tag you return doesn't actually mather, in none of the styles. Just make sure the native declaration has the Float tag so you don't get 'tag mismatch' warnings.

Code:

native Float:MyPrettyFloatNative(Float:blah)

I just had problems with with 'tag mismatch' cuz didn't knew that it's possible to to cassify type after function "public".

Exolent[jNr] 02-28-2009 13:59

Re: native returns float
 
@AntiBots
Style 1 isn't required. The style is just a preference:
Code:
// include file native Float:get_float(index); // plugin with style 1 public plugin_natives() {     register_native("get_float", "_get_float", 1); } public Float:_get_float(index) {     // code } // plugin with style 0 public plugin_natives() {     register_native("get_float", "_get_float"); } public Float:_get_float(plugin, params) {     new index = get_param(1);     // code }

I prefer style 0.

ConnorMcLeod 02-28-2009 16:18

Re: native returns float
 
Quote:

NOTE: Style should always be 0. The "dJeyL" mode value of 1 is deprecated, since it is not properly compatible with any by-reference type.

The advantage to keeping style set to 0 is that it more closely resembles the AMX Mod/X module API.

Anyway, i think NumB was talking about internal plugin native, aka simple function :D

Exolent[jNr] 02-28-2009 18:12

Re: native returns float
 
Well, he said create a native, so everyone assumed dynamic natives, rather than an internal function.


All times are GMT -4. The time now is 16:51.

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