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

Solved ArrayList in <include> for use in two plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
_GamerX
AlliedModders Donor
Join Date: Jun 2011
Location: Fun Server
Old 03-13-2019 , 15:25   ArrayList in <include> for use in two plugin
Reply With Quote #1

Hello.
I have in my include declared this ArrayList

PHP Code:
ArrayList[MAXPLAYERS 1PlayerCore;
//I also try this
ArrayList PlayerCore[MAXPLAYERS 1]; 

In CORE plugin is called this in Plugin_init located in include too
PHP Code:
stock int CreatePlayerArrays()
{
    for(
int i 1<= MaxClientsi++)
        
PlayerCore[i] = new ArrayList(5);

But if i want use this in other plugins i get error
[SM] Exception reported: Invalid Handle 0 (error: 4)

But why? Please help
__________________

Last edited by _GamerX; 03-14-2019 at 05:51.
_GamerX is offline
Send a message via ICQ to _GamerX Send a message via Skype™ to _GamerX
Mitchell
~lick~
Join Date: Mar 2010
Old 03-13-2019 , 15:50   Re: ArrayList in <include> for use in two plugin
Reply With Quote #2

That isn't how includes work. That's also why i'm against morecolors etc making StringMaps/Tries because every plugin that uses it creates the StringMap/Trie.
When you compile your plugin you are bringing in all the code from the include* into your plugin. Which means theres no reference between plugins.
You'll need a middle man plugin or core plugin that handles this array.
The Core plugin can give out the values/modify the values via natives.

* Unless it's a stock method and you don't use it.

Last edited by Mitchell; 03-13-2019 at 15:51.
Mitchell is offline
_GamerX
AlliedModders Donor
Join Date: Jun 2011
Location: Fun Server
Old 03-13-2019 , 15:59   Re: ArrayList in <include> for use in two plugin
Reply With Quote #3

So how i can work with ArrayLists via Natives?
__________________

Last edited by _GamerX; 03-13-2019 at 16:01.
_GamerX is offline
Send a message via ICQ to _GamerX Send a message via Skype™ to _GamerX
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 03-13-2019 , 17:06   Re: ArrayList in <include> for use in two plugin
Reply With Quote #4

Quote:
Originally Posted by _GamerX View Post
So how i can work with ArrayLists via Natives?
Declare arraylist in core plugin, not in include.
Create some natives to gain access of arraylist (or data inside) to other plugins.

I do not know what you are going to do exactly, so I don't know what should I advise you, but if you want to use the same arraylist in the different plugins, you can create natives like
PHP Code:
int PushDataToPlayerList(int playerint data);     //.Push method inside
int GetDataFromPlayerList(int playerint index);  //.Get method inside
int GetStringFromArrayList(int playerint indexchar[] bufferint maxlength); //.GetString inside 
or something like that, idk.

Last edited by impossible_cc; 03-13-2019 at 17:20. Reason: edited
impossible_cc is offline
_GamerX
AlliedModders Donor
Join Date: Jun 2011
Location: Fun Server
Old 03-14-2019 , 01:49   Re: ArrayList in <include> for use in two plugin
Reply With Quote #5

PHP Code:
stock int GetData(int clientany dataint block 0)
{
    return 
PlayerCore[client].Get(view_as<int>(data), block);
}
stock void SetData(int clientany dataint valueint block 0)
{
    
PlayerCore[client].Set(view_as<int>(data), valueblock);

ahh well this i use for manipulate with array so this remake to natives?
__________________
_GamerX is offline
Send a message via ICQ to _GamerX Send a message via Skype™ to _GamerX
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 09:22.


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