Hello in my plugin I would like the player on which I work sends a chat command used in another plugin.
Is it possible? And if is yes how i can do it please??
I try this :
but it is not working he send just text not a command.Code:SendReply(player, string.Format("/transfert 76561198007607899 2500"));
Can you help me please??
Solved Sending chat command as player?
Discussion in 'Rust Development' started by L'Indien, Aug 13, 2015.
-
It's not possible with chat commands. Only with console commands.
-
I never used other plugins within one of my plugins but would it not be possible to simply call the function from the other plugin straight and pass it whatever BasePlayer? This would bypass the / command but have the same result.. I do not know if you can straight out call another function like that in another plugin though or if they need to be exposed as API functions or whatever.
-
Wulf Community Admin
-
The plugin is in Lua, i don't understand lua. can you give me the hook for c# please??
-
Wulf Community Admin
-
Code:
[ConsoleCommand("plugin.save")] private void SaveCommand(ConsoleSystem.Arg arg) { PrintToConsole(arg.Player(), "Saving the world data"); SaveRestore.Save(); }
it this command??
can you explain me the argument please?
Thanks for your help -
Wulf Community Admin
To call that though, you'd use the PluginReference and CallHook like shown in my previously mentioned examples, though there wouldn't be much point, as you could just use SaveRestore.Save() directly in your own plugin. -
Hum sorry but i don't understand, i have decompil the file but i dont understand.
In the file i have the method :
Code:public static void SendClientCommand(List<Connection> cn, string strCommand, params object[] args) { if (!Net.sv.IsConnected()) { return; } Net.sv.write.Start(); Net.sv.write.PacketID(Message.Type.ConsoleCommand); Net.sv.write.String(ConsoleSystem.BuildCommand(strCommand, args)); Net.sv.write.Send(new SendInfo(cn)); }
I explain again my problem. I use the plugin economics LUA and the plugin Human NPC c#.
In my plugin (c#) i would like to call command on this two plugins. For the NPC i use a Hook but for the plugin economics he have no hook so i would like send a command console tu use that plugin.
Sorry for the translate and if i'am a beginner.... -
Wulf Community Admin
-
Code:
void OnUseNPC(BasePlayer npc, BasePlayer player) { var items = ItemManager.GetItemDefinitions(); var newMenu = new Dictionary<string, int>(); if(npc.displayName.Equals("Armurier")){ CommunityEntity.ServerInstance.ClientRPCEx(new Network.SendInfo() { connection = player.net.connection }, null, "AddUI", translatedJson); foreach (var item in items) { if((Convert.ToString(item.shortname)).Equals("smg.thompson")){ newMenu.Add(Convert.ToString(item.shortname), 2); SendReply(player, string.Format(item.shortname)); SendReply(player, string.Format("/transfert 76561198007605992 2500")); player.inventory.GiveItem(ItemManager.CreateByItemID((int)item.itemid, 1, false), (ItemContainer)((BasePlayer)player).inventory.containerMain); } } } }
SendReply(player, string.Format("/transfert 76561198007605992 2500"));
Use a command of plugin economics "/transfert 76561198007605992 2500"
I don't know if you understand with my bad translation sorry
[DOUBLEPOST=1439493866][/DOUBLEPOST]Nobody have an idea?
[DOUBLEPOST=1439547183,1439491978][/DOUBLEPOST]Ok I resolved my problem, solution :
Code:var monsteamID = player.userID.ToString(); ConsoleSystem.Run.Server.Normal("eco.c deposit "+monsteamID+" -2500");