[FilterScript] RoadBlock system
#4

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)
Reply


Messages In This Thread
RoadBlock system - by [CG]Milito - 04.05.2013, 23:40
Re: RoadBlock system - by J4mmyHD - 05.05.2013, 17:32
Re: RoadBlock system - by Kontrol - 06.05.2013, 23:12
Re: RoadBlock system - by Pottus - 07.05.2013, 01:15
Re: RoadBlock system - by DJTunes - 07.05.2013, 01:34
Re: RoadBlock system - by SeanDenZYR - 26.06.2016, 05:08

Forum Jump:


Users browsing this thread: 1 Guest(s)