Author Topic: Event to clear all bricks for a specific BL_ID (admin only)  (Read 1309 times)

onActivate -> Server -> ClearBricks -> (player BLID)

anyone up to it? I need it for my Star Trek RP. Automatically loading and clearing saves via events to simulate changing environments around the ship.
of course it would need to be admin-only so players can't just event a brick and start deleting people's stuff.

I would load saves under the Public BL_ID, then clear them as such.
« Last Edit: February 19, 2017, 11:15:51 PM by Planr »

here's something simple that will clear the bricks and check if the brick owner is an admin
issue is it plays the clear bricks sound + prints to the chat
Code: [Select]
function fxDTSbrick::clearPublicBricks(%brick)
{
serverCmdClearBrickGroup(%brick.client, 888888);
}

registerOutputEvent("fxDTSbrick","clearPublicBricks");

will make an updated version that doesn't make noise/printing, and maybe add a way to detect if it's finished clearing so the load can be started


Code: [Select]
function fxDTSbrick::clearPublicBricks(%brick)
{
if(!%brick.client.isAdmin)
return;
%g = mainBrickGroup.getCount();
for(%i = 0; %i < %g; %i++)
if((%bg = mainBrickGroup.getObject(%i)).bl_id == 888888)
{
%bg.chainDeleteAll();
return;
}
}

registerOutputEvent("fxDTSbrick","clearPublicBricks");

should be able to add that to the end of Greek's server.cs file

the brickgroup will probably be the first, but just in case it loops through them

and thanks greek, didn't know about brickgroup.chainDeleteAll(), I was going to go through and delete everything at first lol

edit:
or to follow Greek's format of using the server target:
Code: [Select]
function ServerEventTargetSO::clearPublicBricks(%brick)
{
%g = mainBrickGroup.getCount();
for(%i = 0; %i < %g; %i++)
if((%bg = mainBrickGroup.getObject(%i)).bl_id == 888888)
{
%bg.chainDeleteAll();
return;
}
}
registerOutputEvent(ServerEventTargetSO, "clearPublicBricks", "", false, true);
which should also make it host only, instead of admin only
« Last Edit: February 21, 2017, 12:33:46 AM by phflack »