01.01.2014, 17:26
I know, but on the code I provided does not include MAX_OBJECTS, or any value that is over than 255 and lower than 0
Tested that code with crashdetect #include & #plugin doesn't show me any CrashDetect warning, it's also compiled with -d3, test it your self if you don't believe
Tested that code with crashdetect #include & #plugin doesn't show me any CrashDetect warning, it's also compiled with -d3, test it your self if you don't believe

Код:
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase Header size: 968 bytes Code size: 11028 bytes Data size: 4680 bytes Stack/heap size: 16384 bytes; estimated max. usage=113 cells (452 bytes) Total requirements: 33060 bytes
pawn Код:
#include <a_samp>
#include <zcmd>
#include <crashdetect>
#include <YSI\y_stringhash>
#define MAX_LIGHTS \
(12)
new
green_light[MAX_LIGHTS char],
red_light[MAX_LIGHTS char],
purple_light[MAX_LIGHTS char]
;
main(){}
public OnGameModeInit() return AddPlayerClass(0, 1958.33, 1343.12, 15.36, 269.15, 26, 36, 28, 150, 0, 0), 1;
public OnGameModeExit() return true;
public OnPlayerSpawn(playerid) return true;
CMD:lights(playerid, params[])
{
if(isnull(params))
return SendClientMessage(playerid, -1, "Syntax: /lights [colour]");
ClearObjectsFirst(); //clears the last set of created lights for the new set
switch ( YHash( params ) )
{
case _H<green>:
{
SetPlayerPos(playerid, 2001.195679, 1547.113892, 14.283400);
//You need to start from 0
for(new i = 0; i < MAX_LIGHTS; i++)
green_light{i} = CreateObject(18649, 2001.195679, 1547.113892, 14.283400, 0.0, 0.0, 96.0);
SendClientMessage(playerid, -1, "Created Colour Green");
// and so on.
}
case _H<red>:
{
//You need to start from 0
for(new i = 0; i < MAX_LIGHTS; i++) red_light{i} = CreateObject(18647, 2001.195679, 1547.113892, 14.283400, 0.0, 0.0, 96.0);
SendClientMessage(playerid, -1, "Created Colour Red");
// and so on.
}
case _H<purple>:
{
//You need to start from 0
for(new i = 0; i < MAX_LIGHTS; i++) purple_light{i} = CreateObject(18651, 2001.195679, 1547.113892, 14.283400, 0.0, 0.0, 96.0);
SendClientMessage(playerid, -1, "Created Colour Purple");
// and so on.
}
default: SendClientMessage(playerid, -1, "Default - None");
}
//continue to create all the green lights and setting them to green_light_x
return 1;
}
stock ClearObjectsFirst()
{
new
i = 0
;
while(i < MAX_LIGHTS)
{
if(IsValidObject( green_light{i} ) ) //Im only checking for the first one in the set since if one is valid they all should be
{
DestroyObject( green_light{i} );
}
else if(IsValidObject( red_light{i} ) )
{
DestroyObject( red_light{i} );
}
else //the purple lights must be the ones spawned then
{
DestroyObject( purple_light{i} );
}
i++;
}
return 1;
}
