Raised This Month: $51 Target: $400
 12% 

Pass data between menu handlers. Optimization.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 07-01-2015 , 10:35   Pass data between menu handlers. Optimization.
Reply With Quote #1

I need pass only 1 int var. I see two ways to do it.
1) Create global int var and store data for pass.
2) Create global DataPack and store data for pass.
My questions. Use DataPack more better because you delete Handle when u don't use it. And use DataPack can slow down program.
My decision that 1st way more fasted but more memory exacting, and 2nd optimize memory use, but a little bit slowly.
I'm right?
Kailo is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-01-2015 , 10:42   Re: Pass data between menu handlers. Optimization.
Reply With Quote #2

The "best" way to do it right now is to store it in a not displayed menu item. Unfortunately, this means you need to convert it to a string and back.

I wrote a pull request to add an any field to store arbitrary data a while back, but that change was rejected.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 07-01-2015 , 11:23   Re: Pass data between menu handlers. Optimization.
Reply With Quote #3

if you only use 1 int, the datapack would use more memory o.o
Miu is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 07-01-2015 , 15:19   Re: Pass data between menu handlers. Optimization.
Reply With Quote #4

https://forums.alliedmods.net/showthread.php?t=265263 same problem?

So something like this?
KissLick is offline
ThatOneGuy
Veteran Member
Join Date: Jul 2012
Location: Oregon, USA
Old 07-02-2015 , 01:21   Re: Pass data between menu handlers. Optimization.
Reply With Quote #5

See kisslicks include for one way to do it. But for a single integer, just pass it in the info string:
https://sm.alliedmods.net/api/index....d=show&id=184&

Then, in the handler, retrieve it with:
Code:
new String:sInfo[64];
GetMenuItem(hMenu, param2, sInfo, sizeof(sInfo));
You can also pass several things this way if you use a delimiter in between, then split it during the callback.

This was fully discussed in the thread kisslick linked.
__________________

Last edited by ThatOneGuy; 07-02-2015 at 01:21.
ThatOneGuy 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:19.


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