Well I've been trying for hours trying to find a way to get the player who placed certain BuildingBlock or Storage container or anything that can be deployed. I got no luck at all or I'm looking in the wrong location. Is this possible? If so, how ? Thanks.
[DOUBLEPOST=1437410845,1437261486][/DOUBLEPOST]Really no one knows how? I really need this.
Getting block owner?
Discussion in 'Rust Development' started by WolfsDarker, Jul 20, 2015.
-
Going from memory, don't have access to my code right now, but there's a .OwnerID or .Owner or something like that attached to all entities (including blocks). I don't know if this persists though, I haven't toyed with it.. Might be always null for all I know.
-
Calytic Community Admin Community Mod
An entity only has "ownership" within the engine when the either of these two conditions are met.
This shows that unless the block parentEntity is set to the player, the player technically does not "own" the block. You cannot manually set the parentEntity property of a block, it does not persist because BuildingBlock is not a BaseEntityChild (nor should it be)Code:(int) ent.net.ID == (int) player.net.ID || (int) ent.parentEntity.uid == (int) player.net.ID;
I am not aware of a built-in way to track ownership. I have tried persisting ownership through MonoBehavior and it is incredibly slow and basically unfeasible. -
Well thanks for both replies, I'll try another way to do what i had in mind
-
Calytic Community Admin Community Mod
What's that? -
Just a way to track where a player placed any block or chest ( I had an issue with mods building underground to hide stolen items ).
-
Calytic Community Admin Community Mod
Oh okay, that sucks.
-
Calytic Community Admin Community Mod
I just released EntityOwner last Wednesday to track ownership of buildingblocks and entities like boxes..
http://oxidemod.org/plugins/entityowner.1255/ -
Nice work there, read the other thread on it, it's very interesting. I assume this will not work for existing blocks and only document new blocks, right?
-
Calytic Community Admin Community Mod
Yes. You can set ownership manually using the /own command but generally it is recommended to install this after a wipe.
I did not write a migration from BuildingOwners but they should not conflict so you can run both together. -
Just curious on another question, do you really keep ownership of all blocks or do you bunch them up in a "base" entity? If you do bunch them up, how do you keep track of say a 100 foundation wall that gets blown up right in it's middle, forming 2 different groups of foundation?
What about bases that are built by 2 different guys at the same time? Do you keep ownership of all individual blocks? -
Calytic Community Admin Community Mod
All blocks are tracked individually. Ownership is stored on a per-player basis just like BuildingOwners.
-
Well I'm not sure about you guys, but thats a bit too much for a plugin, it has so many ways to "break" plus saving a 2000 buildings whenever someone place somethins can lag the server. I've been trying to avoid that, i want a way to do it by calling a instance BasePlayer or whatever in the BuildingBlock class. Not sure if you guys ever had classes over this but thats how a memory leak starts, saving and reading that huge amount of data just for a feature.
-
The way he made it shouldn't cause too much trouble for that, but it is a potential monster, esp. on high gather servers with high pop. If everyone has huge bases and start working at the same time, the disk is probably getting some significant access. I assume most servers would be able to handle this, but it sure ain't a "free" or "lightweight" feature. I don't know if it's still an issue with Experimental but I remember there was a logging mod back in Legacy that caused issues because it was too disk-intensive.. When it was active, sometimes when you looted stuff out of boxes they would replicate and you can guess the rest.
The plugin could instead save "groups" like I was talking in my other reply, but this would in turn increase the memory and CPU access significantly, not sure it would be better in the end.
Unfortunately though Wolf, there's no way to tie an element to a owner right now other than this kind of trick. The best would be for the owner field to persist through restart but that would have to be done by Facepunch. It would add almost nothing to the current process and it would just be accessible any time. -
Calytic Community Admin Community Mod
I actually agree with this, my solution is unreliable compared to a non-existent baked-in solution. I have done what I can to mitigate the issues with the JsonSerializer and others. This mod will store ownership as reliably and quickly as possible.
It only saves owner profiles that are "dirty" or have pending changes. It doesn't save every profile every time. The only real cost is loading all the profiles in initially at server start. Even so, it's not really that huge with my optimizations and given that it only saves deployables and buildings by default (not every single Entity in the game, as others have implied) -
Just to be clear when I said "every entity" I meant every building block of a base... I can think of a couple bases or players that would have a huge list. I don't know how badly this would affect performance, but I've had some of my own plugin tests choke just on iterating lists so I can only assume that if you add disk access to the mix, it can be a bit taxing. Not saying it's problem, but a potential issue. I'd be curious to see how big a share of cycle time this mod can take maximum on a crowded server with X10+ gather for instance where the bigger players are all building at the same time, etc.
-
Calytic Community Admin Community Mod
I noticed the performance of EntityOwner skyrocketed when I started checking type parameters on the SphereCast and only iterating through individual types.
So instead of FindEntities(Vector3)
I have FindEntities<BuildingBlock>(Vector3).
Technically it still loops through all of the Entities, but all the processing handled by the plugin is limited to only Entities that are also BuildingBlocks (in this case). The performance difference was like night and day.
[DOUBLEPOST=1438115365][/DOUBLEPOST]When I first wrote this I was storing considerably more information aside from entity position. I stored the type and created an EntityProfile for every Entity in the OwnerProfile. Then I wrote a MonoBehavior which hooked into every Entity and every BasePlayer to avoid having to save the data myself. This approach failed miserably given the stunning amount of overhead associated with it.
As a result I scrapped it and went with the conventional approach similar to BuildingOwners (ie. only storing the position).
I still have a number of things on the TODO list for this mod, such as ownership expiration timers, decay hooks, a mass deauthorization command, and another /prod to aggregate cupboard authorization for an entire building.Last edited: Jul 28, 2015 -
well if you do buildingBock.ToString() and debug you get a group of numbers attached to the foundation those numbers seems to be static you could probably use those you would have to extract them from the string as the string as a hole is unusable some terror with parsing so just extract that if its usefull and that should do
