02.10.2018, 20:53
I have a problem with this 2 commands.
Basically, if there is no roadblock object near me, it should say "you are not near a roadblock" message. But instead it says the picked up message even if there are no roadblocks near me.
Why?
pawn Код:
CMD:rallrb(playerid, params[])
{
if(gTeam[playerid] == TEAM_COP || Player[playerid][AccountLevel] == 5)
{
if(Player[playerid][Jailed] == 1) return SCM(playerid, COLOR_LIGHTRED, "* You can't use this command while jailed.");
new range;
if(sscanf(params, "d",range)) return SCM(playerid, COLOR_LIGHTRED, "* [USAGE]: /rallrb [range in meters] - Removes all roadblock objects in the range chosen.");
if(range < 1 || range > 500) return SCM(playerid, COLOR_LIGHTRED, "* Invalid range. Min: 1 meter - Max: 500 meters");
new countrb=0;
for(new i = 0; i < sizeof(Roadblocks); i++)
{
if(IsPlayerInRangeOfPoint(playerid, range, Roadblocks[i][RoadblockX], Roadblocks[i][RoadblockY], Roadblocks[i][RoadblockZ]))
{
if(Roadblocks[i][RoadblockCreated] == 1)
{
Roadblocks[i][RoadblockCreated] = 0;
Roadblocks[i][RoadblockX] = 0.0;
Roadblocks[i][RoadblockY] = 0.0;
Roadblocks[i][RoadblockZ] = 0.0;
DestroyDynamicObject(Roadblocks[i][RoadblockObject]);
countrb++;
}
}
}
SendNearbyMessage(playerid, 30.0, COLOR_BBLUE, "* %s has picked up all currently spawned roadblocks.", ReturnName(playerid, 0));
new string[170];
format(string,sizeof(string),"* [DISPATCHER]: %s has picked up all currently spawned roadblocks in range of %d meters from %s.", ReturnName(playerid, 0), range, CheckSex(playerid));
SendMessageToCops(string);
if(countrb>0)
{
SCM(playerid, COLOR_LIGHTRED, "* You are not near a roadblock.");
}
}
return 1;
}
CMD:rrb(playerid, params[])
{
if(gTeam[playerid] == TEAM_COP || Player[playerid][AccountLevel] == 5)
{
if(Player[playerid][Jailed] == 1) return SCM(playerid, COLOR_LIGHTRED, "* You can't use this command while jailed.");
new countrb=0;
for(new i = 0; i < sizeof(Roadblocks); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, Roadblocks[i][RoadblockX], Roadblocks[i][RoadblockY], Roadblocks[i][RoadblockZ]))
{
if(Roadblocks[i][RoadblockCreated] == 1)
{
Roadblocks[i][RoadblockCreated] = 0;
Roadblocks[i][RoadblockX] = 0.0;
Roadblocks[i][RoadblockY] = 0.0;
Roadblocks[i][RoadblockZ] = 0.0;
DestroyDynamicObject(Roadblocks[i][RoadblockObject]);
countrb++;
}
}
}
SendNearbyMessage(playerid, 30.0, COLOR_BBLUE, "* %s has picked up a roadblock object.", ReturnName(playerid, 0));
new string[100];
format(string,sizeof(string),"* [DISPATCHER]: %s has picked up a roadblock.", ReturnName(playerid, 0));
SendMessageToCops(string);
if(countrb>0)
{
SCM(playerid, COLOR_LIGHTRED, "* You are not near a roadblock.");
}
}
return 1;
}
Why?