Module: Array Solutions 1.0

Adding Modules to help with scripting/coding plugins.
User avatar
Archive-Poster
Posts: 1189
Gender:
United States of America

Module: Array Solutions 1.0

Post by Archive-Poster »

Well, This is a little module, That you can use to Hold arrays, when map change.

I will add more natives, to found data and to valid data.
Also restrict data for one plugin.

Here is a basic example:

Code: Select all

#include <amxmodx>
#include <amxmisc>

#pragma library arraysolutions

#define ARRAYTEMP "temp"

// Is name Exist. Copy the info to array. If not. Array to Module. and return the correct pointer.
// Also if you use "temp" like name. Array will remove on mapchange.
native array_create( const name[], array[], size);

// Remove an Existan Array
native array_destroy( pointer );

// Return Array Size.
native array_size( pointer );

// Get and set new name.
native array_name( pointer, name[], len );
native array_rename( pointer, const newname[] );

// Get a Cell & Set. 0 to Size-1 // PD: to set float, do  _:43.2323
native array_setcell( pointer, data, element );
native array_getcell( pointer, element ); // Tu return float use: new Float:lala = _:array_get(....

// Get & Set full Array.  Get == array_create, but this use pointer.
native array_set( pointer, array[], size);
native array_get( pointer, array[], size); // Is float, use _:


new test;
new g_pointer_players[33];

public plugin_init() 
{
    register_plugin("Array Solutions Test", "1.0", "ReymonARG");
    
    new array[5] = { 1, 2, 3, 4, 5 }
    
    test = array_create("test", array, sizeof(array) );
    
    register_srvcmd("arraytest", "arraytest" );
}

public arraytest()
{
    new array[5];
    array_get( test, array, sizeof(array) )
    
    server_print(" %d %d %d %d %d ", array[0], array[1], array[2], array[3], array[4] );
    
    array_setcell( test, 0, 2 );
    
    array_get( test, array, sizeof( array ) );
    
    server_print(" %d %d %d %d %d ", array[0], array[1], array[2], array[3], array[4] );
}

public client_putinserver( id )
{
    new name[32];
    get_user_name(id, name, 31);
    
    g_pointer_players[id] = array_create( ARRAYTEMP, name, sizeof( name ) );
}

public client_disconnect( id )
{
    if( !g_pointer_players[id] )
        return PLUGIN_CONTINUE;
    
    new name[32], actualname[32];
    get_user_name(id, actualname, 31);
    array_get( g_pointer_players[id], name, sizeof( name ) );
    
    server_print("Disconect: %s that enter with: %s", actualname, name );
    
    array_destroy( g_pointer_players[id] );
    g_pointer_players[id] = 0;
} 
Well here actual natives:

Code: Select all

#pragma library arraysolutions

#define ARRAYTEMP "temp"

// Is name Exist. Copy the info to array. If not. Array to Module. and return the correct pointer.
// Also if you use "temp" like name. Array will remove on mapchange.
native array_create( const name[], array[], size);

// Remove an Existan Array
native array_destroy( pointer );

// Return Array Size.
native array_size( pointer );

// Get and set new name.
native array_name( pointer, name[], len );
native array_rename( pointer, const newname[] );

// Get a Cell & Set. 0 to Size-1 // PD: to set float, do  _:43.2323
native array_setcell( pointer, data, element );
native array_getcell( pointer, element ); // Tu return float use: new Float:lala = _:array_get(....

// Get & Set full Array.  Get == array_create, but this use pointer.
native array_set( pointer, array[], size);
native array_get( pointer, array[], size); // Is float, use _:


Well I create in the module more func like arraycopy and that. But i dont create the natives. Sorry. I will do.
Attachments
array_amxx.dll.zip
(35.31 KiB) Downloaded 3 times
Array Solutions_source.zip
(40.55 KiB) Downloaded 2 times

Who is online

Users browsing this forum: No registered users and 0 guests