Author Topic: Shared name bricks  (Read 1847 times)

right, but like I just said, not everyone wants to keep everyone else out while they build
well couldn't they come up with a script where you can choose who falls under that same brick group?

well couldn't they come up with a script where you can choose who falls under that same brick group?
yeah

away from home so i can't check, but %client.brickgroup exists doesn't it?

Well, yes. That's the client brickgroup.

okay lets get things straight here.

it wouldnt be particularly difficult to make it support full trust between two people. the complexity happens when you have three people, where one does not have full trust with another.

as long as everyone you have full trust with has full trust with everyone else you have full trust with, it wont cause issues.

trog if you need such a script just hmu and i could write it super fast

it wouldnt be particularly difficult to make it support full trust between two people. the complexity happens when you have three people, where one does not have full trust with another.
as long as everyone you have full trust with has full trust with everyone else you have full trust with, it wont cause issues.
idk exactly how this stuff actually works in the game but conceptually this doesn't sound very complicated
your events that target named bricks would include the bricks with that name that belong to you or anyone you share full trust with
I don't really see any complications there, unless there's something about the game's implementation of this stuff that would cause trouble, which like I said I wouldn't know about

how named bricks are implemented:

each client is given a brickgroup labeled with their BLID on join. this brickgroup contains all their bricks
when they name a brick, its stored as a value/variable in the brickgroup. only clients whose brickgroup == the brickgroup of the brick they have wrench evented can access the named bricks target field and see the named bricks available.
although you CAN access the named bricks of others using script it would be particularly difficult to make these show up in your named brick list, since that's generated based on the named bricks in your brickgroup.

theres two ways to do this
1) make people who have full trust with each other share a mutual brickgroup. easiest to implement, doesn't involve wacky code and stuff, and would be most consistent. downside: the complexity when you have three people of which two don't share full trust
2) give access to the named bricks of people you have full trust with by manually adding them into the named brick list when they open a wrench event dialog, using some workaround. depending on the implementation it could have the same issue as 1) but it would probably be easier to fix. downside: hard to implement.

You know, since everyone is sharing a mutual brickgroup... why not just only check trust between the true owner of the brickgroup, and each member using it, instead of checking trust between all members?
If Person B doesn't want Person C using their bricks... well it's technically Person A's bricks anyway so too bad.

Personally, I think a mutual brickgroup system where players can create brickgroups and invite other players to build in it for collaboration builds would be the best way to handle it.
It's kinda hard to explain the way I imagine how it would work, but if I get some time I might write up a simple script for it.

Personally, I think a mutual brickgroup system where players can create brickgroups and invite other players to build in it for collaboration builds would be the best way to handle it.
It's kinda hard to explain the way I imagine how it would work, but if I get some time I might write up a simple script for it.

something like the gang system on base raiders, yeah.

Code: [Select]
if (!$Pref::Server::MaxOwnedBrickgroups) {
    $Pref::Server::MaxOwnedBrickgroups = 2;
    $Pref::Server::MaxOwnedBrickgroupsAdmin = 5;
}
if (!$OBG::Index) {
    $OBG::Index = 1;
}
function padZeros(%i) {
    while (strLen(%i) < 3) {
        %i = "0" @ %i;
    }
    return %i;
}
function serverCmdListCustomBrickgroups(%this) {
    for (%i = 0; %i < (%mb = mainBrickgroup).getCount(); %i++) {
        %group = %mb.getObject(%i);
        if (%group.isCustomBrickgroup) {
            messageClient(%this, '', "\c6[\c3" @ %i @ "\c6]: " @ %group.name @ " owned by " @ %group.ownedClient);
        }
    }
}
           
