Hi EveryBody,
Is there a way to handle a CallHook on python plugin ? I have put helptext plugin and i want to put "SendHelpText" hook on notifier.py.
I have put this on notifier.py :
And the callhook on helptext.lua is :Code:def SendHelpText(self, player): helptext = "<size=18>Notifier</size> by <color=#ce422b>SkinN</color>\n" helptext += " " + "<color=\"#ffd479\">/players</color> - Displays number of players" helptext += " " + "<color=\"#ffd479\">/online</color> - Displays online players" helptext += " " + "<color=\"#ffd479\">/admins</color> - Displays online admins" helptext += " " + "<color=\"#ffd479\">/plugins</color> - Displays server plugins" #player.ChatMessage(helptext) rust.SendChatMessage(player, helptext, None, '76561198235146288')
Code:plugins.CallHook("SendHelpText", util.TableToArray({player}))
But nothing append. How can i handle the CallHook send by helptext plugin ?
Regards,
oLaNceLoTo
Solved Python and SendHelpText hook?
Discussion in 'Rust Development' started by oLaNceLoTo, Jan 21, 2016.
-
CallHook will simply call the specified hook with the specified arguments on every plugin that specifies the hook in its code, unregarding which language the plugin is written in. Make sure to check the console or log file that no errors have occured. I will run some tests myself when I get home from work.
-
I am waiting for your answer impatiently xD
-
So I have just tested this by downloading the latest version of notifier and then fixing a few tiny things that prevented it from loading and then I added the SendHelpText function you mentioned before and it was working for me. Is it possible that Notifier is actually throwing an error and preventing the plugin from being loaded for you like it was for me? As that would explain why the helptext wouldn't be shown to the player when he/she uses the /help command.
-
It's totally probable....I will check the log this evening. I Keep this post inform.
[DOUBLEPOST=1453493391,1453443104][/DOUBLEPOST]So no error or warning on the log when i type the command or before.....
[DOUBLEPOST=1453546603][/DOUBLEPOST]Is this code correct
Code:rust.SendChatMessage(player, helptext, None, '76561198235146288')
-
-
yes /players /online and /admins works
[DOUBLEPOST=1453553052][/DOUBLEPOST]i ve tried to unload all plugins exept helptext and notifier and the same
[DOUBLEPOST=1453553150][/DOUBLEPOST]I ve download the latest notifier
Code:self.Title = 'Notifier' self.Version = V(2, 18, 0) self.Author = 'SkinN' self.Description = 'Server administration tool with chat based notifications' self.ResourceId = 797
Code:import re import time import BasePlayer import ConVar.Server as sv import TOD_Sky import UnityEngine.Random as random from System import Action, Int32, StringDEV = True LINE = '-' * 50 DBNAME = 'notifier-countries_db'class notifier: def __init__(self): self.Title = 'Notifier' self.Version = V(2, 18, 0) self.Author = 'SkinN' self.Description = 'Server administration tool with chat based notifications' self.ResourceId = 797 def SendHelpText(self, player): helptext = "<size=18>Notifier</size> by <color=#ce422b>SkinN</color>\n" helptext += " " + "<color=\"#ffd479\">/players</color> - Displays number of players" helptext += " " + "<color=\"#ffd479\">/online</color> - Displays online players" helptext += " " + "<color=\"#ffd479\">/admins</color> - Displays online admins" helptext += " " + "<color=\"#ffd479\">/plugins</color> - Displays server plugins" #player.ChatMessage(helptext) rust.SendChatMessage(player, helptext, None, '76561198235146288') #rust.SendChatMessage(player, msg, None, profile)
[DOUBLEPOST=1453554000][/DOUBLEPOST]And this is the all helptext.lua :
Code:PLUGIN.Title = "Helptext" PLUGIN.Description = "Hooks into plugins to send helptext" PLUGIN.Author = "#Domestos" PLUGIN.Version = V(1, 4, 0) PLUGIN.HasConfig = true PLUGIN.ResourceID = 676function PLUGIN:Init() command.AddChatCommand("help", self.Object, "cmdHelp") self:LoadDefaultConfig() endfunction PLUGIN:LoadDefaultConfig() self.Config.Settings = self.Config.Settings or {} self.Config.Settings.UseCustomHelpText = self.Config.Settings.UseCustomHelpText or "false" self.Config.Settings.AllowHelpTextFromOtherPlugins = self.Config.Settings.AllowHelpTextFromOtherPlugins or "true" self.Config.CustomHelpText = self.Config.CustomHelpText or { "custom helptext", "custom helptext" } self:SaveConfig() endfunction PLUGIN:cmdHelp(player) if not player then return end if self.Config.Settings.UseCustomHelpText == "true" then for _, helptext in pairs(self.Config.CustomHelpText) do rust.SendChatMessage(player, helptext) end end if self.Config.Settings.AllowHelpTextFromOtherPlugins == "true" then plugins.CallHook("SendHelpText", util.TableToArray({player})) end end
[DOUBLEPOST=1453554220][/DOUBLEPOST]if you are free to test this afternoon, comme to the server : rust.ohbordel.fr:28015 (F1 => connect rust.ohbordel.fr:28015 => Enter) Server web site : Rust - OhBordel ! , server name : "En Dev - Do not Join - [FR] RUST & Bordel - Oh Bordel ! Fun and Repect Server" -
Wulf Community Admin
@oLaNceLoTo, let's keep the discussion here, since it doesn't directly relate to the other plugins as all it does it call a hook via Oxide, and since the discussion is already here. I tested with Notifier and HelpText and the portion of code you provided above, and it works fine as well.
I've attached the working version.Attached Files:
Last edited: Jan 23, 2016 -
-
Even if you beleive I m' a noob or something else i dont care, you gave me a valid file that work and with this solution I have found that my file had contain space and not tabulation for python..... It's why it didn't work.....
And for keeping the face before finding, i have download notifier from here (Oxide plugin), then i have copy/pase the method SendHelpText from YOUR file, and it has not work.... I have so use notepad++, "transform space to tabulation" and it has work.....
So the problem is come from, notepad++, my NTFS disk, my chrome brower or because i m on tse to my server....... -
Wulf Community Admin
-
Yes, i know it's my job i m now Responsible of a python web site...... I was never having this problem mainly that I do like every day.....
But i work on a VM ubuntu with pycharm generally, i was here, on notepad++ and by Remote Desktop to add the method....
Shortly, I hope it can help other people.