30.01.2019, 13:02
How to check if the integer array is empty without additional variable?
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?
|
#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(...))