SA-MP Forums Archive
[Ayuda] Con este Error... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: [Ayuda] Con este Error... (/showthread.php?tid=406073)



[Ayuda] Con este Error... - OTACON - 08.01.2013

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.


Re: [Ayuda] Con este Error... - Daniel-92 - 08.01.2013

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.


Respuesta: Re: [Ayuda] Con este Error... - OTACON - 08.01.2013

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;
}



Re: [Ayuda] Con este Error... - Daniel-92 - 08.01.2013

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;
}



Respuesta: Re: [Ayuda] Con este Error... - OTACON - 08.01.2013

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 .