Roadblock problem - 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 problem (
/showthread.php?tid=466793)
Roadblock problem -
AnonScripter - 29.09.2013
why /removerb only removes the last roadblock that player created and it doesn't remove other roadblocks?
pawn Код:
CMD:roadblock(playerid, params[])
{
new Float:x, Float:y, Float:z,Float:angle;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, angle);
CreateRoadBlock[playerid] = 1;
SendClientMessage(playerid, COLOR_GREEN, "Roadblock Created, remove it using /removerb");
PlayerRB[playerid] = CreateObject(978, x, y, z, 0.0, 0.0, angle);
return 1;
}
CMD:removerb(playerid, params[])
{
CreateRoadBlock[playerid] = 0;
SendClientMessage(playerid, COLOR_GREEN, "Roadblock Removed");
DestroyObject(PlayerRB[playerid]);
return 1;
}
Re: Roadblock problem - Patrick - 29.09.2013
You need a loop to destroy all the object.
Re: Roadblock problem -
EiresJason - 29.09.2013
Like pds2012 said, you need to loop through the road blocks and delete them.
EDIT: I just tested it and it works perfectly.
Try this.
pawn Код:
#define MAX_RBS 5
//you can change '5' to whatever you want.
new PlayerRB[MAX_PLAYERS][MAX_RBS];
new CreateRoadBlock[MAX_PLAYERS];
CMD:roadblock(playerid, params[])
{ //add in a check here to see if the max number of roadblocks has been reached already if you want.
new Float:x, Float:y, Float:z,Float:angle;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, angle);
SendClientMessage(playerid, COLOR_GREEN, "Roadblock Created, remove it using /removerb");
PlayerRB[playerid][CreateRoadBlock[playerid]] = CreateObject(978, x, y, z, 0.0, 0.0, angle);
CreateRoadBlock[playerid]++;
return 1;
}
CMD:removerb(playerid, params[])
{
for(new i=0;i<MAX_RBS;i++)
{
DestroyObject(PlayerRB[playerid][i]);
}
CreateRoadBlock[playerid] = 0;
SendClientMessage(playerid, COLOR_GREEN, "All of the roadblocks have been removed");
return 1;
}
Re: Roadblock problem -
AnonScripter - 29.09.2013
thanks all +rep
Re: Roadblock problem -
EiresJason - 29.09.2013
Np