Remove all roadblocks?
#1

Hi everyone, a few weeks ago i made a topic about how to place simple roadblocks for an rp server, and i got my answer, now theres just 1 thing i need to know, how to delete all created roadblocks? Like for example, if someone is placing a roadblock, and then he leaves the server, then it would be good to have a command that would remove all roadblocks created, could someone help me with this? if you need it, here is the roadblock script

Код:
if (strcmp(cmd,"/roadblock",true) == 0)
    {
        if(!Blocked[playerid])
        {
            new Float:X,Float:Y,Float:Z,Float:A;
            GetPlayerPos(playerid, X, Y, Z);
            GetPlayerFacingAngle(playerid,A);
            roadblock[playerid] = CreateObject(978, X, Y, Z, 0.0, 0.0, A);
            Blocked[playerid] = true;
            return 1;
        }
        else return SendClientMessage(playerid, -1, "You already created a roadblock!");
    }
    if (strcmp(cmd,"/deleteblock",true) == 0)
    {
        if(Blocked[playerid])
        {
            DestroyObject(roadblock[playerid]);
            Blocked[playerid] = false;
            return 1;
        }
        else return SendClientMessage(playerid, -1, "You didn't create a roadblock yet!");
    }
under /deleteblock i would like to place /deleteallblocks, which will delete all the roadblocks created on the server, no matter which player placed it, i would really appreciate some help here, as im new to scripting
Reply
#2

Just do a player loop.
pawn Код:
// if you're using foreach include(WHICH I HIGHLY RECOMMAND)
if (strcmp(cmd,"/deleteallblocks",true) == 0)
{
foreach(Player, i)
{
   if(Blocked[i])
   {
        Blocked[i]=false;
        DestroyObject(roadblock[i]);
   }
}
}
+ You should use the ZCMD command processor.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)