i have this little plugin and for some reason it is not compiling
i am getting an error on line 39,78 that is the end of the switch...Code:internal class SimpleKit : RustPlugin { [ChatCommand("kit")] void cmdChatKit(BasePlayer player, string command, string[] args) { if (args.Length == 1) { switch (args[0]) { case "basico": //check cooldown player.inventory.GiveItem(ItemManager.CreateByItemID("mushroom", 10), player.inventory.containerMain); player.inventory.GiveItem(ItemManager.CreateByItemID("torch", 1), player.inventory.containerMain); player.inventory.GiveItem(ItemManager.CreateByItemID("stone.pickaxe", 1), player.inventory.containerMain); player.inventory.GiveItem(ItemManager.CreateByItemID("stonehatchet", 1), player.inventory.containerMain); SendReply(player, "Recibiste el kit Basico"); break; case "escopeta": //check cooldown player.inventory.GiveItem(ItemManager.CreateByItemID("shotgun.waterpipe", 1), player.inventory.containerMain); SendReply(player, "Recibiste el kit Escopeta"); break; case "blueprints": //check cooldown player.inventory.GiveItem(ItemManager.CreateByItemID("shotgun.waterpipe BP", 1), player.inventory.containerMain); SendReply(player, "recibiste el kit blueprints"); break; default: SendReply(player, "Kits: basico, escopeta, blueprints"); break; } } else SendReply(player, "Kits: basico, escopeta, blueprints"); } }
i dont understand what the error is, it says it cant convert from string to int, but i am never using any int in here, this is my first plugin for rust and i want to learn how this works
[DOUBLEPOST=1519908006][/DOUBLEPOST]i know the problem is somewhere on the switch cause if i comment it, it runs just fine
Solved Argument #1 cannot convert string expression to type int
Discussion in 'Rust Development' started by Bruno Puccio, Mar 1, 2018.
-
You should take a look at this Referencing game/Oxide DLLs in Visual Studio 2015/2017 and set that up.
It will help you a lot and show you errors etc. (https://i.imgur.com/cdYm9Zc.png)
So you are using ItemManager.CreateByItemID https://i.imgur.com/a4FiWOH.png , it takes and integer for the ItemID but you are using a string (the short name for a item in that case) So you wanna get the ItemID and replace it with the string. -
-
It was a little different now, there was no reference folder so i couldn't delete anything but i added all that i had to, the plugin works just fine but in visual studio i see all these errors -
Wulf Community Admin
-