07.05.2013, 01:15
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
You need to do it like this
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
5) Provide an optional parameter for the modelid
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;
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;
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
pawn Code:
stock CreateRB(Float:x,Float:y,Float:z,Float:Angle,modelid = 973)