remove remove building
#1

is there anyway to bring back all the removed buildings for players without restarting the server?
Like you use 2 RemoveBuilding lines for a map and then want to show the removed stuff to players again during the second map change, is it possible without restarting the server?
Reply
#2

It's not a server issue this is a per-player type function so the only way is make the player disconnect or replace any removed buildings with ideally dynamic objects.
Reply
#3

I wrote a quick include after I posted to help handle doing this I think I got it all correct honestly I didn't even test it but it should work

All the correct rotations are located in this include https://sampforum.blast.hk/showthread.php?tid=415397
You could also use Texture Studio to automatically swap buildings then export your map.

pawn Код:
// AddRemoveBuilding(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, groupid=-1, bool:hide=true)
// ShowRemoveBuilding(index)
// ShowAllRemoveBuilding()
// ShowRemoveBuildingGroup(groupid)
// HideRemoveBulding(index)
// HideAllRemoveBuilding()
// HideRemoveBuldingGroup(groupid)

#include <YSI\y_iterate>
#include <YSI\y_hooks>
#include <streamer>

#define         MAX_REMOVED_BUILDINGS           1000

static Iterator:RemovedBuildings<MAX_REMOVED_BUILDINGS>;

enum RBINFO
{
    RB_ObjectID,
    RB_ModelID,
    RB_GroupID,
    bool:RB_Shown,
    Float:RB_X,
    Float:RB_Y,
    Float:RB_Z,
    Float:RB_RX,
    Float:RB_RY,
    Float:RB_RZ,
}

static RBData[MAX_REMOVED_BUILDINGS][RBINFO];

// Remove all buildings when a player connects
hook OnPlayerConnect(playerid)
{
    foreach(new i : RemovedBuildings)
    {
        RemoveBuildingForPlayer(playerid,  RBData[i][RB_ModelID],  RBData[i][RB_X], RBData[i][RB_Y], RBData[i][RB_Z], 0.25);
    }
    return 1;
}

// Add a new remove building
stock AddRemoveBuilding(modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, groupid=-1, bool:hide=true)
{
    new index = Iter_Free(RemovedBuildings);
    if(index > -1)
    {
        Iter_Add(RemovedBuildings, index);

        RBData[index][RB_ModelID] = modelid;
        RBData[index][RB_X] = x;
        RBData[index][RB_Y] = y;
        RBData[index][RB_Z] = z;
        RBData[index][RB_RX] = rx;
        RBData[index][RB_RY] = ry;
        RBData[index][RB_RZ] = rz;
        RBData[index][RB_Shown] = hide;
        RBData[index][RB_GroupID] = groupid;
       
        foreach(new i : Player)
        {
            RemoveBuildingForPlayer(i, modelid, x, y, z, 0.25);
        }
       
        if(!hide) RBData[index][RB_ObjectID] = CreateDynamicObject(modelid, x, y, z, rx, ry, rz, -1, -1, -1, 300.0, 300.0);
        return index;
    }
    else

    printf("Error::AddRemoveBuilding::Tried to remove too many buildings");
    return 0;
}

// Show a specific building
stock ShowRemoveBuilding(index)
{
    if(Iter_Contains(RemovedBuildings, index))
    {
        if(RBData[index][RB_Shown] == false)
        {
            RBData[index][RB_ObjectID] = CreateDynamicObject(RBData[index][RB_ModelID], RBData[index][RB_X], RBData[index][RB_Y], RBData[index][RB_Z], RBData[index][RB_RX], RBData[index][RB_RY], RBData[index][RB_RZ], -1, -1, -1, 300.0, 300.0);
            RBData[index][RB_Shown] = true;
            return 1;
        }
        printf("Error::ShowRemoveBuilding::Building is already shown::Index:%i", index);
        return 0;
    }
    printf("Error::ShowRemoveBuilding::Index is invalid::Index:%i", index);
    return 0;
}

// Show all removed buildings
stock ShowAllRemoveBuilding()
{
    foreach(new i : RemovedBuildings)
    {
        if(RBData[i][RB_Shown] == false)
        {
            RBData[i][RB_ObjectID] = CreateDynamicObject(RBData[i][RB_ModelID], RBData[i][RB_X], RBData[i][RB_Y], RBData[i][RB_Z], RBData[i][RB_RX], RBData[i][RB_RY], RBData[i][RB_RZ], -1, -1, -1, 300.0, 300.0);
            RBData[i][RB_Shown] = true;
        }
    }
    return 1;
}

// Show only a group of remove buildings
stock ShowRemoveBuildingGroup(groupid)
{
    foreach(new i : RemovedBuildings)
    {
        if(RBData[i][RB_Shown] == false && RBData[i][RB_GroupID] == groupid)
        {
            RBData[i][RB_ObjectID] = CreateDynamicObject(RBData[i][RB_ModelID], RBData[i][RB_X], RBData[i][RB_Y], RBData[i][RB_Z], RBData[i][RB_RX], RBData[i][RB_RY], RBData[i][RB_RZ], -1, -1, -1, 300.0, 300.0);
            RBData[i][RB_Shown] = true;
        }
    }
    return 1;
}

// Hide a specific building
stock HideRemoveBulding(index)
{
    if(Iter_Contains(RemovedBuildings, index))
    {
        if(RBData[index][RB_Shown] == true)
        {
            DestroyDynamicObject(RBData[index][RB_ObjectID]);
            RBData[index][RB_Shown] = false;
            return 1;
        }
        printf("Error::HideRemoveBulding::Building is already hidden::Index:%i", index);
        return 0;
    }
    printf("Error::HideRemoveBulding::Index is invalid::Index:%i", index);
    return 0;
}

// Hide all removed buildings
stock HideAllRemoveBuilding()
{
    foreach(new i : RemovedBuildings)
    {
        if(RBData[i][RB_Shown] == true BData[i][RB_GroupID] == groupid)
        {
            DestroyDynamicObject(RBData[i][RB_ObjectID]);
            RBData[i][RB_Shown] = false;
        }
    }
    return 1;
}

// Hide a group of removed buildings
stock HideRemoveBuldingGroup(groupid)
{
    foreach(new i : RemovedBuildings)
    {
        if(RBData[i][RB_Shown] == true && )
        {
            DestroyDynamicObject(RBData[i][RB_ObjectID]);
            RBData[i][RB_Shown] = false;
        }
    }
    return 1;
}
Reply
#4

But...let's say i got a gamemode with 6 changing maps with 100 RemoveBuildings each. If i replace the RemoveBuildings with createdynamicobjects by the time i reach my 6th map,I'd have 500+ remove buildings which actually exceeds the samp remove buildings limit right? Is there a way to fix such an issue?
Reply
#5

You should be ok to up about 1000 remove buildings.
You will also need to use the group features quite a bit.

Unfortunately this is really the only way your limited with this function.
Reply
#6

Thanks for the help, will make use of it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)