SA-MP Forums Archive
error 047: array sizes do not match, or destination array is too small - 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: error 047: array sizes do not match, or destination array is too small (/showthread.php?tid=549190)



error 047: array sizes do not match, or destination array is too small - Parlianment - 05.12.2014

Help me please error ;(

PHP код:
new Flood_ip[MAX_PLAYERS][16], Flood_time[MAX_PLAYERS]; 
PHP код:
public OnIncomingConnection(playeridip_address[], port)
{
    if(!
strcmp(ip_addressFlood_ip[playerid], true16))
    {
        if(
GetTickCount() - Flood_time[playerid] < 1000)
        {
            
BlockIpAddress(ip_address60 1000);
        }
    }
    
Flood_time[playerid] = GetTickCount();
    
Flood_ip[playerid] = ip_address;
    return 
1;

________

PHP код:
Flood_ip[playerid] = ip_addresstoerror 047: array sizes do not match, or destination array is too small 



Re: error 047: array sizes do not match, or destination array is too small - Jay_ - 05.12.2014

Since technically we don't know the size of the ip_address[] array it's not possible to directly allocate it to an array which we do know the size of.

Use the format() function.
pawn Код:
format(Flood_ip[playerid], sizeof(Flood_ip[playerid]), "%s", ip_address);



Re: error 047: array sizes do not match, or destination array is too small - Lordzy - 05.12.2014

There's no need of using format function just to copy strings. strcpy can be used instead and it's faster compared to format.


Re: error 047: array sizes do not match, or destination array is too small - Parlianment - 05.12.2014

Quote:
Originally Posted by Jay_
Посмотреть сообщение
Since technically we don't know the size of the ip_address[] array it's not possible to directly allocate it to an array which we do know the size of.

Use the format() function.
pawn Код:
format(Flood_ip[playerid], sizeof(Flood_ip[playerid]), "%s", ip_address);
PHP код:
public OnIncomingConnection(playeridip_address[], port)
{
    if(!
strcmp(ip_addressFlood_ip[playerid], true16))
    {
        if(
GetTickCount() - Flood_time[playerid] < 1000)
        {
            
BlockIpAddress(ip_address60 1000);
        }
    }
    
Flood_time[playerid] = GetTickCount();
    
//Flood_ip[playerid] = ip_address;
    
format(Flood_ip[playerid], sizeof(Flood_ip[playerid]), "%s"ip_address);
    return 
1;

?