29.04.2012, 03:51
okay im trying to pass unlimited arguments to a function,
the hard part is getting the string from the argument
let my code explain,
this creates a db table with the fields passed to the function
but i keep getting an error
and i use it like so..
the pawn ref says getarg() can take a second argument
getarg(arg, index=0)
to indicate the start of an array
iv tried
but just get an argument type mismatch.
hoping someone can shed some light on this for me.
thanks
the hard part is getting the string from the argument
let my code explain,
this creates a db table with the fields passed to the function
but i keep getting an error
pawn Код:
stock CreateNewDbTable(tbl_name[],...)
{
new str_Query[256];
strcat(str_Query,"CREATE TABLE IF NOT EXISTS `");
strcat(str_Query,tbl_name);
strcat(str_Query,"` (");
for (new i = 1,i_n_a=numargs(); i < i_n_a ; ++i)
{
if (i>2) strcat(str_Query,",");
strcat(str_Query,"`");
strcat(str_Query,getarg(i));//<~~~~type mismatch error here.
strcat(str_Query,"`");
}
strcat(str_Query,")");
db_query(j5ud,str_Query);
return 1;
}
pawn Код:
CreateNewDbTable("USERS",
"NAME",
"PASSWORD",
"IP",
"ALIAS",
"EXP",
"LEVEL",
"FLAGS",
"SCORE",
"CASH",
"X",
"Y",
"Z",
"A",
"INTERIOR",
"VWORLD");
getarg(arg, index=0)
to indicate the start of an array
iv tried
pawn Код:
getarg(i,0)
hoping someone can shed some light on this for me.
thanks