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

Solved Handle Type and Natives


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Weetabix
Member
Join Date: Feb 2017
Location: United Kingdom
Old 03-11-2017 , 13:45   Handle Type and Natives
Reply With Quote #1

I just have a few queries about handles and returning handles via natives.
To my understanding, a handle is of type "cell_t". I've seen some plugins pushing handles such as tries into an ArrayList with no problem.

Why is it then when I try to return a KeyValues type via a native it's invalid?

Here's what I've done:
File 1
PHP Code:
//Keyvalues
KeyValues g_hKeyValues;

...

public 
int Native_GetConfig(Handle hPluginint iArgs)
{
    return 
view_as<int>(g_hKeyValues);

File 1 Include
PHP Code:
native KeyValues GetConfig(); 
File 2
PHP Code:
g_hKeyValues GetConfig();

g_hKeyValues.JumpToKey("Test Section"true);

g_hKeyValues.ExportToFile(g_sPath); 

Last edited by Weetabix; 03-11-2017 at 17:24.
Weetabix is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 03-11-2017 , 14:41   Re: Handle Type and Natives
Reply With Quote #2

Your bug isn't in the code you supplied.

At a certain level, everthing is a cell. It's not relevant to your problem.
Fyren is offline
Weetabix
Member
Join Date: Feb 2017
Location: United Kingdom
Old 03-11-2017 , 15:16   Re: Handle Type and Natives
Reply With Quote #3

Quote:
Originally Posted by Fyren View Post
Your bug isn't in the code you supplied.

At a certain level, everthing is a cell. It's not relevant to your problem.
Is it not possible? Because the handle is definitely valid before being passed to the native.
Weetabix is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 03-11-2017 , 16:07   Re: Handle Type and Natives
Reply With Quote #4

Quote:
Originally Posted by Weetabix View Post
Is it not possible? Because the handle is definitely valid before being passed to the native.
Is it? I don't see a call to CreateKeyValues("name") or new KeyValues("name") anywhere in the code you posted.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 03-11-2017 at 16:08.
Powerlord is offline
Weetabix
Member
Join Date: Feb 2017
Location: United Kingdom
Old 03-11-2017 , 16:50   Re: Handle Type and Natives
Reply With Quote #5

Quote:
Originally Posted by Powerlord View Post
Is it? I don't see a call to CreateKeyValues("name") or new KeyValues("name") anywhere in the code you posted.
It's created in another plugin, I just ended up passing the handle by reference which seems to work fine.
Weetabix is offline
Weetabix
Member
Join Date: Feb 2017
Location: United Kingdom
Old 03-12-2017 , 10:26   Re: Handle Type and Natives
Reply With Quote #6

Just a quick question, does the handle passed by reference need to be closed? The handle is global in the owner plugin.
Weetabix is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 03-12-2017 , 12:05   Re: Handle Type and Natives
Reply With Quote #7

Quote:
Originally Posted by Weetabix View Post
Just a quick question, does the handle passed by reference need to be closed? The handle is global in the owner plugin.
Any handle created by a plugin must be closed (unless the native creating it, close it).
__________________
Benoist3012 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 04:57.


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