Please assist : warnings related to format() ( and possibly Notepad++ ? )
#1

This issue is solved, click here to go to the solution.
Hello.

My PAWN compiler is getting spammed by errors similar to :

Код:
test.pwn(13509) : warning 202: number of arguments does not match definition
test.pwn(13509) : warning 202: number of arguments does not match definition
test.pwn(19589 -- 19590) : warning 202: number of arguments does not match definition
test.pwn(19589 -- 19590) : warning 202: number of arguments does not match definition
test.pwn(19617 -- 19628) : warning 202: number of arguments does not match definition
test.pwn(19617 -- 19628) : warning 202: number of arguments does not match definition
Line 19617 -- 19628, for example is :
pawn Код:
format(string, sizeof(string), "%s \
        `CustomExterior`=%d, \
        `VIP`=%d, \
        `Family`=%d, \
        `Faction`=%d, \
        `Admin`=%d, \
        `Wanted`=%d, \
        `VehicleAble`=%d, \
        `Color`=%d, \
        `PickupModel`=%d, \
        `Pass`='%s', \
        `Locked`=%d WHERE `id`=%d"
, // < ----------- 19617
        string,
        DDoorsInfo[doorid][ddCustomExterior],
        DDoorsInfo[doorid][ddVIP],
        DDoorsInfo[doorid][ddFamily],
        DDoorsInfo[doorid][ddFaction],
        DDoorsInfo[doorid][ddAdmin],
        DDoorsInfo[doorid][ddWanted],
        DDoorsInfo[doorid][ddVehicleAble],
        DDoorsInfo[doorid][ddColor],
        DDoorsInfo[doorid][ddPickupModel],
        g_mysql_ReturnEscaped(DDoorsInfo[doorid][dPass], MainPipeline), // < ----------- 19628
        DDoorsInfo[doorid][dLocked],
        doorid+1
    );
Can these warnings be only for the Notepad++ users, I doubt it because it still uses the good old PAWN compiler, and the text in script is same too.

Help would be appreciated.

EDIT
This is the full function :

pawn Код:
stock SaveDynamicDoor(doorid)
{
    new string[1024];
    format(string, sizeof(string), "UPDATE `ddoors` SET \
        `Description`='%s', \
        `CustomInterior`=%d, \
        `ExteriorVW`=%d, \
        `ExteriorInt`=%d, \
        `InteriorVW`=%d, \
        `InteriorInt`=%d, \
        `ExteriorX`=%f, \
        `ExteriorY`=%f, \
        `ExteriorZ`=%f, \
        `ExteriorA`=%f, \
        `InteriorX`=%f, \
        `InteriorY`=%f, \
        `InteriorZ`=%f, \
        `InteriorA`=%f,"
,
        g_mysql_ReturnEscaped(DDoorsInfo[doorid][ddDescription], MainPipeline),
        DDoorsInfo[doorid][ddCustomInterior],
        DDoorsInfo[doorid][ddExteriorVW],
        DDoorsInfo[doorid][ddExteriorInt],
        DDoorsInfo[doorid][ddInteriorVW],
        DDoorsInfo[doorid][ddInteriorInt],
        DDoorsInfo[doorid][ddExteriorX],
        DDoorsInfo[doorid][ddExteriorY],
        DDoorsInfo[doorid][ddExteriorZ],
        DDoorsInfo[doorid][ddExteriorA],
        DDoorsInfo[doorid][ddInteriorX],
        DDoorsInfo[doorid][ddInteriorY],
        DDoorsInfo[doorid][ddInteriorZ],
        DDoorsInfo[doorid][ddInteriorA]
    );

    format(string, sizeof(string), "%s \
        `CustomExterior`=%d, \
        `VIP`=%d, \
        `Family`=%d, \
        `Faction`=%d, \
        `Admin`=%d, \
        `Wanted`=%d, \
        `VehicleAble`=%d, \
        `Color`=%d, \
        `PickupModel`=%d, \
        `Pass`='%s', \
        `Locked`=%d WHERE `id`=%d"
,
        string,
        DDoorsInfo[doorid][ddCustomExterior],
        DDoorsInfo[doorid][ddVIP],
        DDoorsInfo[doorid][ddFamily],
        DDoorsInfo[doorid][ddFaction],
        DDoorsInfo[doorid][ddAdmin],
        DDoorsInfo[doorid][ddWanted],
        DDoorsInfo[doorid][ddVehicleAble],
        DDoorsInfo[doorid][ddColor],
        DDoorsInfo[doorid][ddPickupModel],
        g_mysql_ReturnEscaped(DDoorsInfo[doorid][dPass], MainPipeline),
        DDoorsInfo[doorid][dLocked],
        doorid+1
    );
}
Reply
#2

