Error 075: Input line too long
#1

Well, as you can see, this piece of script is too long. So my question is: Does anyone know a different method to do this?

pawn Код:
format(query, sizeof(query), "INSERT INTO players (`id` , \
    `username` , `password` , `money` , `bank` , \
    `Weap1` , `Weap2` , `Weap3` , `Weap4` , `Weap5` , `Weap6` , `Weap7` , `Weap8` , \
    `banned` , `bannedreason` , `lastvisit` , `timeplayed` , `HP` , `Armor` , \
    `faction` , `factionrank` , `joinmessage` , `x` , `y` , `z` , `virtualworld` , \
    `interior` , `coprank` , `medicrank` , `driverrank` , `deliverrank` , \
    `firemanrank` , `businessrank` , `skinod` , `skinof` , `weaponrank`) \
    VALUES (%i, %s, %s, %i, %i, %i, %i, %i, %i,  \
    %i, %i, %i, %i, %i, %s, NOW(), \
    %i, %0.2f, %0.2f, %i, %i \
    %s, %0.2f, %0.2f, %0.2f, %i, %i, %i, %i, \
    %i, %i, %i, %i, %i, %i, %i) \
    "
, id+1, PlayerName(playerid), pPassword[0][playerid], 15000, PlayerInfo[playerid][pBank],\
    PlayerInfo[playerid][pWeap1], PlayerInfo[playerid][pWeap2], PlayerInfo[playerid][pWeap3], \
    PlayerInfo[playerid][pWeap4], PlayerInfo[playerid][pWeap5], PlayerInfo[playerid][pWeap6], \
    PlayerInfo[playerid][pWeap7], PlayerInfo[playerid][pWeap8], PlayerInfo[playerid][pBanned], \
    PlayerInfo[playerid][pBannedReason], PlayerInfo[playerid][pLastVisit],  \
    PlayerInfo[playerid][pTimePlayed],PlayerInfo[playerid][pHP], \
    PlayerInfo[playerid][pArmor],PlayerInfo[playerid][pFaction], \
    PlayerInfo[playerid][pFactionRank],PlayerInfo[playerid][pJoinMessage], \
    PlayerInfo[playerid][pX],PlayerInfo[playerid][pY],PlayerInfo[playerid][pZ],\
    PlayerInfo[playerid][pVirtualWorld], PlayerInfo[playerid][pInterior], \
    PlayerInfo[playerid][pCopRank], PlayerInfo[playerid][pMedicRank], \
    PlayerInfo[playerid][pDriverRank], PlayerInfo[playerid][pDevilerRank], \
    PlayerInfo[playerid][pFiremanRank], PlayerInfo[playerid][pBusinessRank], \
    PlayerInfo[playerid][pSkinOD], PlayerInfo[playerid][pSkinOF], PlayerInfo[playerid][pWeaponRank]);
And yes, this is my own script.

I hope someone can help me
Reply
#2

You can redo this by dividing the work into smaller parts.

Example.
pawn Код:
new
        s_1[256],
        s_2[256],
        s_3[256],
        name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(s_1,sizeof(s_1),"** %s **",name);
    format(s_2,sizeof(s_2),"Cash: [$%d] Bank: [$%d] Total Wealth: [$%d]",pInfo[playerid][pCash] = GetPlayerMoney(playerid),pInfo[playerid][pBank],pInfo[playerid][pCash] + pInfo[playerid][pBank]);
    format(s_3,sizeof(s_3),"Job: [%s] Faction: [%s] Rank: [%s] Materials: [%d] Crack: [%d]",jText,fText,rText,pInfo[playerid][pMats],pInfo[playerid][pCrack]);
I hope you get the idea.
Reply
#3

Yeah I got your idea, I did that before at previous script, but I tried to avoid this.
If there's no other method, I will use yours.

Thank you
Reply
#4

I am not sure if this will work, I cannot test it ATM as I am not on my 'scripting' PC.
Could anyone confirm if this method would work:

pawn Код:
new qw[128], qw2[128], qw3[128], qw4[128], qw5[128], query[256];
format(qw, sizeof(qw), "%i, %s, %s, %i, %i, %i, %i, %i, %i", id+1, PlayerName(playerid), pPassword[0][playerid], 15000, PlayerInfo[playerid][pBank],\
PlayerInfo[playerid][pWeap1], PlayerInfo[playerid][pWeap2], PlayerInfo[playerid][pWeap3], \
PlayerInfo[playerid][pWeap4]);

format(qw2, sizeof(qw2), "%i, %i, %i, %i, %i, %s, NOW()", PlayerInfo[playerid][pWeap5], PlayerInfo[playerid][pWeap6], \
PlayerInfo[playerid][pWeap7], PlayerInfo[playerid][pWeap8], PlayerInfo[playerid][pBanned], \
PlayerInfo[playerid][pBannedReason]);

format(qw3, sizeof(qw3), "%i, %0.2f, %0.2f, %i, %i", layerInfo[playerid][pLastVisit],  \
PlayerInfo[playerid][pTimePlayed],PlayerInfo[playerid][pHP], \
PlayerInfo[playerid][pArmor],PlayerInfo[playerid][pFaction], PlayerInfo[playerid][pFactionRank]);

format(qw4, sizeof(qw4), "%s, %0.2f, %0.2f, %0.2f, %i, %i, %i, %i", PlayerInfo[playerid][pJoinMessage], \
PlayerInfo[playerid][pX],PlayerInfo[playerid][pY],PlayerInfo[playerid][pZ],\
PlayerInfo[playerid][pVirtualWorld], PlayerInfo[playerid][pInterior], \
PlayerInfo[playerid][pCopRank], PlayerInfo[playerid][pMedicRank]);

