Hi,
Today i was creating new plugins to allow server owners to limit number of constructible high external walls but i got a litle problem.
My data file don't get refreshed, i mean it store corretly but when i try to remove key/value on enitydeath, it won't work if someone more experimented can take a look.
Datafile not updating with my plugin
Discussion in 'Rust Development' started by sami37, Jun 2, 2016.
-
Attached Files:
-
-
When you store a key does it store correctly? I will keep looking around in it.
-
mistake on line 79
-
i got Puts("listt.Contains fired"); at line 79 , i don't think it's the problem.
when it store i got something like that
it storing greatly, but i don't know what append when i try to removeCode:{ "76561197988704127": [ 19.5835667, 19.8276539 ] } -
You need to SaveData(); Once you do the remove
-
Sorry wrong line was tried last night when I posted that
-
Changed some code and added some SaveData() make it working
Maybe i am newly confronted to a problem with my plugin, if player use /remove to remove a walls, how i can handle remove item?Last edited by a moderator: Jun 3, 2016 -
I think (Remover Tool) destroys the entity, you should be able to use the OnEntityDeath Hook and find the owner of the entity.
-
I already use OnEntityDeath but RemoverTool use KillMessage() so OnEntityKill
I am trying to use OnEntityKill(BaseNetworkable networkable) -
That might work then, getting the owner would be a tad bit different.
[DOUBLEPOST=1464970690][/DOUBLEPOST]Wait thats a hook? I looked through the docs and didn't see one named that. -
Get it working
The docs is not uptodate, you should look at the githubCode:void OnEntityKill(BaseNetworkable networkable) { var entity = networkable as BaseEntity; if (entity == null) return; var buildingblock = entity.GetComponent<SimpleBuildingBlock>(); if (buildingblock == null) return; var name = buildingblock.name; if (!name.Contains("wall.external.high.stone")) return; float posy = buildingblock.transform.position.y; string userid = entity.OwnerID.ToString(); if (ReverseData[userid] == null) { ReverseData[userid] = new List<object>(); } var listt = ReverseData[userid] as List<object>; if (listt.Contains(buildingblock.transform.position.y)) { listt.Remove(buildingblock.transform.position.y); ReverseData[userid] = listt; SaveData(); } }
