SA-MP Forums Archive
Input Line too long(after substitutions) - 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: Input Line too long(after substitutions) (/showthread.php?tid=335182)



Input Line too long(after substitutions) - Jstylezzz - 17.04.2012

Hi,


EDIT:
These are the errors i'm getting now.. anyone any idea whats going wrong??
Errors:

Код:
E:\Programming\WSRP\gamemodes\wsrpmysql.pwn(1270) : error 035: argument type mismatch (argument 2)
E:\Programming\WSRP\gamemodes\wsrpmysql.pwn(1271) : error 035: argument type mismatch (argument 3)
Script Lines:
Код:
new Query[5000]; // however big you require this variable to be
	strcat(Query,"UPDATE `Users` SET `Money` = '%d', `Level` = '%d', `Admin` = '%d', `Helper` = '%d', `VipLevel` = '%d', `Skin` '%d', `Kills` = '%d', `Deaths` = '%d', `Muted` = '%d', `Cell` = '%d', `Cigs` = '%d', `Watch` = '%d', `Mask` = '%d', `GasCan` = '%d'");
	strcat(Query," `Sprunk` = '%d', `Stereo` = '%d', `GoldCoins` = '%d', `PaymentMethod` = '%d', WHERE `Username` = '%s'");
	strcat(Query, GetPlayerMoney(playerid),GetPVarInt(playerid,"Score"),GetPVarInt(playerid,"Level"),GetPVarInt(playerid,"Helper"),GetPVarInt(playerid,"Vip Level"),GetPlayerSkin(playerid));
	format(Query,sizeof(Query),GetPVarInt(playerid,"Kills"),GetPVarInt(playerid,"Deaths"),GetPVarInt(playerid,"Muted"),GetPVarInt(playerid,"HasCellphone"),GetPVarInt(playerid,"HasCigs"),GetPVarInt(playerid,"HasWatch"),GetPVarInt(playerid,"HasMask"),GetPVarInt(playerid,"GasCan"),GetPVarInt(playerid,"HasSprunk"),GetPVarInt("HasStereo"),GetPVarInt(playerid,"GoldCoins"),GetPVarInt(playerid,"PMethod"),GetPlayerNameEx(playerid));
	mysql_query(Query);




[OLD]
Well, like the title says, i am stuck on this.
I know what it means, but how can I solve it?
This is the code it's about:

Код:
format(Query,sizeof(Query),"UPDATE `Users` SET `Money` = '%d' `Level` = '%d' `Admin` = '%d' `Helper` = '%d' `VipLevel` = '%d' `Skin` '%d' `Kills` = '%d' `Deaths` = '%d' `Muted` = '%d' `Cell` = '%d' `Cigs` = '%d' `Watch` = '%d' `Mask` = '%d' `GasCan` = '%d' `Sprunk` = '%d' `Stereo` = '%d' `GoldCoins` = '%d' `PaymentMethod` = '%d' WHERE `Username` = '%s' ",GetPlayerMoney(playerid),GetPVarInt(playerid,"Score"),GetPVarInt(playerid,"Level"),GetPVarInt(playerid,"Helper"),GetPVarInt(playerid,"Vip Level"),GetPlayerSkin(playerid),GetPVarInt(playerid,"Kills"),GetPVarInt(playerid,"Deaths"),GetPVarInt(playerid,"Muted"),GetPVarInt(playerid,"HasCellphone"),GetPVarInt(playerid,"HasCigs"),GetPVarInt(playerid,"HasWatch"),GetPVarInt(playerid,"HasMask"),GetPVarInt(playerid,"GasCan"),GetPVarInt(playerid,"HasSprunk"),GetPVarInt("HasStereo"),GetPVarInt(playerid,"GoldCoins"),GetPVarInt(playerid,"PMethod"),GetPlayerNameEx(playerid));
Yeah, I know it's pretty much, but how can i do this shorter/other way??


Re: Input Line too long(after substitutions) - SuperViper - 17.04.2012

That query won't work because there are no commas between each updating variable. Here, use this:

pawn Код:
format(Query, sizeof(Query),"UPDATE `Users` SET `Money`='%d', `Level`='%d', `Admin`='%d', `Helper`='%d', `VipLevel`='%d', `Skin`='%d', `Kills`='%d', `Deaths`='%d', `Muted`='%d', `Cell`='%d', `Cigs`='%d', `Watch`='%d', ",GetPlayerMoney(playerid),GetPVarInt(playerid,"Score"),GetPVarInt(playerid,"Level"),GetPVarInt(playerid,"Helper"),GetPVarInt(playerid,"Vip Level"),GetPlayerSkin(playerid),GetPVarInt(playerid,"Kills"),GetPVarInt(playerid,"Deaths"),GetPVarInt(playerid,"Muted"),GetPVarInt(playerid,"HasCellphone"),GetPVarInt(playerid,"HasCigs"),GetPVarInt(playerid,"HasWatch"));

