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

Help me to fix this error: "number of arguments does not match definition"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GlobalPlague
Senior Member
Join Date: Feb 2016
Location: Pluto
Old 02-15-2022 , 11:02   Help me to fix this error: "number of arguments does not match definition"
Reply With Quote #1

Hello. I opened the main code of ZPA, and i added the following code at the bottom of the main ZPA code:

PHP Code:
AddCommasiNum szOutput[] , iLen )
{
    new 
szTmp15 ] , iOutputPos iNumPos iNumLen;
    
    if ( 
iNum )
    {
        
szOutputiOutputPos++ ] = '-';
        
iNum absiNum );
    }
    
    
iNumLen num_to_striNum szTmp charsmaxszTmp ) );

    if ( 
iNumLen <= )
    {
        
iOutputPos += copyszOutputiOutputPos ] , iLen szTmp );
    }
    else
    {
        while ( ( 
iNumPos iNumLen ) && ( iOutputPos iLen ) ) 
        {
            
szOutputiOutputPos++ ] = szTmpiNumPos++ ];
        
            if( ( 
iNumLen iNumPos ) && !( ( iNumLen iNumPos ) % ) ) 
                
szOutputiOutputPos++ ] = ',';
        }
        
        
szOutputiOutputPos ] = EOS;
    }
    
    return 
iOutputPos;

Then i added "AddCommas" in the following code:

Code:
	// Spectating someone else?
	if (id != ID_SHOWHUD)
	{
		// Show name, health, class, and ammo packs and armor
		set_dhudmessage(0, 0, 138, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0)
		show_dhudmessage(ID_SHOWHUD, "%L %s^nHP: %d - %L %s - %L %d - %L %d", ID_SHOWHUD, "SPECTATING", g_playername[id],
		pev(id, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[id], ID_SHOWHUD, "ARMOR", pev(id, pev_armorvalue))
	}
	else
	{
		// Show health, class and ammo packs and armor
		set_dhudmessage(red, green, blue, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0)
		show_dhudmessage(ID_SHOWHUD, "%L: %d - %L %s - %L %d - %L %d^nXP: %d/%d | Level: %d/%d: %s", id, "ZOMBIE_ATTRIB1", pev(ID_SHOWHUD, pev_health), ID_SHOWHUD, "CLASS_CLASS",
		class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[ID_SHOWHUD], ID_SHOWHUD, "ARMOR", pev(ID_SHOWHUD, pev_armorvalue), mysystem_get_user_xp(id), mysystem_get_user_next_xp(id), mysystem_get_user_level(id), mysystem_get_max_levels(), rankname, AddCommas(g_ammopacks[id]))
	}
}
The "AddCommas" is marked in red, so it can be easier for you to see it. Just use the scroll-bar, and move it to the right side of your screen, so you can see where the "AddCommas" is added.

When i tried to compile the .sma file, i got the following message:

"zombie_plague_advance_v1-6-1.sma(11136 -- 11137) : error 088: number of arguments does not match definition"

This is the code from line 11136 to 11137:

PHP Code:
        show_dhudmessage(ID_SHOWHUD"%L: %d - %L %s - %L %d - %L %d^nXP: %d/%d | Level: %d/%d: %s"id"ZOMBIE_ATTRIB1"pev(ID_SHOWHUDpev_health), ID_SHOWHUD"CLASS_CLASS",
        class, 
ID_SHOWHUD"AMMO_PACKS1"g_ammopacks[ID_SHOWHUD], ID_SHOWHUD"ARMOR"pev(ID_SHOWHUDpev_armorvalue), mysystem_get_user_xp(id), mysystem_get_user_next_xp(id), mysystem_get_user_level(id), mysystem_get_max_levels(), ranknameAddCommas(g_ammopacks[id])) 
So, can someone explain to me how to fix this error?

Thanks.

Last edited by GlobalPlague; 02-15-2022 at 11:05. Reason: mistake
GlobalPlague is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 02-15-2022 , 13:31   Re: Help me to fix this error: "number of arguments does not match definition"
Reply With Quote #2

We told you how to use it in the old topic!!

AddCommas( iNum ( The number that you want to be with commas, szOutput[] Buffer to store the nummber with commas. , Maximum buffer length. )

PHP Code:
new szOutput16 ];
AddCommasiNumszOutput charsmaxszOutput ) )
log_amx"Number with commas: %s"szOutput 
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-15-2022 , 13:33   Re: Help me to fix this error: "number of arguments does not match definition"
Reply With Quote #3

As you can see from the function's body:

Code:
AddCommas( iNum , szOutput[] , iLen )

it has 3 required arguments. You used only the first one - iNum, hence why it says "number of arguments does not match definition".

Since the function formats a string (not a number because numbers cannot contain commas), you need to store the string in a variable (because returning strings directly is not good practice).

Code:
new szNumberWithCommas[10] // 10 would be the maximum length of the string (each number and comma is a separate character - feel free to increase the number if you need more space) AddCommas(g_ammopacks[id], szNumberWithCommas, charsmax(szNumberWithCommas))

Then you would use szNumberWithCommas in your message instead of AddCommas(g_ammopacks[id]).

Also, since you're now working with a string, you must change the %d in the message associated with this argument to %s.

%d is used for numbers (same as %i)
%s is used for strings
__________________

Last edited by OciXCrom; 02-15-2022 at 13:34.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-16-2022 , 08:44   Re: Help me to fix this error: "number of arguments does not match definition"
Reply With Quote #4

Quote:
Originally Posted by OciXCrom View Post
As you can see from the function's body:

Code:
AddCommas( iNum , szOutput[] , iLen )
Its the function parameters.

The function body which what lies between { the curly brackets }

Quote:
Originally Posted by OciXCrom View Post
(not a number because numbers cannot contain commas), you need to store the string in a variable (because returning strings directly is not good practice).
A number can be equal to a comma depending on its definition in ASCII characters order.

Returning a string by value is not recommended because it takes more time until the function stops executing, you can read more about returning strings or arrays by value in the c++ documentation.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 02-16-2022 at 08:45.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-16-2022 , 22:31   Re: Help me to fix this error: "number of arguments does not match definition"
Reply With Quote #5

Quote:
Originally Posted by Natsheh View Post
A number can be equal to a comma depending on its definition in ASCII characters order.
That doesn't make any sense.
__________________
fysiks is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-17-2022 , 02:06   Re: Help me to fix this error: "number of arguments does not match definition"
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
That doesn't make any sense.
He didn't phrase that very well, but what he meant is that characters are internally represented by their ASCII value so a comma is actually a number. ',' = 44

No idea why this was relevant to the topic, you will have to ask Natsheh.
__________________

Last edited by HamletEagle; 02-17-2022 at 02:06.
HamletEagle is offline
Reply



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 08:39.


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