Raised This Month: $ Target: $400
 0% 

[not important] dyn natives: how to get native name from itself? no hardcoding


Post New Thread Reply   
 
Thread Tools Display Modes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-02-2012 , 16:17   Re: dyn natives: how to get native name from itself? no hardcoding
Reply With Quote #11

Quote:
Originally Posted by Owyn View Post
Other people ^_^ And they don't, it's my motive.
Why don't we talk about theoretical part of the problem? ^_^ Did you like my idea about get_last_used_native() function or would you like to suggest anything instead?
I take it that you never read the post by Exolent about the "X Y Problem".

I'm trying to get to the actual root of the issue and not the one that you think you need to solve.
__________________
fysiks is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 01-02-2012 , 18:22   Re: [not important] dyn natives: how to get native name from itself? no hardcoding
Reply With Quote #12

Just bringing up a time where it would be nice to have:

Code:
register_native("ModGiveXP","NativeXP");
register_native("ModSetXP","NativeXP");

//....

NativeXP()
{
   new szNativeName[32]
   //Fill szNativeName here
   if ( equal( szNativeName, "ModGiveXP" ) )
      g_PlayerXP[ iPlayer ] += iXP
   else
      g_PlayerXP[ iPlayer ] = iXP
}
That way you would not need two functions that do very similar things.

Untested, but there is the small chance that the following code will return the Native name.
Code:
get_string( 0, szNativeName, charsmax(szNativeName) );
If someone tests it, let me know and I will edit this post.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Owyn
Veteran Member
Join Date: Nov 2007
Old 01-02-2012 , 18:36   Re: [not important] dyn natives: how to get native name from itself? no hardcoding
Reply With Quote #13

Tried that and got following:

Quote:
L 01/03/2012 - 033:15: Plugin tried to use native D"*КшDP‹0*8»PИTТшЬЬМЬјшј/iLu¬ЋDФИ6@щTИ„б.оИџD?8льйђђ‰ђ'L
L 01/03/2012 - 033:29: Plugin tried to use native ґ"КhDА‹**Ё»АИДТhЬLМL,ш,/xiјuЋґФ86°щД8фбx.xо8џґ?Ёлlй
L 01/03/2012 - 0331: Plugin tried to use native "hКАD‹ш*
L 01/03/2012 - 0333: Plugin tried to use native "hКАD‹ш*
L 01/03/2012 - 0337: Plugin tried to use native ”"рКHD*‹Ђ*€»*И¤ТHЬ,М, ш /XiњuьЋ”Ф6ђщ¤ФбX.Xоџ”?€лLйаа‰а'њ
That's why I made this thread
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-02-2012 , 21:34   Re: [not important] dyn natives: how to get native name from itself? no hardcoding
Reply With Quote #14

Quote:
Originally Posted by Emp` View Post
Just bringing up a time where it would be nice to have:

Code:
register_native("ModGiveXP","NativeXP");
register_native("ModSetXP","NativeXP");

//....

NativeXP()
{
   new szNativeName[32]
   //Fill szNativeName here
   if ( equal( szNativeName, "ModGiveXP" ) )
      g_PlayerXP[ iPlayer ] += iXP
   else
      g_PlayerXP[ iPlayer ] = iXP
}
That way you would not need two functions that do very similar things.
That's debatable. Doesn't that use more cpu than having two independent functions (because of the string comparison)?
__________________
fysiks is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 01-02-2012 , 21:49   Re: [not important] dyn natives: how to get native name from itself? no hardcoding
Reply With Quote #15

Quote:
Originally Posted by fysiks View Post
That's debatable. Doesn't that use more cpu than having two independent functions (because of the string comparison)?
Even though I'm pretty sure the difference between the two is negligible, would you rather have less lines to write/easier to write, or slightly better cpu usage?
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please

Last edited by nikhilgupta345; 01-02-2012 at 21:50.
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-02-2012 , 22:04   Re: [not important] dyn natives: how to get native name from itself? no hardcoding
Reply With Quote #16

Quote:
Originally Posted by nikhilgupta345 View Post
Even though I'm pretty sure the difference between the two is negligible, would you rather have less lines to write/easier to write, or slightly better cpu usage?
That is way too dependent on what exactly I'm doing. In Emp's example I would prefer two functions.
__________________
fysiks is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-03-2012 , 01:21   Re: [not important] dyn natives: how to get native name from itself? no hardcoding
Reply With Quote #17

If only you would tell us what you are exactly trying to do...
Actually no one can really help you.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 03:20.


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