format(qw5, sizeof(qw5), "%i, %i, %i, %i, %i, %i, %i", PlayerInfo[playerid][pDriverRank], PlayerInfo[playerid][pDevilerRank], \
PlayerInfo[playerid][pFiremanRank], PlayerInfo[playerid][pBusinessRank], \
PlayerInfo[playerid][pSkinOD], PlayerInfo[playerid][pSkinOF], PlayerInfo[playerid][pWeaponRank]);

format(query, sizeof(query), "INSERT INTO players (`id` , \
    `username` , `password` , `money` , `bank` , \
    `Weap1` , `Weap2` , `Weap3` , `Weap4` , `Weap5` , `Weap6` , `Weap7` , `Weap8` , \
    `banned` , `bannedreason` , `lastvisit` , `timeplayed` , `HP` , `Armor` , \
    `faction` , `factionrank` , `joinmessage` , `x` , `y` , `z` , `virtualworld` , \
    `interior` , `coprank` , `medicrank` , `driverrank` , `deliverrank` , \
    `firemanrank` , `businessrank` , `skinod` , `skinof` , `weaponrank`) \
    VALUES (%s, %s, %s, %s, %s)"
, qw, qw2, qw3, qw4, qw5);
Somehow I have the feeling this won't work.
Reply
#5

Use strcat to build the string and then format it all

pawn Код:
strcat(query, "INSERT INTO players (`id` , ");
    strcat(query, "`username` , `password` , `money` , `bank` , ");
    ...
    strcat(query, "VALUES (%i, %s, %s, %i, %i, %i, %i, %i, %i,  ");
    strcat(query, "%i, %i, %i, %i, %i, %s, NOW(), ");
    ...
    strcat(query, "%i, %i, %i, %i, %i, %i, %i)");
    format(query, sizeof(query), query, id+1, PlayerName(playerid), pPassword[0][playerid], 15000, PlayerInfo[playerid][pBank],
    PlayerInfo[playerid][pWeap1], PlayerInfo[playerid][pWeap2], ...);
Reply
#6

MadeMan, thank you very much. Unfortunately I still get this error, but at the 'format' part. How would I be able to do this?

Current code:
pawn Код:
strcat(query, "INSERT INTO players (`id` , ");
    strcat(query, "`username` , `password` , `money` , `bank` , ");
    strcat(query, "`Weap1` , `Weap2` , `Weap3` , `Weap4` , `Weap5` , `Weap6` , `Weap7` , `Weap8` , ");
    strcat(query, "`banned` , `bannedreason` , `lastvisit` , `timeplayed` , `HP` , `Armor` , ");
    strcat(query, "`faction` , `factionrank` , `joinmessage` , `x` , `y` , `z` , `virtualworld` , ");
    strcat(query, "`interior` , `coprank` , `medicrank` , `driverrank` , `deliverrank` , ");
    strcat(query, "`firemanrank` , `businessrank` , `skinod` , `skinof` , `weaponrank`) ");
    strcat(query, "VALUES (%i, %s, %s, %i, %i, %i, %i, %i, %i, ");
    strcat(query, "%i, %i, %i, %i, %i, %s, NOW(), ");
    strcat(query, "%i, %0.2f, %0.2f, %i, %i ");
    strcat(query, "%s, %0.2f, %0.2f, %0.2f, %i, %i, %i, %i, ");
    strcat(query, "%i, %i, %i, %i, %i, %i, %i)");
    format(query, sizeof(query),
    id+1, PlayerName(playerid), pPassword[0][playerid], 15000, PlayerInfo[playerid][pBank],\
    PlayerInfo[playerid][pWeap1], PlayerInfo[playerid][pWeap2], PlayerInfo[playerid][pWeap3], \
    PlayerInfo[playerid][pWeap4], PlayerInfo[playerid][pWeap5], PlayerInfo[playerid][pWeap6], \
    PlayerInfo[playerid][pWeap7], PlayerInfo[playerid][pWeap8], PlayerInfo[playerid][pBanned], \
    PlayerInfo[playerid][pBannedReason], PlayerInfo[playerid][pLastVisit],  \
    PlayerInfo[playerid][pTimePlayed],PlayerInfo[playerid][pHP], \
    PlayerInfo[playerid][pArmor],PlayerInfo[playerid][pFaction], \
    PlayerInfo[playerid][pFactionRank],PlayerInfo[playerid][pJoinMessage], \
    PlayerInfo[playerid][pX],PlayerInfo[playerid][pY],PlayerInfo[playerid][pZ],\
    PlayerInfo[playerid][pVirtualWorld], PlayerInfo[playerid][pInterior], \
    PlayerInfo[playerid][pCopRank], PlayerInfo[playerid][pMedicRank], \
    PlayerInfo[playerid][pDriverRank], PlayerInfo[playerid][pDevilerRank], \
    PlayerInfo[playerid][pFiremanRank], PlayerInfo[playerid][pBusinessRank], \
    PlayerInfo[playerid][pSkinOD], PlayerInfo[playerid][pSkinOF], PlayerInfo[playerid][pWeaponRank]);
Error starting at: the start of the format, until "PlayerInfo[playerid][pTimePlayed],PlayerInfo[playerid][pHP],"..

Any ideas?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)