function serverCmdCreateBrickgroup(%this, %name) {
    %name = expandEscape(stripTrailingSpaces(StripMLControlChars(%name)));
    if (%name $= "") {
        return;
    }
    %ownedGroups = -1;
    for (%i = 0; %i < (%mb = mainBrickgroup).getCount(); %i++) {
        %group = %mb.getObject(%i);
        if (%group.ownedClient == %this.getBLID()) {
            %ownedGroups++;
        }
        if (%group.name $= %name) {
            messageClient(%this, '', "\c6There is already a brickgroup with the name of \"\c3" @ %name @ "\c6\"!");
            return;
        }
    }
    if (%ownedGroups > ((%this.isAdmin | %this.isSuperAdmin) ? $Pref::Server::MaxOwnedBrickgroupsAdmin:$Pref::Server::MaxOwnedBrickgroups)) {
        messageClient(%this, '', "\c6You already have/exceed the limit in owned brickgroups!");
        return;
    }
   
    %id = "889" @ padZeros($OBG::Index);
    $OBG::Index++;
    %group = new SimGroup(("BrickGroup_" @ %id)) {
        BL_ID = %id;
        client = %this;
        isPlublicDomain = 0;
        isCustomBrickgroup = true;
        abandonedTime = 0;
        ownedClient = %this.getBLID();
        name = %name;
    };
    %this.brickGroup = %group;
    %mb.add(%group);
    messageClient(%this, '', "\c6Brickgroup \"\c3" @ %name @ "\c6\" created.");
    echo(%this.getPlayerName() @ " created a new brickgroup called " @ %name @ ".");
    echo("------------\r\nBrickGroup_" @ %id @ "\r\n    client = " @ %this @ "\r\n    name = " @ %name @ "\r\n    ownedClient = " @ %this.getBLID() @ "\r\n------------");
}
function serverCmdJoinBrickgroup(%this, %id) {
    %mb = mainBrickgroup;
    if($Sim::Time-%this.pendingBrickgroupTime < 15) {
        messageClient(%this, '', "\c6You've just recently requested to join a brickgroup.");
        messageClient(%this, '', "\c6Please wait a little while before requesting again.");
        %this.pendingBrickgroupTime = $Sim::Time;
    }
    if (%id >= %mb.getCount() || !(%group = %mb.getObject(%id)).isCustomBrickgroup) {
        return;
    }
    if (%group == %this.brickGroup) {
        messageClient(%this, '', "\c6You're already a part of that brickgroup!");
        return;
    } else if (!isObject(%targetClient = findClientByBL_ID(%group.ownedClient))) {
        messageClient(%this, '', "\c6Was unable to find the client that owns the group.");
        return;
    }
    %this.pendingBrickgroup = %group;
    %this.pendingBrickgroupTime = $Sim::Time;
    messageClient(%targetClient, '', "\c3" @ %this.getPlayerName() @ "\c6 wishes to be a part of your brickgroup, " @ %group.name @ ".");
    messageClient(%targetClient, '', "\c6Type /addToBrickgroup " @ %this.getBLID() @ " to let them join.");
}
function serverCmdaddToBrickgroup(%this, %id) {
    if (!isObject(%targetClient = findClientbyBL_ID(%id))) {
        messageClient(%this, '', "\c6Was unable to find a client with the BL_ID of " @ %id);
        return;
    }
    if ($Sim::Time-%targetClient.pendingBrickgroupTime >= 30) {
        messageClient(%this, '', "\c6It doesn't appear that " @ %targetClient.getPlayerName() @ " has recently requested to join your brickgroup.");
        return;
    }
    %group = %targetClient.pendingBrickgroup;
    messageClient(%this, '', "\c6Added \c3" @ %targetClient.getPlayerName() @ "\c6 to your brickgroup, " @ %group.name @ ".");
    messageClient(%targetClient, '', "\c6You've been added to the \c3" @ %group.name @ "\c6 brickgroup.");
    %targetClient.brickGroup = %group;
}


Unsure how this will work when used, I can't test it out since I can't play online at the moment.
Would be helpful if someone can test it out and tell me how it works.


/createBrickgroup name  - Creates a brickgroup with the name "name".
/listCustomBrickgroups  - Lists all of the custom brickgroups in the server
The format is [<idx>]: <name> owned by <owned client id>
/joinBrickgroup idx - Requests to join the brickgroup


Edit: I've realized I forgot to make trust checks, working on that now.
Edit 2: Amazingly enough, it still works for me without any modifications to the trust functions. Weird.
Edit 3: Fixed some mispelled variables in serverCmdjoinBrickgroup
« Last Edit: March 08, 2016, 12:34:00 AM by Pah1023 »


Edit: I've realized I forgot to make trust checks, working on that now.
Edit 2: Amazingly enough, it still works for me without any modifications to the trust functions. Weird.
Edit 3: Fixed some mispelled variables in serverCmdjoinBrickgroup
why wouldn't it work without modification to the trust functions? if your brickgroup is the same as the one you're trying to edit, it won't have an issue...?

why wouldn't it work without modification to the trust functions? if your brickgroup is the same as the one you're trying to edit, it won't have an issue...?
I wasn't thinking at the time.

Why not invite someone to be able to place your bricks and to modify them?
All bricks placed by that player after the invite will then belong to you. And so will the named bricks.
Then all you need is for the other player to be able to select your bricknames in the eventing system instead of his own.

Basically treat the 2 players as if they are one.

After you are done, you can remove the invite so the player is able to place his own bricks again.