not sure, I never tried, but try to put \ after every variable,
because I don't know if this is even possible with a format, I think it is, but I cannot test it atm.
so you always can give it a try.

Ah I don;t think it matters.
Why don't you use something like this for updating rows:
pawn Код:
new querystring[2048];
        format(querystring,2048,"%s%s",querystring,STOCK_GetUpdateFormatFloat("CHAR_HEALTH",p[VAR_CHAR_HEALTH]));
        format(querystring,2048,"%s%s",querystring,STOCK_GetUpdateFormatFloat("CHAR_ARMOUR",p[VAR_CHAR_ARMOUR]));
        format(querystring,2048,"%s%s",querystring,STOCK_GetUpdateFormatFloat("CHAR_X",p[VAR_CHAR_X]));
        format(querystring,2048,"%s%s",querystring,STOCK_GetUpdateFormatFloat("CHAR_Y",p[VAR_CHAR_Y]));
        format(querystring,2048,"%s%s",querystring,STOCK_GetUpdateFormatFloat("CHAR_Z",p[VAR_CHAR_Z]));
        format(querystring,2048,"%s%s",querystring,STOCK_GetUpdateFormatFloat("CHAR_A",p[VAR_CHAR_A]));
        format(querystring,2048,"%s%s",querystring,STOCK_GetUpdateFormatInt("CHAR_INT",p[VAR_CHAR_INT]));
        format(querystring,2048,"%s%s",querystring,STOCK_GetUpdateFormatInt("CHAR_VW",p[VAR_CHAR_VW]));
        format(querystring,2048,"%s%s",querystring,STOCK_GetUpdateFormatInt("CHAR_PICKUP",p[VAR_CHAR_IN_PICKUP]));
        format(querystring,2048,"%s%s",querystring,STOCK_GetUpdateFormatInt("CHAR_PICKUP_NUM",p[VAR_CHAR_PICKUP_NUM]));
        format(querystring, 2048, "UPDATE `plr_character` SET %s `CHAR_ONLINE`=-1 WHERE CHAR_ID = %d",querystring,p[VAR_CHAR_ID]);
        mysql_query_nodata(querystring);

// the STOCK_GetUpdateFormat will return something like this: %s = '%f', or %s = '%s', or %s = '%d',
Reply
#3

I'm gonna try your solution, thank you for the reply.
Reply
#4

Yea well maybe, but this is working fine for me, and it is easy to add and remove parts of it, Also this is just a part of my saving function, and I just like format lol, but yea I think you are true... you are always so I won't discuss about this.
Reply
#5

Quote:
Originally Posted by ******
Посмотреть сообщение
Why not just put the whole string on one line? There is a limit, but you're WAY under it (512). And that's vastly better than calling format over and over and over again!
It might be possible, but is this method invalid, could be the cause of error?

I do not believe so, because I am getting errors on lines like :

pawn Код:
format(query, sizeof(query), "INSERT INTO `flags` (`id` ,`time` ,`issuer` ,`flag`) VALUES ('%d',NOW(),'%s','%s')", sqlid, mysql_ReturnEscaped(admin, MainPipeline), mysql_ReturnEscaped(flag, MainPipeline));
I still am believing it has something to do with Notepad++ and it's way of handling parameters.

