Try this one out, I fixed the property line and added the missing 'new' in DString_Create. Creating the methodmap first allows the stock functions to use the methodmap; if you look at the stock functions, some handles use both DataPack and DString methods.
PHP Code:
/**************************************************************************
* *
* DString - Dynamic Strings *
* Author: Eun *
* Version: 1.0.1 Emp`s changes *
* *
**************************************************************************/
#if defined _DSTRING_INCLUDED
#endinput
#endif
#define _DSTRING_INCLUDED
#if !defined DSTRING_BUFFERLEN
#define DSTRING_BUFFERLEN 4048
#endif
methodmap DString < DataPack
{
public DString() = DString_Create;
public Copy() = DString_Copy;
public Format() = DString_Format;
public Add() = DString_Add;
public AddEx() = DString_AddEx;
public Read() = DString_Read;
public ReadEx() = DString_ReadEx;
property int Length
{
public get() { return DString_Length( this ); }
}
public Clear() = DString_Clear;
}
stock DString DString_Create( const char[] str = "" )
{
DString handle = view_as < DString > new DataPack();
int len = strlen( str );
if ( len )
{
handle.WriteCell( len );
handle.WriteString( str );
}
return handle;
}
stock int DString_Copy( DString handle, const char[] str )
{
int len = strlen( str );
if ( !handle ) return 0;
handle.Reset( true );
handle.WriteCell( len );
handle.WriteString( str );
return len;
}
stock int DString_Format( DString handle, const char[] str, any ... )
{
char buffer[ DSTRING_BUFFERLEN ];
VFormat( buffer, sizeof buffer, str, 3 );
return handle.Copy( handle, buffer );
}
stock int DString_Add( DString handle, const char[] str )
{
int len = handle.Length();
int len_add = strlen( str );
if ( !len_add ) return len;
int len_new = len + len_add
char[] buffer = new char[ len_new ];
if ( len ) handle.ReadString( buffer, len );
strcopy( buffer[ len ], len_add, str );
return handle.Copy( buffer );
}
stock int DString_AddEx( DString handle, const char[] str, any ... )
{
char buffer[ DSTRING_BUFFERLEN ];
VFormat( buffer, sizeof buffer, str, 3 );
return handle.Add( buffer );
}
stock int DString_Read( DString handle, char[] buffer, int buffersize )
{
int len = handle.Length();
if ( len ) handle.ReadString( buffer, buffersize );
return len;
}
stock char[] DString_ReadEx( DString handle )
{
int len = handle.Length();
char[] buffer = new char[ len ];
handle.Read( buffer, len );
return buffer;
}
stock int DString_Length( DString handle )
{
if ( !handle ) return 0;
handle.Reset( false );
if ( !handle.IsReadable( 1 ) ) return 0;
return handle.ReadCell();
}
stock void DString_Clear( DString handle )
{
handle.Reset( true );
}
stock void DString_Delete( DString &handle )
{
delete handle;
}