25.09.2011, 12:30
I've done something wrong:
So, the Variable(argstring) doesn't show up in mysql correctly. Instead, it shows up with some previously used strings. For example part of the dialog name.
Edit: Forgot to mention, this problem is only with strings.
pawn Code:
//MLog(playerid,"Whispered","s",text);
stock MLog(playerid,action[],formats[], {Float,_}:...)
{
if(!IsPlayerConnected(playerid)) return 0;
new
paramCount = numargs(),
lenght=strlen(formats),
query[500],
argstring[200];
if((paramCount-3) != lenght) return printf("ERROR! Arg count is not equal to the format!");
for(new i; i < lenght;i++)
{
switch(formats[i])
{
case 's': format(argstring,sizeof(argstring),"%s %s",argstring,getarg(i+3));
case 'i': format(argstring,sizeof(argstring),"%s %i",argstring,getarg(i+3));
case 'd': format(argstring,sizeof(argstring),"%s %d",argstring,getarg(i+3));
case 'f': format(argstring,sizeof(argstring),"%s %.1f",argstring,getarg(i+3));
case 'c': format(argstring,sizeof(argstring),"%s %c",argstring,getarg(i+3));
default: format(argstring,sizeof(argstring),"%s %s",argstring,getarg(i+3));
}
}
mysql_real_escape_string(argstring,argstring);
format(query,sizeof(query),"INSERT INTO `Logs` (`PName`, `Action`, `Variable`, `Date`) VALUES ('%s', '%s', '%s', NOW())",ReturnName(playerid),action,argstring);
return mysql_query(query);
}
Edit: Forgot to mention, this problem is only with strings.