Input too long after substitutions?
#1

Here's my code:
pawn Код:
if (strlen(APlayerData[playerid][PlayerPassword]) != 0)
    {
        new score = GetPlayerScore(playerid);
        new money = GetPlayerMoney(playerid);
        new query[1000], pname[24];
        GetPlayerName(playerid, pname, 24); // line 573
        format(query, sizeof(query), "UPDATE `PlayerData` SET Score='%d', Ip='%s', PlayerLevel='%d', StatsMetersDriven='%d', StatsTruckerJobs='%d', StatsConvoyJobs='%d', StatsBusDriverJobs='%d', StatsPilotJobs='%d', StatsMafiaJobs='%d', StatsMafiaStolen='%d', StatsPoliceFined='%d', StatsPoliceJailed='%d', StatsAssistance='%d', StatsCourierJobs='%d', StatsRoadworkerJobs='%d', Money='%d', OFWarns='%d' WHERE `Name`='%s'", score,IP, APlayerData[playerid][PlayerLevel], APlayerData[playerid][StatsMetersDriven],APlayerData[playerid][StatsTruckerJobs],APlayerData[playerid][StatsConvoyJobs],APlayerData[playerid][StatsBusDriverJobs],APlayerData[playerid][StatsPilotJobs],APlayerData[playerid][StatsMafiaJobs],APlayerData[playerid][StatsMafiaStolen],APlayerData[playerid][StatsPoliceFined],APlayerData[playerid][StatsPoliceJailed],APlayerData[playerid][StatsAssistance],APlayerData[playerid][StatsCourierJobs],APlayerData[playerid][StatsRoadworkerJobs],money,APlayerData[playerid][OFWarns],pname);
        mysql_query(query);
    }
And here's the error:

Код:
C:\Users\Barbara\Desktop\SAMP Kevin\hoi\gamemodes\TruckingGame.pwn(573) : error 075: input line too long (after substitutions)
What did I do wrong in this code?
Reply
#2

pawn Код:
format(query, sizeof(query), "UPDATE `PlayerData` SET Score='%d', Ip='%s', PlayerLevel='%d', StatsMetersDriven='%d', StatsTruckerJobs='%d', StatsConvoyJobs='%d', StatsBusDriverJobs='%d', StatsPilotJobs='%d', StatsMafiaJobs='%d', StatsMafiaStolen='%d', StatsPoliceFined='%d', StatsPoliceJailed='%d', StatsAssistance='%d', StatsCourierJobs='%d', StatsRoadworkerJobs='%d', Money='%d', OFWarns='%d' WHERE `Name`='%s'", score,IP, APlayerData[playerid][PlayerLevel], APlayerData[playerid][StatsMetersDriven],APlayerData[playerid][StatsTruckerJobs],
APlayerData[playerid][StatsConvoyJobs],APlayerData[playerid][StatsBusDriverJobs],APlayerData[playerid][StatsPilotJobs],APlayerData[playerid][StatsMafiaJobs],APlayerData[playerid][StatsMafiaStolen],APlayerData[playerid][StatsPoliceFined],APlayerData[playerid][StatsPoliceJailed],APlayerData[playerid][StatsAssistance],APlayerData[playerid][StatsCourierJobs],APlayerData[playerid][StatsRoadworkerJobs],money,APlayerData[playerid][OFWarns],pname);
Reply
#3

It still gives me the same error.
Reply
#4

Anyone?
Reply
#5

http://puu.sh/zKMx
Reply
#6

Split your query in to multiple lines.

For example:

pawn Код:
new
     szQuery[768];

format(szQuery, sizeof(szQuery), "UPDATE `players` SET `value` = 1, `value2` = 6, `value3` = 'cats'");

// Notice how 'szQuery' is being formatted again, so we can get the value of the format() we constructed above, and then we can combine it all in to a single string.
format(szQuery, sizeof(szQuery), "%s `value4` = 'sixtytwo', `value5` = 'thefutureiswithinyoursights'", szQuery);

// Keep doing what I've done above. Split it in to a new format each time it overflows and gives you an error with your input lengths, like so:

format(szQuery, sizeof(szQuery), "%s `value6` = 'itsalright', `value7` = 'junglemassive'", szQuery);

// And we're getting everything from above, *again*
// If you see, we're ending the query now. The other format lines above are for the first part of the query and here's where we end it.
format(szQuery, sizeof(szQuery), "%s WHERE `Name` = '%s'", szQuery, GetPlayerNameEx(playerid));
Reply
#7

~Delete
Reply
#8

In the most causes its enough to put it into seperate lines
pawn Код:
// this does work
    if(strlen(APlayerData[playerid][PlayerPassword]) != 0) {
        new score = GetPlayerScore(playerid);
        new money = GetPlayerMoney(playerid);
        new query[1000], pname[24];
        GetPlayerName(playerid, pname, sizeof pname);
        format(query, sizeof(query), // the string is only 384 long, limit is over 500
            "UPDATE `PlayerData` SET Score='%d', Ip='%s', PlayerLevel='%d', StatsMetersDriven='%d', StatsTruckerJobs='%d', StatsConvoyJobs='%d', StatsBusDriverJobs='%d', StatsPilotJobs='%d', StatsMafiaJobs='%d', StatsMafiaStolen='%d', StatsPoliceFined='%d', StatsPoliceJailed='%d', StatsAssistance='%d', StatsCourierJobs='%d', StatsRoadworkerJobs='%d', Money='%d', OFWarns='%d' WHERE `Name`='%s'",
            score, IP, APlayerData[playerid][PlayerLevel], APlayerData[playerid][StatsMetersDriven],APlayerData[playerid][StatsTruckerJobs],APlayerData[playerid][StatsConvoyJobs],APlayerData[playerid][StatsBusDriverJobs],APlayerData[playerid][StatsPilotJobs],
            APlayerData[playerid][StatsMafiaJobs],APlayerData[playerid][StatsMafiaStolen],APlayerData[playerid][StatsPoliceFined],APlayerData[playerid][StatsPoliceJailed],APlayerData[playerid][StatsAssistance],APlayerData[playerid][StatsCourierJobs],APlayerData[playerid][StatsRoadworkerJobs],money,APlayerData[playerid][OFWarns],pname
        );
        mysql_query(query);
    }
if the string is over 500 you should declare it globally (the compiler does that anyways)
pawn Код:
new
    myQuery[] = "UPDATE `PlayerData` SET Score='%d', Ip='%s', PlayerLevel='%d', StatsMetersDriven='%d', StatsTruckerJobs='%d', StatsConvoyJobs='%d', StatsBusDriverJobs='%d',",
    myQuery1[] = "StatsPilotJobs='%d', StatsMafiaJobs='%d', StatsMafiaStolen='%d', StatsPoliceFined='%d', StatsPoliceJailed='%d', StatsAssistance='%d',",
    myQuery2[] = "StatsCourierJobs='%d', StatsRoadworkerJobs='%d', Money='%d', OFWarns='%d' WHERE `Name`='%s'"
;
//OnGameModeInit
// lets replace the EOS with a space
myQuery[sizeof myQuery - 1] = myQuery1[sizeof myQuery1 - 1] = ' ';
// we need to use myQuery2 at least once otherwise the compiler will remove it
myQuery2[sizeof myQuery2 - 1] = EOS;
// now if you want to test it
print(myQuery);
// it will print the whole query
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)