Roadblock - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Roadblock (
/showthread.php?tid=388201)
Roadblock -
thefatshizms - 27.10.2012
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;
}
Re: Roadblock -
Edward d - 27.10.2012
idk but if its admin only i would love it and if blocks are set on timers thay would goaway and you would not have to worry about deleting each one 5 min or 10 mins would let you hang out at your RB
Re: Roadblock -
ryansheilds - 27.10.2012
On the "CreateRB" stock don't you need to check if the roadblock is being used? either add a extra variable to the enum and set the bool to true of false and work from that or:
pawn Код:
stock CreateRB(Float:x, Float:y, Float:z, Float:a)
{
for(new i = 0; i < sizeof(RoadBlock); i++)
{
if(RoadBlock[i][Xpos] == 0 && RoadBlock[i][Ypos] == 0) {
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);
break;
}
}
return 1;
}
Should work.
Edit: Added a 'break;'
Re: Roadblock -
thefatshizms - 27.10.2012
Thanks ^^ but i found another way to get around it basicly the same concept as yours so +rep for your effort