That would be a float, not an int.
New Xp Functions
Discussion in 'Rust Development' started by Caffeine, Jul 8, 2016.
-
Wulf Community Admin
-
Oh i thought he wanted a float haha.
-
Mhh, because I'm Trying this code but I have an error
Code:(21:02:47) | [Oxide] 21:03 [Error] SetLevel plugin failed to compile! (21:02:47) | [Oxide] 21:03 [Error] SetLevel.cs(31,13): error CS9010: Primary constructor body is not allowed
Thank to k1lly0u for her codeAttached Files:
-
-
if (user = null) needs to be ==
-
I did not test it but try this:
Code:using System.Collections.Generic; using Oxide.Core; using Oxide.Core.Configuration; using Rust.Xp; namespace Oxide.Plugins { [Info("SetLevel", "MrErne", "0.1", ResourceId = 0)] class SetLevel : RustPlugin { private void ResetPlayerLevel(BasePlayer player, float amount) { if (player == null) return; player.xp.Reset(); player.xp.Add(Definitions.Cheat, amount); } [ChatCommand("level")] private void level(BasePlayer player, string command, string[] args) { if (!player.IsAdmin()) return; if (args == null || args.Length == 0) { SendMSG(player, "/level <playername> <amount>"); } if (args.Length > 1) { var user = FindPlayer(player, args[1]); if (user == null) { SendMSG(player, "User not found"); return; } int amount = args[2]; if (amount > 300 || amount < 0) { SendMSG(player, "You cannot set level more than 300 and less than 0"); return; } else { ResetPlayerLevel(target, amount); SendMSG(player, "Level are set to"); SendMSG(user, "An admin fix your level to"); return; } } } } }
-
-
Ok, let me 2 min to try the code
(Thk for the help)
[DOUBLEPOST=1468007284][/DOUBLEPOST]I have this output:
Code:(21:47:13) | [Oxide] 21:47 [Error] SetLevel plugin failed to compile! (21:47:13) | [Oxide] 21:47 [Error] SetLevel.cs(48,21): error CS0103: The name `SendMSG' does not exist in the current context
My bad SendMSG is not the fonction to send a Message into the gamme sry.
What's is the name of the oxide fonction ?Last edited by a moderator: Jul 8, 2016 -
-
Wulf Community Admin
-
Ok, now I have an other problem
Code:(22:16:15) | [Oxide] 22:16 [Error] SetLevel.cs(46,44): error CS0103: The name `amount' does not exist in the current context
But doesn't work
Code:(22:16:57) | [Oxide] 22:17 [Error] SetLevel.cs(37,21): error CS0019: Operator `>' cannot be applied to operands of type `string' and `int'
Attached Files:
-
-
-
Yeah but is not the probelm actually
-
MrErne you need to convert to an int I believe
Code:int amount; if (Int32.TryParse(args[2], out amount)) { if (amount > 300 || amount < 0) { etc.... } } else { //wasn't a valid int }
-
(23:11:23) | [Oxide] 23:11 [Error] SetLevel.cs(38,9): error CS0103: The name `Int32' does not exist in the current context -
Try adding
using System;
to the top, if that doesn't fix it i'll test out the code and see if I can get it working. -
Code:
(23:32:42) | [Oxide] 23:33 [Error] SetLevel plugin failed to compile! (23:32:42) | [Oxide] 23:33 [Error] SetLevel.cs(38,17): error CS0841: A local variable `amount' cannot be used before it is declared
Code:amount = args[2]; int amount; if (Int32.TryParse(args[2], out amount)) { ResetPlayerLevel(user, amount); PrintToChat(player, "Level are set to"); PrintToChat(user, "An admin fix your level to"); return; }else{ PrintToChat(player, "You cannot set level more than 300 and less than 0"); }
-
-
Code:
if (Int32.TryParse(args[2], out amount)) { ResetPlayerLevel(user, amount); PrintToChat(player, "Level are set to"); PrintToChat(user, "An admin fix your level to"); return; }else{ PrintToChat(player, "You cannot set level more than 300 and less than 0"); }
(00:18:38) | [Oxide] 00:18 [Error] SetLevel.cs(42,29): error CS0103: The name `amount' does not exist in the current context
The same output, I just ween i type /level [pseudo] [amount] set the level [amount] -
-
New error about Xp and the update
Code:(08:31:08) | [Oxide] 08:31 [Error] MagicCraft.cs(167,55): error CS0104: `Convert' is an ambiguous reference between `System.Convert' and `Rust.Xp.Convert'
Code:if (currentlevel<=80) {crafter.xp.Add(Definitions.Cheat, 15);}
Last edited by a moderator: Jul 9, 2016