I am going to try compile this script on PAWN and will reply here with the result.
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
I meant just put the string on one line, not the whole function.
pawn Код:
format(string, sizeof(string),
        "UPDATE `ddoors` SET `Description`='%s',`CustomInterior`=%d, `ExteriorVW`=%d, `ExteriorInt`=%d, InteriorVW`=%d, `InteriorInt`=%d, `ExteriorX`=%f, `ExteriorY`=%f, `ExteriorZ`=%f, `ExteriorA`=%f, `InteriorX`=%f, `InteriorY`=%f, `InteriorZ`=%f, `InteriorA`=%f, `CustomExterior`=%d, `VIP`=%d, `Family`=%d, `Faction`=%d, `Admin`=%d, `Wanted`=%d, `VehicleAble`=%d, `Color`=%d, `PickupModel`=%d, `Pass`='%s', `Locked`=%d WHERE `id`=%d",
        g_mysql_ReturnEscaped(DDoorsInfo[doorid][ddDescription], MainPipeline),
        DDoorsInfo[doorid][ddCustomInterior],
        DDoorsInfo[doorid][ddExteriorVW],
        DDoorsInfo[doorid][ddExteriorInt],
        DDoorsInfo[doorid][ddInteriorVW],
        DDoorsInfo[doorid][ddInteriorInt],
        DDoorsInfo[doorid][ddExteriorX],
        DDoorsInfo[doorid][ddExteriorY],
        DDoorsInfo[doorid][ddExteriorZ],
        DDoorsInfo[doorid][ddExteriorA],
        DDoorsInfo[doorid][ddInteriorX],
        DDoorsInfo[doorid][ddInteriorY],
        DDoorsInfo[doorid][ddInteriorZ],
        DDoorsInfo[doorid][ddInteriorA],
        DDoorsInfo[doorid][ddCustomExterior],
        DDoorsInfo[doorid][ddVIP],
        DDoorsInfo[doorid][ddFamily],
        DDoorsInfo[doorid][ddFaction],
        DDoorsInfo[doorid][ddAdmin],
        DDoorsInfo[doorid][ddWanted],
        DDoorsInfo[doorid][ddVehicleAble],
        DDoorsInfo[doorid][ddColor],
        DDoorsInfo[doorid][ddPickupModel],
        g_mysql_ReturnEscaped(DDoorsInfo[doorid][dPass], MainPipeline),
        DDoorsInfo[doorid][dLocked],
        doorid+1
    );
Still giving me the same errors :

Код:
test.pwn(19630 -- 19632) : warning 202: number of arguments does not match definition
test.pwn(19630 -- 19632) : warning 202: number of arguments does not match definition
test.pwn(19630 -- 19655) : warning 202: number of arguments does not match definition
test.pwn(19630 -- 19655) : warning 202: number of arguments does not match definition[
Quote:
Originally Posted by ******
Посмотреть сообщение
And if you have got the compiler flags right there should be no difference between Notepad++ and PAWNO - as you say they use the same compiler.
Correct, I have just tested on PAWNO and it is the same.


Additional information if it changes anything:

The part of PAWN.xml for Notepad++(Slice)
I dont think it changes anything, its just for user assisting..

PHP код:
<KeyWord name="format" func="yes">
            <
Overload retVal="">
                <
Param name="output[ ]" />
                <
Param name="len" />
                <
Param name="const format[ ]" />
                <
Param name="{mixed}" />
            </
Overload
a_samp definition of format() :

pawn Код:
format(output[], len, const format[], {Float,_}:...);
Results for Roel's suggestion : still the same.
Reply
#7

Show the g_mysql_ReturnEscaped function, there is usually something wrong with that function with people who try to compile the NGRP mode.
Reply
#8

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
Show the g_mysql_ReturnEscaped function, there is usually something wrong with that function
It was quite useless until i found one of your old posts.

pawn Код:
stock g_mysql_ReturnEscaped()
{
    new EscapedString[256];
    return EscapedString;
}
your reply :

pawn Код:
stock g_mysql_ReturnEscaped(unEscapedString[], connectionHandle)
{
    new EscapedString[256];
    mysql_real_escape_string(unEscapedString, EscapedString, connectionHandle);
    return EscapedString;
}
It was indeed the fault, thank you.
Reply
#9

Quote:
Originally Posted by CmZxC
Посмотреть сообщение
It was quite useless until i found one of your old posts.

pawn Код:
stock g_mysql_ReturnEscaped()
{
    new EscapedString[256];
    return EscapedString;
}
your reply :

pawn Код:
stock g_mysql_ReturnEscaped(unEscapedString[], connectionHandle)
{
    new EscapedString[256];
    mysql_real_escape_string(unEscapedString, EscapedString, connectionHandle);
    return EscapedString;
}
It was indeed the fault, thank you.
Oh cool. Try compiling in Pawno then, I see no real problem in your code and I doubt it has something to do with Notepad++.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)