Raised This Month: $32 Target: $400
 8% 

Format() max params ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
waza123a
Member
Join Date: Mar 2010
Old 10-25-2016 , 18:10   Format() max params ?
Reply With Quote #1

I sow that many scripts stops working if Format() parameters are too many.

For example:

Code:
Format(sql, 1024, "some sql %s %d %d %f %s %d %d %f %s %d %d %f %s %d %d %f %s %d %d %f %s %d %d %f %s %d %d %f %s %d %d %f", param1, param2, param3, param4, param5, param6 etc..);
This will not be executed because too many parameters 30 or more.. To make it work, i had to split that in to several format() with max 11 parameters.

Why this is happening ? Some time ago this wasn't a problem. Until now.
__________________
Life is good, sometimes...
waza123a is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 10-25-2016 , 18:13   Re: Format() max params ?
Reply With Quote #2

How it didn't work? A compiler error or a run-time error? Or just didn't format correctly?
klippy is offline
waza123a
Member
Join Date: Mar 2010
Old 10-25-2016 , 18:15   Re: Format() max params ?
Reply With Quote #3

no compilator error, just not working, format is correctly. It's just not executed by sourcemod engine. And all code after this format() not executed.

sm version
SourceMod Version Information:
SourceMod Version: 1.9.0.5987
SourcePawn Engine: 1.9.0.5987, jit-x86 (build 1.9.0.5987)
SourcePawn API: v1 = 4, v2 = 11
Compiled on: Oct 12 2016 1876
Built from: https://github.com/alliedmodders/sou...commit/c097bdc
Build ID: 5987:c097bdc
http://www.sourcemod.net/
__________________
Life is good, sometimes...
waza123a is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 10-25-2016 , 20:36   Re: Format() max params ?
Reply With Quote #4

I don't know where Sourcemod logs its errors and all that stuff, but if no code in that particular function executes after Format() call, it should mean that native has thrown a run-time error. There is probably a log somewhere that says what exactly wrong is going on.

Also, knowing Pawn, there should be no limit to the amount of arguments you can pass into a function (the only limitation should be the stack size, each passed argument takes 4 bytes on it), so I believe you are doing something else wrong. Probably passing too few arguments to the function.

Last edited by klippy; 10-25-2016 at 20:38.
klippy is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 10-25-2016 , 21:19   Re: Format() max params ?
Reply With Quote #5

Quote:
Originally Posted by KliPPy View Post
I don't know where Sourcemod logs its errors and all that stuff, but if no code in that particular function executes after Format() call, it should mean that native has thrown a run-time error. There is probably a log somewhere that says what exactly wrong is going on.

Also, knowing Pawn, there should be no limit to the amount of arguments you can pass into a function (the only limitation should be the stack size, each passed argument takes 4 bytes on it), so I believe you are doing something else wrong. Probably passing too few arguments to the function.
SourceMod logs plugin runtime errors in the error log file located in the logs folder of the running SM base folder (folder containing: plugins, data, etc)
__________________
WildCard65 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 10-25-2016 , 22:36   Re: Format() max params ?
Reply With Quote #6

try just not doing that.
Mitchell is offline
fakuivan
Senior Member
Join Date: Nov 2015
Old 10-27-2016 , 00:19   Re: Format() max params ?
Reply With Quote #7

It might have to do with stack allocation on the vm (oh, it's a native, nevermind)

Last edited by fakuivan; 10-27-2016 at 00:20.
fakuivan is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 10-27-2016 , 01:04   Re: Format() max params ?
Reply With Quote #8

That's a bug. The compiler doesn't enforce the right call argument count. The maximal argument count of a function defined in SP is 32, but you can call a function with up to 127 arguments. Since Format is a vararg function, the compiler lets you currently call it with more than 32 arguments, but the vm checks for the max of 32 in its validator since SM 1.9.

You shouldn't call Format with that many arguments though - unreadable!
__________________
Peace-Maker is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:44.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode