SA-MP Forums Archive
Little help with getarg(mysql) - 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: Little help with getarg(mysql) (/showthread.php?tid=285759)



Little help with getarg(mysql) - wups - 25.09.2011

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.


Re: Little help with getarg(mysql) - Stylock - 25.09.2011

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.


Re: Little help with getarg(mysql) - wups - 25.09.2011

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.


AW: Little help with getarg(mysql) - Meta - 25.09.2011

Look here.