#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
/*
if(IsPlayerConnected(i) && array[i][zize1] != false && array[playerid][zize1] != true) count++
la dimencion del array en el "stock" no es la correcta deberia ser array[][] ya que lo usas en segunda dimensiуn.
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;
}
#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;
}
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 Код:
|