27.10.2012, 21:47
HI guys, i made this short roadblock system but it has one bug, if i create 2 roadblocks and want to destroy both it will only destroy the most recent one.
pawn Код:
#include <a_samp>
#include <zcmd>
#include <streamer>
//defines
#define MAX_RB 50
//enums
enum rb
{
Float:Xpos,
Float:Ypos,
Float:Zpos,
object
}
new RoadBlock[MAX_RB][rb];
//stocks
stock CreateRB(Float:x, Float:y, Float:z, Float:a)
{
for(new i = 0; i < sizeof(RoadBlock); i++)
{
RoadBlock[i][Xpos] = x;
RoadBlock[i][Ypos] = y;
RoadBlock[i][Zpos] = z-0.7;
RoadBlock[i][object] = CreateDynamicObject(1459, x, y, z-0.9, 0, 0, a);
}
return 1;
}
//commands
CMD:createrb(playerid, params[])
{
new Float:X, Float:Y, Float:Z, Float:A;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, A);
CreateRB(X, Y, Z, A);
return 1;
}
CMD:destroyrb(playerid, params[])
{
for(new i = 0; i < sizeof(RoadBlock);i++)
{
if(IsPlayerInRangeOfPoint(playerid, 10, RoadBlock[i][Xpos], RoadBlock[i][Ypos], RoadBlock[i][Zpos]))
{
RoadBlock[i][Xpos] = 0.0;
RoadBlock[i][Ypos] = 0.0;
RoadBlock[i][Zpos] = 0.0;
DestroyDynamicObject(RoadBlock[i][object]);
}
else
{
SendClientMessage(playerid, -1, "SHit not near it");
}
}
return 1;
}