Raised This Month: $ Target: $400
 0% 

[Sharing memory 4 fun]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 01-21-2014 , 18:39   [Sharing memory 4 fun]
Reply With Quote #1

core.sp
Spoiler


mycore.inc
Spoiler


plugin1.sp
Spoiler


plugin2.sp
Spoiler


I did not put all the checks and memory cleanup when one of the plugin unload but I will do it later and also GetRawDataStructByName only return the first one found. I will edit it later.

Last edited by Mathias.; 01-21-2014 at 18:43.
Mathias. is offline
striker07
Veteran Member
Join Date: Mar 2012
Location: Solar System/Earth/Belgi
Old 01-21-2014 , 18:39   Re: [Sharing memory 4 fun]
Reply With Quote #2

Thanks
__________________

Working on:
[CSGO/CSS] Mmorpg - an extensive XP/level modulair platform
Progress: [♣♣♣♣♣♣♣|♣♣♣]
striker07 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 01-21-2014 , 18:59   Re: [Sharing memory 4 fun]
Reply With Quote #3

Very cool. Seems like an easy alternative that making a bunch of natives.
Mitchell is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 01-21-2014 , 19:02   Re: [Sharing memory 4 fun]
Reply With Quote #4

It can be useful if you want to create run time libraries for plugins. (in sourcepawn)

Last edited by Mathias.; 01-21-2014 at 19:02.
Mathias. is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 01-03-2015 , 11:03   Re: [Sharing memory 4 fun]
Reply With Quote #5

I have no fucking idea what this does but I converted it to the new syntax for no reason lol.

I prob converted it wrong but here it is

PHP Code:
#include <sourcemod>
#include <mycore>

ArrayList array_Data null;

public 
APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max)
{
    
array_Data = new ArrayList(struct_data);
    
CreateNative("AddDataStruct"Native_AddDataStruct);
    
CreateNative("GetDataStructByName"Native_GetDataStructByName);
    
CreateNative("GetRawDataStructByName"Native_GetRawDataStructByName);
}

public 
int Native_AddDataStruct(Handle pluginint numParams)
{
    
int data[struct_data];
    
GetNativeArray(1datastruct_data);
    
data[m_plugin] = plugin;

    
array_Data.PushArray(data); //PushArrayArray(array_Data, data);
    
PrintToServer("[DEBUG] core: key '%s' by plugin ID '%d'"data[m_key], plugin);
}

public 
int Native_GetDataStructByName(Handle pluginint numParams)
{
    
char key[32];
    
GetNativeString(1key32);
    
PrintToServer("[DEBUG] core: Looking for a data from '%s'..."key);

    
int data[struct_data];

    for (
int iarray_Data.Lengthi++) //GetArraySize(array_Data); i++)
    
{
        
array_Data.GetArray(idata); //GetArrayArray(array_Data, i, data);

        
PrintToServer("[DEBUG] core: is key '%s' equal to '%s' and plugin ID %d equal to  '%d'?"data[m_key], keyplugindata[m_plugin]);

        if (
data[m_plugin] == plugin && StrEqual(data[m_key], keytrue))
        {
            
PrintToServer("[DEBUG] core: key '%s' was found!"key);
            
SetNativeArray(2datastruct_data);
            return 
view_as<int>(true);
        }
        continue;
    }
    
PrintToServer("[DEBUG] core: raw data was not found!");
    return 
view_as<int>(false);
}

public 
int Native_GetRawDataStructByName(Handle pluginint numParams)
{
    
char key[32];
    
GetNativeString(1key32);

    
PrintToServer("[DEBUG] core: Looking for a raw data from '%s'..."key);

    
int data[struct_data];

    for (
int iarray_Data.Lengthi++) //(new i; i < GetArraySize(array_Data); i++)
    
{
        
array_Data.GetArray(idata); //GetArrayArray(array_Data, i, data);
        
PrintToServer("[DEBUG] core: is key '%s' equal to '%s'?"data[m_key], key);

        if (
StrEqual(data[m_key], keytrue))
        {
            
PrintToServer("[DEBUG] core: key '%s' was found from plugin ID '%d'!"keydata[m_plugin]);
            
SetNativeArray(2datastruct_data);
            return 
view_as<int>(true);
        }
    }
    
PrintToServer("[DEBUG] core: raw data was not found!");
    return 
view_as<int>(false);
}







#if defined _mycore_included
 #endinput
#endif
#define _mycore_included

// ignore m_plugin this is used by core

enum struct_data
{
    
Handle m_plugin,
    
char m_key[32],
    
int m_value
};

// Add structure
native void AddDataStruct(int data[struct_data]);

// Find structure declared only by my plugin
native bool GetDataStructByName(const char key[32], int data[struct_data]);

// Find any structures by any plugin
native bool GetRawDataStructByName(const char key[32], int data[struct_data]); 
__________________
nergal is offline
__int128
BANNED
Join Date: Jan 2015
Old 01-05-2015 , 15:41   Re: [Sharing memory 4 fun]
Reply With Quote #6

does it even compile? I though we could not use the new declaration type into enums
__int128 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 19:55.


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