Little help with getarg(mysql)
#1

I've done something wrong:
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);
}
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.
Reply
#2

If you pass a string as an argument, you'll need to get each character from the string.
pawn Code:
getarg(i + 3, 0); //1st
getarg(i + 3, 1); //2nd
getarg(i + 3, 2); //3rd character
Something like that.
Reply
#3

Quote:
Originally Posted by YJIET
View Post
If you pass a string as an argument, you'll need to get each character from the string.
pawn Code:
getarg(i + 3, 0); //1st
getarg(i + 3, 1); //2nd
getarg(i + 3, 2); //3rd character
Something like that.
Thanks.
Reply
#4

Look here.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)