AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   number of arguments does not match definition (https://forums.alliedmods.net/showthread.php?t=196313)

n0br41ner 09-18-2012 12:21

number of arguments does not match definition
 
1.
PHP Code:

BuildMapVoteMenu() {
    
g_iMapVoteBodyLenght copy(g_iMapVoteBody511"\rMap Vote:^n");
    
    for(new 
i=1i<10i++) {
        
g_iMapVoteBodyLenght += copy(g_iMapVoteBody[g_iMapVoteBodyLenght], (511-g_iMapVoteBodyLenght), "^n\r%d\y. \w%s"ig_iPickedMaps[i]);
    }
    
    return 
PLUGIN_HANDLED;


2.
PHP Code:

BuildTeamsTypeVoteMenu() {
    
copy(g_iTeamsTypeVoteBody149"\rTeams Type Vote:^n^n\r1\y. \w%s^n\r2\y. \w%s^n\r3\y. \w%s^n^n\r0\y. \yEXIT"TEAMS_TYPE_VOTE1TEAMS_TYPE_VOTE2TEAMS_TYPE_VOTE3);
    
    return 
PLUGIN_HANDLED;


3.
PHP Code:

BuildOverTimeVoteMenu() {
    
copy(g_iOverTimeVoteBody149"\rOver Time Vote:^n^n\r1\y. \w%s^n\r2\y. \w%s^n^n\r0\y. \yEXIT"YESNO);
    
    return 
PLUGIN_HANDLED;


All these functions are returning this error: "error 088: number of arguments does not match definition"

How is it that the arguments does not match, am i not allowed to to use the %s?
If i am not allowed, then what should i do? What alternative should i adopt?

Please explain, i am confused.

Thanks in advance...

Alka 09-18-2012 13:04

Re: number of arguments does not match definition
 
Code:

Syntax
copy ( dest[], len, const src[] )

You can't format the string. Use formatex() instead

n0br41ner 09-18-2012 13:22

Re: number of arguments does not match definition
 
Can you make an example?

Transform #3 using formatex... cause i can't see the formatex in the func wiki :(

Liverwiz 09-18-2012 13:33

Re: number of arguments does not match definition
 
Quote:

Originally Posted by n0br41ner (Post 1801924)
Can you make an example?

Transform #3 using formatex... cause i can't see the formatex in the func wiki :(

use the include files.

Quote:

/* Same as format(), except does not perform a "copy back" check.
* This means formatex() is faster, but DOES NOT ALLOW this type
* of call:
* formatex(buffer, len, "%s", buffer)
* formatex(buffer, len, buffer, buffer)
* formatex(buffer, len, "%s", buffer[5])
* This is because the output is directly stored into "buffer",
* rather than copied back at the end.
*/
native formatex(output[] ,len ,const format[] , any:...);

n0br41ner 09-18-2012 13:37

Re: number of arguments does not match definition
 
Alright thanks a lot.

n0br41ner 09-18-2012 19:10

Re: number of arguments does not match definition
 
Can anyone check if i implemented it correctly? (commented line is the old one)
PHP Code:

for(new i=1i<10i++) {
        
g_iMapVoteBodyLenght += format(g_iMapVoteBody[g_iMapVoteBodyLenght], (511-g_iMapVoteBodyLenght), "^n\r%d\y. \w%s"ig_iPickedMaps[i]);
        
// g_iMapVoteBodyLenght += copy(g_iMapVoteBody[g_iMapVoteBodyLenght], (511-g_iMapVoteBodyLenght), "^n\r%d\y. \w%s", i, g_iPickedMaps[i]);
    



fysiks 09-18-2012 19:27

Re: number of arguments does not match definition
 
Quote:

Originally Posted by n0br41ner (Post 1802112)
Can anyone check if i implemented it correctly? (commented line is the old one)
PHP Code:

for(new i=1i<10i++) {
        
g_iMapVoteBodyLenght += format(g_iMapVoteBody[g_iMapVoteBodyLenght], (511-g_iMapVoteBodyLenght), "^n\r%d\y. \w%s"ig_iPickedMaps[i]);
        
// g_iMapVoteBodyLenght += copy(g_iMapVoteBody[g_iMapVoteBodyLenght], (511-g_iMapVoteBodyLenght), "^n\r%d\y. \w%s", i, g_iPickedMaps[i]);
    



Why did you not listen to the advice given? Also, test it yourself. You will find out very quickly if it works or not.

Liverwiz 09-19-2012 09:17

Re: number of arguments does not match definition
 
where did anyone say anything about format? Use formatex. Its more efficient and required to get a plugin approved. Maybe not officially, but if you're doing that...."its poorly coded"

Also use charsmax(g_iMapVoteBody) - g_iMapVoteBodyLength instead of 511. It'll make things easier in the future. I promise.


All times are GMT -4. The time now is 08:22.

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