error 047: array sizes do not match, or destination array is too small
#1

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 
Reply
#2

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);
Reply
#3

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

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;

?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)