Solved Using XP particle punch effect?
Discussion in 'Rust Development' started by Austinv900, Jul 12, 2016.
-
First you need to find the correct prefab string, you can list all the prefab strings with the code below and see output in rusty/whatever, but it may take 15-20mins.
Code://Writen by Wulf foreach (var str in GameManifest.Get().pooledStrings) { Puts(str.str); }
I tried to narrow it down to effects with the following but I didn't see anything obvious related to Xp
Once you find the right string you can do the followingCode:foreach (var str in GameManifest.Get().pooledStrings) { if (!str.str.StartsWith("assets/bundled/prefabs/fx/")) continue; Puts(str.str); }
Code:using UnityEngine; Effect.server.Run("assets/bundled/prefabs/fx/player/onfire.prefab", PlayerPos); -
I don't believe its a prefab mainly. because I found the the line of code in the server assembly that does it . We are just stumped on how to add it. or if its possible
-
I can tell you the the server uses the unityengine to generate the particles. And uses key frames to move and animate them
-
I'm pretty certain that it's purely client sided, I don't see a point in it being server sided.
-
@Wulf said it might be possible
There wouldn't be a way for it to be pushed to the client? -
Wulf Community Admin
If it's a regular effect, it's possible, but if it's a client-side only thing that happens on the interface, maybe not. -
Hmm I see.
-
I'd imagine it probably is client side given other players can't see when you get Xp, so not a lot reason for it to be server really. But honestly it doesn't matter and i'll tell you why in a second. When you do player.xp.Add(Rust.Xp.Definitions.Cheat, amount); it causes the effect so can use that to narrow down the exact code that causes the effect, but it sounds like you've done this. So ultimately all you would need to do is probably change the onscreen coordinates of the effect and if it is client side you probably can't but either way you can just do the same effect for any players within x radius of the player you're doing it for.
Something like this would do what I mentioned, untested
Code:using UnityEngine; using Rust.Xp;void PlayersNearPlayer(BasePlayer player, float radius) { var Active = BasePlayer.activePlayerList as List<BasePlayer>; foreach( BasePlayer aplayer in Active) { if (aplayer.userID==player.userID) continue; float distance = Vector3.Distance(player.transform.position,aplayer.transform.position); if (distance <= radius) { // do Xp effect by giving the player 1 Xp aplayer.xp.Add(Rust.Xp.Definitions.Cheat, 1); Puts(string.Format("Did effect for player {0}",aplayer.displayName)); //now do rest of your code to the player } } }Last edited by a moderator: Jul 14, 2016 -
Just use this:
it saves the Prefabs in a file (oxide/logs/AssetsOutput.txt) and it finishes instantly.Code:foreach (var str in GameManifest.Get().pooledStrings) { var prefab = str.str; ConVar.Server.Log("oxide/logs/AssetsOutput.txt", prefab); } Puts("Created AssetsOutput.txt with Assets"); -
Wulf Community Admin
That's essentially the same as what was already posted, just with a split log. -
Maybe you can add 1 XP for example and then remove it instantly. Then you'll get the effect but it wouldn't affect player's XP.
-
The experience and levelup notices are running client side but can actually be triggered by running a console command on the client no need to actually give the user any experience and take it away after.
Code:notice.levelup <level_number> notice.xp
-
That's not the "particle punch effect" but something.
-
Sorry didn't read everything, you can trigger the effect by sending an RPC message to the client indicating that the spend experience has changed but you need to send another one on the next update cycle to reset the xp value on the user's screen to prevent it from bugging out:
Code:namespace Oxide.Plugins { [Info("Tests", "Mughisi", 1.0)] class Tests : RustPlugin { [ChatCommand("t")] private void Test(BasePlayer p) { timer.Repeat(1, 5, () => Boom(p)); } private void Boom(BasePlayer p) { p.ClientRPCPlayer(null, p, "UpdateXPValues", p.xp.CurrentLevel, p.xp.UnspentXp + 1); timer.Once(0.1f, () => p.ClientRPCPlayer(null, p, "UpdateXPValues", p.xp.CurrentLevel, p.xp.UnspentXp - 1)); } } } -
couldn't you just use NextTick() instead of a 0.1 timer?
-
Not the point, you can use anything you want honestly, the RPC message is what it is about and making sure to send a second one to undo the change to trigger the particle explosion effect. The timer.Once is there because I had it there from something else. You can even go crazy with it and setup a queue and undo it in OnTick if you want to
The important thing is that the change needs to be
undone.
