Roadblock problem
#1

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;
}
Reply
#2

You need a loop to destroy all the object.
Reply
#3

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;
}
Reply
#4

thanks all +rep
Reply
#5

Np
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)