SA-MP Forums Archive
passing variable types? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: passing variable types? (/showthread.php?tid=429942)



passing variable types? - CJay9209 - 11.04.2013

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.


Re: passing variable types? - Bakr - 11.04.2013

You could use tagof() or tagged macros.