passing variable types?
#1

hey guys - I'm just playing around with optimizing some code here and was wandering if it was possible to make a stock function able to tell which variable type was being sent to it?

ok so right now I'm using:

pawn Код:
#define DATATYPE_INT 0
#define DATATYPE_FLOAT 1
#define DATATYPE_STRING 2

stock processdata(playerid, datatype, int_data, Float:f_data, s_data[])
{
    switch(datatype) {
        case DATATYPE_INT: {
            //do stuff here
        }
        case DATATYPE_FLOAT: {
            //do stuff here
        }
        case DATATYPE_STRING: {
            //do stuff here
        }
    }
}
is there any way of writing the equivalent of this but pass either a string,integer OR float and not need to pass all 3 and detect it within the code inside the stock function?

not a big deal but I'm looking to tidy up the code a little.
Reply
#2

You could use tagof() or tagged macros.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)