Suggestions for some improvement
1) There is no need for rCreated in your enum initialize rObject entries to INVALID_OBJECT_ID
2) This code is written incorrectly it will always do one iteration
pawn Code:
for(new i = 0; i < sizeof(RoadBlockInfo); i++)
{
if(IsPlayerInRangeOfPoint(playerid,5.0,RoadBlockInfo[i][rX],RoadBlockInfo[i][rY],RoadBlockInfo[i][rZ]))
{
SendClientMessage(playerid,-1,"You have succesfully removed the closest roadblock");
DeleteClosestRB(playerid);
return 1;
}
else
{
SendClientMessage(playerid,-1,"You are not near to any roadblock!");
return 1;
}
}
return 1;
You need to do it like this
pawn Code:
for(new i = 0; i < sizeof(RoadBlockInfo); i++)
{
if(IsPlayerInRangeOfPoint(playerid,5.0,RoadBlockInfo[i][rX],RoadBlockInfo[i][rY],RoadBlockInfo[i][rZ]))
{
SendClientMessage(playerid,-1,"You have succesfully removed the closest roadblock");
DeleteClosestRB(playerid);
return 1;
}
}
SendClientMessage(playerid,-1,"You are not near to any roadblock!");
return 1;
3) Return the index of the road block when being created instead of returning 1 that way it can be referenced if needed return INVALID_ROAD_BLOCK if failed.... #define INVALID_ROAD_BLOCK (0xFFFF)
4) Provide an option to use incognito streamer dynamic objects instead of create object
pawn Code:
#define USE_STREAMER
#if defined USE_STREAMER
RoadBlockInfo[i][rObject] = CreateDynamicObject(973, x, y, z-0.9, 0, 0, Angle-90);
#else
RoadBlockInfo[i][rObject] = CreateObject(973, x, y, z-0.9, 0, 0, Angle-90);
#endif
5) Provide an optional parameter for the modelid
pawn Code:
stock CreateRB(Float:x,Float:y,Float:z,Float:Angle,modelid = 973)