format(Query, sizeof(Query), "%s`Mask`='%d', `GasCan`='%d', `Sprunk`='%d', `Stereo`='%d', `GoldCoins`='%d', `PaymentMethod`='%d'  WHERE `Username` = '%s' ",query,GetPVarInt(playerid,"HasMask"),GetPVarInt(playerid,"GasCan"),GetPVarInt(playerid,"HasSprunk"),GetPVarInt("HasStereo"),GetPVarInt(playerid,"GoldCoins"),GetPVarInt(playerid,"PMethod"),GetPlayerNameEx(playerid));
Your code is very messy, no offense.


Re: Input Line too long(after substitutions) - ev0lution - 17.04.2012

Regardless of whether or not the query in itself works, the problem is, as it states, that line is too long.
To split it up you could use a function such as strcat like so:
pawn Код:
new Query[5000]; // however big you require this variable to be
strcat(Query,"UPDATE `Users` SET `Money` = '%d' `Level` = '%d' `Admin` = '%d' `Helper` = '%d' `VipLevel` = '%d' `Skin` '%d' `Kills` = '%d' `Deaths` = '%d' `Muted` = '%d' `Cell` = '%d' `Cigs` = '%d' `Watch` = '%d' `Mask` = '%d' `GasCan` = '%d'");
strcat(Query," `Sprunk` = '%d' `Stereo` = '%d' `GoldCoins` = '%d' `PaymentMethod` = '%d' WHERE `Username` = '%s'");
format(Query,sizeof(Query),Query,GetPlayerMoney(playerid),GetPVarInt(playerid,"Score"),GetPVarInt(playerid,"Level"),GetPVarInt(playerid,"Helper"),GetPVarInt(playerid,"Vip Level"),GetPlayerSkin(playerid),GetPVarInt(playerid,"Kills"),GetPVarInt(playerid,"Deaths"),GetPVarInt(playerid,"Muted"),GetPVarInt(playerid,"HasCellphone"),GetPVarInt(playerid,"HasCigs"),GetPVarInt(playerid,"HasWatch"),GetPVarInt(playerid,"HasMask"),GetPVarInt(playerid,"GasCan"),GetPVarInt(playerid,"HasSprunk"),GetPVarInt("HasStereo"),GetPVarInt(playerid,"GoldCoins"),GetPVarInt(playerid,"PMethod"),GetPlayerNameEx(playerid));



Re: Input Line too long(after substitutions) - Jstylezzz - 17.04.2012

EDIT:



hmm.. little problem, i fixed it now, but it says argument type mismatch:

Errors:

Код:
E:\Programming\WSRP\gamemodes\wsrpmysql.pwn(1270) : error 035: argument type mismatch (argument 2)
E:\Programming\WSRP\gamemodes\wsrpmysql.pwn(1271) : error 035: argument type mismatch (argument 3)
Script Lines:
Код:
new Query[5000]; // however big you require this variable to be
	strcat(Query,"UPDATE `Users` SET `Money` = '%d', `Level` = '%d', `Admin` = '%d', `Helper` = '%d', `VipLevel` = '%d', `Skin` '%d', `Kills` = '%d', `Deaths` = '%d', `Muted` = '%d', `Cell` = '%d', `Cigs` = '%d', `Watch` = '%d', `Mask` = '%d', `GasCan` = '%d'");
	strcat(Query," `Sprunk` = '%d', `Stereo` = '%d', `GoldCoins` = '%d', `PaymentMethod` = '%d', WHERE `Username` = '%s'");
	strcat(Query, GetPlayerMoney(playerid),GetPVarInt(playerid,"Score"),GetPVarInt(playerid,"Level"),GetPVarInt(playerid,"Helper"),GetPVarInt(playerid,"Vip Level"),GetPlayerSkin(playerid));
	format(Query,sizeof(Query),GetPVarInt(playerid,"Kills"),GetPVarInt(playerid,"Deaths"),GetPVarInt(playerid,"Muted"),GetPVarInt(playerid,"HasCellphone"),GetPVarInt(playerid,"HasCigs"),GetPVarInt(playerid,"HasWatch"),GetPVarInt(playerid,"HasMask"),GetPVarInt(playerid,"GasCan"),GetPVarInt(playerid,"HasSprunk"),GetPVarInt("HasStereo"),GetPVarInt(playerid,"GoldCoins"),GetPVarInt(playerid,"PMethod"),GetPlayerNameEx(playerid));
	mysql_query(Query);



Re: Input Line too long(after substitutions) - Jstylezzz - 17.04.2012

sry for the small bump, i won't do it again, but this is my last thing before my GM is complete..


Re: Input Line too long(after substitutions) - Spooky - 17.04.2012

