Code:
//bla.inc
/**
* c ^ cell
* s ^ string
* a ^ array
*
* plugin < 0 calls executing plugin
*
* ex. ForceCall( 0, "punishClient", "ccs", Client, Victim, "H4xx0r" );
*
**/
// Deprecated
native ForceCall ( plugin, const name[], const format[], any:... );
//bla.sma
register_native( "ForceCall", "__ForceCall" );
//...
public __ForceCall ( CPlugin, CParams )
{
static plugin, name[ 31 ], format[ 14 ], func_id, source[ 65 ], p_format, param;
plugin = get_param( 1 );
get_string( 2, name, 30 );
if ( plugin < 0 )
plugin = CPlugin;
func_id = get_func_id( name, plugin );
if ( func_id < 0 )
return -1;
get_string( 3, format, 13 );
if ( strlen( format ) != CParams - 3 )
{
log_error( AMX_ERR_NATIVE, "<< CORE >> format doesn't match parameters" );
return 0;
}
if ( callfunc_begin_i( func_id, plugin ) != 1 )
{
log_error( AMX_ERR_NATIVE, "<< CORE >> God seems to hate ya" );
return 0;
}
p_format = 0;
for ( param = 4; param <= CParams; param++ )
{
switch ( format[ p_format ] )
{
case 'c':
{
callfunc_push_int( get_param_byref( param ) );
}
case 's':
{
get_string( param, source, 63 );
callfunc_push_str( source );
}
case 'a':
{
callfunc_push_int( get_param( param ) );
}
default:
{
log_error( AMX_ERR_NATIVE, "<< CORE >> What's '%c' ?", format[ p_format ] );
}
}
++p_format;
}
return callfunc_end();
}