How to check if the integer array is empty without additional variable?
|
And why do you not want to use additional variables? They aren't expensive.
|
An array can never be empty even if all the values are zero as zero is still a value! Your question makes no sense really. Maybe you want to check if integer array is null? All values 0? How the heck is anyone supposed to know?
|
And why do you not want to use additional variables? They aren't expensive.
|
#include <a_samp>
#include <streamer>
#include <sscanf2>
#include <ColAndreas>
#include <zcmd>
#include <YSI_Core\y_utils>
#include <YSI_Coding\y_timers>
new Timer:timer1;
new Grass[5];
new br=0;
new scfmString[250];
#define SCM SendClientMessage
#define SCFM(%1,%2,%3) format(scfmString,sizeof(scfmString),%3), SCM(%1,%2,scfmString)
public OnFilterScriptInit()
{
CA_Init();
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
CMD:as(playerid, params[], help)
{
for(new i=0; i<5; i++)
{
new Float:randx = RandomFloat(109.2241-92.6121)+92.6121;
new Float:randy = RandomFloat(-71.6366-(-57.7923))+57.7923;
new Float:z;
CA_FindZ_For2DCoord(randx, randy, z);
Grass[i] = CreatePlayerObject(playerid, 802, randx, randy, z+0.2, 0, 0, 0);
}
timer1 = repeat Tajmer(playerid);
return 1;
}
CMD:aa(playerid, params[], help)
{
stop timer1;
return 1;
}
timer Tajmer[100](playerid)
{
new Float:x,Float:y,Float:z;
for(new i=0; i<sizeof(Grass); i++)
{
GetPlayerObjectPos(playerid, Grass[i], x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 1, x, y, z))
{
DestroyPlayerObject(playerid, Grass[i]);
Grass[i] = 0;
br++;
}
}
if(br >= sizeof(Grass))
{
SendClientMessage(playerid, -1,"No grass");
}
return 1;
}
if(IsPlayerInRangeOfPoint(playerid, 1, x, y, z))
{
DestroyPlayerObject(playerid, Grass[i]);
Grass[i] = 0;
br++;
}
if(Grass[i] != 0 && IsPlayerInRangeOfPoint(...))
if(GetPlayerObjectPos(playerid, Grass[i], x, y, z) && IsPlayerInRangeOfPoint(...))
For this to be true:
br >= sizeof(Grass) They would have to be right next to every piece of grass at the same time. Is that the case? |