Define the GetPVarInt's and names small

eg
pawn Код:
new name = GetPlayerNameEx(playerid);



Re: Input Line too long(after substitutions) - Jstylezzz - 17.04.2012

Quote:
Originally Posted by Spooky
Посмотреть сообщение
Define the GetPVarInt's and names small

eg
pawn Код:
new name = GetPlayerNameEx(playerid);
thanks, i will try this,

Just to be sure, in case this goes wrong, does anyone know whats wrong with the strcat thing? Why does it say argument type mismatch!?


Re: Input Line too long(after substitutions) - Mark™ - 17.04.2012

Quote:
Originally Posted by Jari_Johnson*
Посмотреть сообщение
thanks, i will try this,

Just to be sure, in case this goes wrong, does anyone know whats wrong with the strcat thing? Why does it say argument type mismatch!?
Like it says, check your second param and the third param at line 1270 and 1271.


Re: Input Line too long(after substitutions) - Jstylezzz - 17.04.2012

Quote:
Originally Posted by Xtreme_playa
Посмотреть сообщение
Like it says, check your second param and the third param at line 1270 and 1271.
I did, but i can't find anything wrong.. thats the problem.
I mean, this is the right syntax when using strcat right?
pawn Код:
new Query[5000]; // however big you require this variable to be
    strcat(Query,"UPDATE `Users` SET `Money` = '%d', `Level` = '%d', `Admin` = '%d', `Helper` = '%d', `VipLevel` = '%d', `Skin` '%d', `Kills` = '%d', `Deaths` = '%d', `Muted` = '%d', `Cell` = '%d', `Cigs` = '%d', `Watch` = '%d', `Mask` = '%d', `GasCan` = '%d'");
    strcat(Query," `Sprunk` = '%d', `Stereo` = '%d', `GoldCoins` = '%d', `PaymentMethod` = '%d', WHERE `Username` = '%s'");
    strcat(Query,GetPlayerMoney(playerid),GetPVarInt(playerid,"Score"),GetPVarInt(playerid,"Level"),GetPVarInt(playerid,"Helper"),GetPVarInt(playerid,"Vip Level"),GetPlayerSkin(playerid));
    format(Query,sizeof(Query),GetPVarInt(playerid,"Kills"),GetPVarInt(playerid,"Deaths"),GetPVarInt(playerid,"Muted"),GetPVarInt(playerid,"HasCellphone"),GetPVarInt(playerid,"HasCigs"),GetPVarInt(playerid,"HasWatch"),GetPVarInt(playerid,"HasMask"),GetPVarInt(playerid,"GasCan"),GetPVarInt(playerid,"HasSprunk"),GetPVarInt("HasStereo"),GetPVarInt(playerid,"GoldCoins"),GetPVarInt(playerid,"PMethod"),GetPlayerNameEx(playerid));
    mysql_query(Query);
@spooky yes, i checked it..


Re: Input Line too long(after substitutions) - Mark™ - 17.04.2012

Quote:
Originally Posted by Jari_Johnson*
Посмотреть сообщение
I did, but i can't find anything wrong.. thats the problem.
I mean, this is the right syntax when using strcat right?
pawn Код:
new Query[5000]; // however big you require this variable to be
    strcat(Query,"UPDATE `Users` SET `Money` = '%d', `Level` = '%d', `Admin` = '%d', `Helper` = '%d', `VipLevel` = '%d', `Skin` '%d', `Kills` = '%d', `Deaths` = '%d', `Muted` = '%d', `Cell` = '%d', `Cigs` = '%d', `Watch` = '%d', `Mask` = '%d', `GasCan` = '%d'");
    strcat(Query," `Sprunk` = '%d', `Stereo` = '%d', `GoldCoins` = '%d', `PaymentMethod` = '%d', WHERE `Username` = '%s'");
    strcat(Query,GetPlayerMoney(playerid),GetPVarInt(playerid,"Score"),GetPVarInt(playerid,"Level"),GetPVarInt(playerid,"Helper"),GetPVarInt(playerid,"Vip Level"),GetPlayerSkin(playerid));
    format(Query,sizeof(Query),GetPVarInt(playerid,"Kills"),GetPVarInt(playerid,"Deaths"),GetPVarInt(playerid,"Muted"),GetPVarInt(playerid,"HasCellphone"),GetPVarInt(playerid,"HasCigs"),GetPVarInt(playerid,"HasWatch"),GetPVarInt(playerid,"HasMask"),GetPVarInt(playerid,"GasCan"),GetPVarInt(playerid,"HasSprunk"),GetPVarInt("HasStereo"),GetPVarInt(playerid,"GoldCoins"),GetPVarInt(playerid,"PMethod"),GetPlayerNameEx(playerid));
    mysql_query(Query);
@spooky yes, i checked it..
Highlight line 1270 and 1271 here