AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Error: Array sizes do not match (https://forums.alliedmods.net/showthread.php?t=153932)

FlyingHorse 03-31-2011 14:14

Error: Array sizes do not match
 
what am i doing wrong here? And could anyone fix that for me... just get one error when i try to compile:

Code:

Error: Array sizes do not match, or destination array is too small on line 27
PHP Code:

public client_putinserver(id)
{
    new 
Country[4], Ip[21]
    
get_user_ip(idIpcharsmax(Ip))
    
geoip_countryIpCountry );
    new 
name[32], szCountry[4], szIP[21
    
get_user_ip(idszIPcharsmax(szIP)) 
    
geoip_code2szIPszCountry );
    
get_user_name(idname31
    
    new 
szAuth[35];
    
get_user_authid(idszAuthcharsmax(szAuth));
    
    if( 
equal(szAuth"STEAM_0:0:39679185"))
    {
        
ColorChat(0RED"%s^x01 %s^x03 [%s]^x04 %s^x01 Has connected from^x04 %s"ClanTagCLMsgszCountrynameCountry)
    }
    else
    {
        
ColorChat(0RED"%s^x01 %s^x03 [%s]^x04 %s^x01 Has connected from^x04 %s"ClanTagIsUserAdmin(id) ? "Admin" "Player"szCountrynameCountry);
    }



Emp` 03-31-2011 14:54

Re: Error: Array sizes do not match
 
We need to know what line 27 is.

FlyingHorse 03-31-2011 15:10

Re: Error: Array sizes do not match
 
Quote:

Originally Posted by Emp` (Post 1442254)
We need to know what line 27 is.


geoip_code2( szIP, szCountry );

tuty 03-31-2011 16:36

Re: Error: Array sizes do not match
 
your array is to small like include said...

PHP Code:

Max name is 45 characters

try to add 45 on your array

FlyingHorse 03-31-2011 17:22

Re: Error: Array sizes do not match
 
Quote:

Originally Posted by tuty (Post 1442298)
your array is to small like include said...

PHP Code:

Max name is 45 characters

try to add 45 on your array

My english sucsk.. dont understand very good. could anyone fix that for me?..

bibu 03-31-2011 17:30

Re: Error: Array sizes do not match
 
My god -.-'

szCountry[45]

FlyingHorse 03-31-2011 17:34

Re: Error: Array sizes do not match
 
tried but still doesnt work :o.. same error as before

PHP Code:

public client_putinserver(id)
{
    new 
Country[4], Ip[21]
    
get_user_ip(idIpcharsmax(Ip))
    
geoip_countryIpCountry );
    new 
name[32], szCountry[45], szIP[21
    
get_user_ip(idszIPcharsmax(szIP));
    
geoip_code2szIPszCountry );
    
get_user_name(idname31
    
    new 
szAuth[35];
    
get_user_authid(idszAuthcharsmax(szAuth));
    
    if( 
equal(szAuth"STEAM_0:0:39679185"))
    {
        
ColorChat(0RED"%s^x01 %s^x03 [%s]^x04 %s^x01 Has connected from^x04 %s"ClanTagCLMsgszCountrynameCountry)
    }
    
    else
    {
        
ColorChat(0RED"%s^x01 %s^x03 [%s]^x04 %s^x01 Has connected from^x04 %s"ClanTagIsUserAdmin(id) ? "Admin" "Player"szCountrynameCountry);
    }


i have one that shows 2 character country and one that shows the full name of it.. and ive never done that before in the same mesasge

Emp` 03-31-2011 18:49

Re: Error: Array sizes do not match
 
Quote:

Originally Posted by tuty (Post 1442298)
your array is to small like include said...

PHP Code:

Max name is 45 characters

try to add 45 on your array

That is actually completely wrong.

If we look at geoip_code2, you can see that the second parameter has a declared array size (3). You need to pass an array for the second parameter that has that same array size.

@FlyingHorse: szCountry[3]

Exolent[jNr] 03-31-2011 19:00

Re: Error: Array sizes do not match
 
geoip_code2() takes an array size of 3.
Also, geoip_country() can give a result up to 45 characters, so you should increase your array size.

Code:

public client_putinserver(id)
{
    new Country[46], Ip[21]
    get_user_ip(id, Ip, charsmax(Ip))
    geoip_country( Ip, Country, 45 );
    new name[32], szCountry[3], szIP[21]
    get_user_ip(id, szIP, charsmax(szIP))
    geoip_code2( szIP, szCountry );
    get_user_name(id, name, 31)
   
    new szAuth[35];
    get_user_authid(id, szAuth, charsmax(szAuth));
   
    if( equal(szAuth, "STEAM_0:0:39679185"))
    {
        ColorChat(0, RED, "%s^x01 %s^x03 [%s]^x04 %s^x01 Has connected from^x04 %s", ClanTag, CLMsg, szCountry, name, Country)
    }
    else
    {
        ColorChat(0, RED, "%s^x01 %s^x03 [%s]^x04 %s^x01 Has connected from^x04 %s", ClanTag, IsUserAdmin(id) ? "Admin" : "Player", szCountry, name, Country);
    }
}



All times are GMT -4. The time now is 14:41.

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