[Ayuda] Con este Error...
#1

Buenas a Todos, Me pueden ayudar con este error.

pawn Код:
#include <a_samp>
new bool:variable[MAX_PLAYERS][1];

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        if(!detectar(playerid, variable, 0, 5)) return 1;
        //Funcion
        return 1;
    }
    return 0;
}

stock detectar(playerid, array[], zize1, zize2)
{
    new count=0;
    for(new i=0; i<GetMaxPlayers(); i++)
    if(IsPlayerConnected(i) && array[i][zize1] != false && array[playerid][zize1] != true) count++;
    if(count == zize2) return 1;
    return 0;
}

/*
(9) :  if(!detectar(playerid, variable, 0, 5)) return 1;
(20) : if(IsPlayerConnected(i) && array[i][zize1] != false && array[playerid][zize1] != true) count++;

(9) : error 048: array dimensions do not match
(20) : error 001: expected token: ")", but found "["
(20) : error 029: invalid expression, assumed zero
(20) : warning 215: expression has no effect
(20) : error 001: expected token: ";", but found "]"
(20) : fatal error 107: too many error messages on one line
/*
desde ya muchas Gracias.
Reply
#2

la dimencion del array en el "stock" no es la correcta deberia ser array[][] ya que lo usas en segunda dimensiуn.

pawn Код:
if(IsPlayerConnected(i) && array[i][zize1] != false && array[playerid][zize1] != true) count++
eso esta mal array[playerid][zize1] no puede ser falso ni positivo al mismo tiempo.
Reply
#3

Quote:
Originally Posted by Daniel-92
Посмотреть сообщение
la dimencion del array en el "stock" no es la correcta deberia ser array[][] ya que lo usas en segunda dimensiуn.

pawn Код:
if(IsPlayerConnected(i) && array[i][zize1] != false && array[playerid][zize1] != true) count++
eso esta mal array[playerid][zize1] no puede ser falso ni positivo al mismo tiempo.
lo ultimo esta bien, es uno para el GetMaxPlayers y el otro para el player ke identifica playerid del stock.

asi funciona perfecto:

pawn Код:
#include <a_samp>
new bool:variable[MAX_PLAYERS][1];

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        if(!detectar(playerid)) return 1;
        //Funcion
        return 1;
    }
    return 0;
}

stock detectar(playerid)
{
    new count=0;
    for(new i=0; i<GetMaxPlayers(); i++)
    if(IsPlayerConnected(i) && variable[i][0] != false && variable[playerid][0] != true) count++;
    if(count == 5) return 1;
    return 0;
}
yo kiero modificar el stock para utilizarlo con otra variable y no crear otro stock.
stock detectar(playerid)
{
new count=0;
for(new i=0; i<GetMaxPlayers(); i++)
if(IsPlayerConnected(i) && variable[i][0] != false && variable[playerid][0] != true) count++;
if(count == 5) return 1;
return 0;
}
Reply
#4

En mi caso preferiria retornar la variable count y compararla en el if se es igual a 5, tambien no sй lo que pretendes hacer pero con ese ejemplo que pones lo mejor seria usar arrays en una dimension.
pawn Код:
#include <a_samp>

new bool:variable[MAX_PLAYERS][1];

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        if(!detectar(playerid, variable, sizeof variable[], 5)) {
            //Funcion
            return 1;
        }
        return 1;
    }
    return 0;
}

stock detectar(playerid, array[][], size1,size2)
{
    new count=0;
    for(new i=0; i < GetMaxPlayers(); i++)
        for(new j=0; j < size1; j++)
            if(IsPlayerConnected(i) && array[i][j] && !array[playerid][j]) count++;

    if(count == size2) return 1;
    return 0;
}
Reply
#5

Quote:
Originally Posted by Daniel-92
Посмотреть сообщение
En mi caso preferiria retornar la variable count y compararla en el if se es igual a 5, tambien no sй lo que pretendes hacer pero con ese ejemplo que pones lo mejor seria usar arrays en una dimension.
pawn Код:
#include <a_samp>

new bool:variable[MAX_PLAYERS][1];

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        if(!detectar(playerid, variable, sizeof variable[], 5)) {
            //Funcion
            return 1;
        }
        return 1;
    }
    return 0;
}

stock detectar(playerid, array[][], size1,size2)
{
    new count=0;
    for(new i=0; i < GetMaxPlayers(); i++)
        for(new j=0; j < size1; j++)
            if(IsPlayerConnected(i) && array[i][j] && !array[playerid][j]) count++;

    if(count == size2) return 1;
    return 0;
}
ah, si hay lo entendi .
Gracias .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)