Quote:
|
Originally Posted by http://compuphase.com/pawn/Pawn_Language_Guide.pdf
You can check the tag of the actual argument by adding an extra argument to the function, and set its default value to be the “tagof” of the argument in question. Similar to the sizeof operator, the tagof operator has a special meaning when it is applied in a default value of a function argument: the expression is evaluated at the point of the function call, instead of at the function definition. This means that the “default value” of the function argument is the actual tag of the parameter passed to the function.
|
I'd like a functionality above but it doesn't seem to be working. I was thinking if that's a feature only in newer versions of Pawn but didn't find anything in logs. It doesn't seem that the expression would be evaluated at the point of function definition either because the value of the variable holding the tag id keeps being zero even you would change the tag of the function argument.
Code:
#include < amxmodx >
public plugin_init( )
{
new No, any: Any, test: Test, test2: Test2;
PrintTag( No );
PrintTag( Any );
PrintTag( Test );
PrintTag( Test2 );
server_print( "No: %i, Any: %i, Test: %i, Test2: %i", tagof( No ), tagof( Any ), tagof( Test ), tagof( Test2 ) );
}
PrintTag( Var, Tag = tagof( Var ) )
{
#pragma unused Var
server_print( "Tag: %i", Tag );
}
/*
Code print:
Tag: 0
Tag: 0
Tag: 0
Tag: 0
No: 0, Any: 2, Test: 13, Test2: 14
*/