Help with csm needed

micheal65536
Member
 
Posts: 160
Joined: Mon May 22, 2017 20:27

Re: Help with csm needed

by micheal65536 » Sun Nov 17, 2019 18:49

Miniontoby wrote:But the reason don't needed to posted everytime ;)

No problem. Your original code was using the variable kick_message in the auto-kick code so I assumed you were trying to store and load the kick message (were either planning to add this feature or had removed it because it didn't work).

Miniontoby wrote:And I add the server info for the kicking a player on a specific server and not kicking at an other server

Good job with that. I was concerned that this would be too complicated to solve and explain but it seems you've figured it out yourself. My only suggestion (and it's a really minor one) would be to change "kick_" to "_kick_" for the name of the value that you're saving (change storage:set_string(server_id .. "kick_" .. player_name, "true") to storage:set_string(server_id .. "_kick_" .. player_name, "true") and likewise in other places) because technically you're missing an underscore between the server identifier and the subsequent text, but this doesn't matter in practice.

Your code looks good now, I can't see any obvious issues with it. Obviously bear in mind that this still won't kick someone who is already online when you join the game (you would need to use the "/status" command and then wait for the response to parse out the list of connected players if you wanted to do that).

Miniontoby wrote:I runned a server from the commandline, I joined it and mod doesn't got loaded (and I have put the client-side-modding on) so that is also an problem

You say you enabled client-side modding but did you enable this specific mod? In addition to enabling or disabling client-side modding entirely, Minetest also has an option to enable or disable specific client-side mods and it won't enable new client-side mods by default. Go to your clientmods directory and find the file called mods.conf. Open this file with a text editor and change the line load_mod_kick2 = false to load_mod_kick2 = true (I'm assuming that the mod is called "kick2" - if not, substitute the name of the mod in the lines above). If this line doesn't exist, add it. If the file doesn't exist, create it and put this line in the file.
 

User avatar
Miniontoby
Member
 
Posts: 330
Joined: Fri Mar 01, 2019 19:25
Location: The Netherlands
In-game: Miniontoby

Re: Help with csm needed

by Miniontoby » Mon Nov 18, 2019 12:45

micheal65536 wrote:
Miniontoby wrote:I runned a server from the commandline, I joined it and mod doesn't got loaded (and I have put the client-side-modding on) so that is also an problem

You say you enabled client-side modding but did you enable this specific mod? In addition to enabling or disabling client-side modding entirely, Minetest also has an option to enable or disable specific client-side mods and it won't enable new client-side mods by default. Go to your clientmods directory and find the file called mods.conf. Open this file with a text editor and change the line load_mod_kick2 = false to load_mod_kick2 = true (I'm assuming that the mod is called "kick2" - if not, substitute the name of the mod in the lines above). If this line doesn't exist, add it. If the file doesn't exist, create it and put this line in the file.

I have enabled it in the mods.conf and I have tried to rename my mod adn then try it and it also don't got loaded on my server when I join

And all the csm's I have doesn't work (all the enabled csm's I mean)
My English isn't very good because I'm Dutch ---- Check my mod "Doorbell"
 

micheal65536
Member
 
Posts: 160
Joined: Mon May 22, 2017 20:27

Re: Help with csm needed

by micheal65536 » Tue Nov 19, 2019 20:38

Miniontoby wrote:
micheal65536 wrote:
Miniontoby wrote:I runned a server from the commandline, I joined it and mod doesn't got loaded (and I have put the client-side-modding on) so that is also an problem

You say you enabled client-side modding but did you enable this specific mod? In addition to enabling or disabling client-side modding entirely, Minetest also has an option to enable or disable specific client-side mods and it won't enable new client-side mods by default. Go to your clientmods directory and find the file called mods.conf. Open this file with a text editor and change the line load_mod_kick2 = false to load_mod_kick2 = true (I'm assuming that the mod is called "kick2" - if not, substitute the name of the mod in the lines above). If this line doesn't exist, add it. If the file doesn't exist, create it and put this line in the file.

I have enabled it in the mods.conf and I have tried to rename my mod adn then try it and it also don't got loaded on my server when I join

And all the csm's I have doesn't work (all the enabled csm's I mean)

Add the line csm_restriction_flags = 0 to the minetest.conf file for the server that you're testing with and try again.
 

micheal65536
Member
 
Posts: 160
Joined: Mon May 22, 2017 20:27

Re: Help with csm needed

by micheal65536 » Thu Nov 21, 2019 20:24

Miniontoby wrote:I have made changes and this is my code now:

I had another look at your code and noticed some issues that I missed the first time (both of these I already mentioned in my earlier post).

Code: Select all
minetest.register_chatcommand("kick2", {
    params = "<playername> | <playername> <reason>",
    func = function(name, param)
Code: Select all
minetest.register_chatcommand("unkick2", {
    params = "<playername>",
    privs = {
        kick = true,
    },
    func = function(name, param)
Change func = function(name, param) to func = function(param). Client-side mods do not get a name parameter to the command handler function and the code won't work if you include this parameter.

Code: Select all
minetest.register_chatcommand("unkick2", {
    params = "<playername>",
    privs = {
        kick = true,
    },
    func = function(name, param)
Remove the privs section, it is ignored in client-side mods and does nothing. You already removed it from the other command definition so I assume you just missed it on this one.

Also see my previous post about testing the mod.
 

User avatar
Miniontoby
Member
 
Posts: 330
Joined: Fri Mar 01, 2019 19:25
Location: The Netherlands
In-game: Miniontoby

Re: Help with csm needed

by Miniontoby » Sat Nov 23, 2019 09:00

Now only the "register_on_receiving_chat_message" function doesnt work . Could you help me?
My English isn't very good because I'm Dutch ---- Check my mod "Doorbell"
 

micheal65536
Member
 
Posts: 160
Joined: Mon May 22, 2017 20:27

Re: Help with csm needed

by micheal65536 » Sat Nov 23, 2019 20:40

Miniontoby wrote:Now only the "register_on_receiving_chat_message" function doesnt work . Could you help me?

When you say "doesn't work", do you get an error message or is it just that nothing seems to happen when someone joins the game?
 

User avatar
Miniontoby
Member
 
Posts: 330
Joined: Fri Mar 01, 2019 19:25
Location: The Netherlands
In-game: Miniontoby

Re: Help with csm needed

by Miniontoby » Sun Nov 24, 2019 11:32

I havent tested it but the person who this wiil well have checked
This makes things easier, but why can't it be in one command like MinionToby's??
It's over complicating things to use 2 commands to perform 1 simple function.

I'm testing MinionToby's one now... let's see if it works!

EDIT:
Bad news, it gave me a mod error. This is what I saw (copied from debug.txt)

Code: Select all
2019-11-22 13:28:02: ERROR[Main]: ModError: Failed to load and run script from C:\MTC\0.4.16\bin\..\clientmods\kick_csm\init.lua:
2019-11-22 13:28:02: ERROR[Main]: C:\MTC\0.4.16\bin\..\clientmods\kick_csm\init.lua:27: attempt to call field 'register_on_receiving_chat_message' (a nil value)
2019-11-22 13:28:02: ERROR[Main]: Check debug.txt for details.
My English isn't very good because I'm Dutch ---- Check my mod "Doorbell"
 

micheal65536
Member
 
Posts: 160
Joined: Mon May 22, 2017 20:27

Re: Help with csm needed

by micheal65536 » Mon Nov 25, 2019 20:25

I have tested the mod according to the last version of the code that you posted (with the changes that I specified in my last post). I made a mistake with the ^*** (%S*) joined the game$ pattern and it should be changed to ^*** (%S*) joined the game%.$ (Minetest puts a . at the end of the join message that I wasn't aware of, and you have to use %. to match it because a . on its own in a pattern means "any character"), but other than that it is working. For reference, here is the complete code that I have tested:
Code: Select all
local storage = minetest.get_mod_storage()
local server_info = minetest.get_server_info()
local server_id = server_info.address .. ':' .. server_info.port

minetest.register_chatcommand("kick2", {
   params = "<playername> | <playername> <reason>",
   func = function(param)
      if string.find(param, "^[^ ]+%s+.+") then
         player_name, reason = string.match(param, "^([^ ]+)%s+(.+)")
         minetest.run_server_chatcommand("kick", player_name .. " " .. reason)
         storage:set_string(server_id .. "kick_" .. player_name, "true")
      else
         player_name = param
         minetest.run_server_chatcommand("kick", player_name)
         storage:set_string(server_id .. "kick_" .. player_name, "true")
      end
    end,   
})

minetest.register_chatcommand("unkick2", {
   params = "<playername>",
   func = function(param)
      storage:set_string(server_id .. "kick_" .. param, "")
    end,   
})

minetest.register_on_receiving_chat_message(function(message)
   if string.find(message, "^*** (%S*) joined the game%.$") then
      player_name = string.match(message, "^*** (%S*) joined the game%.$")
      if storage:get_string(server_id .. "kick_" .. player_name) == "true" then
         minetest.run_server_chatcommand("kick", player_name)
      end
   end
end)


Make sure that the person who is testing the mod has the latest version of the code. Is there any reason why you are relying on someone else to test the mod instead of testing it yourself?
 

User avatar
Miniontoby
Member
 
Posts: 330
Joined: Fri Mar 01, 2019 19:25
Location: The Netherlands
In-game: Miniontoby

Re: Help with csm needed

by Miniontoby » Thu Nov 28, 2019 16:39

This is what he got

Sadly, upon testing the CSM, I got a very similar, if not the same, error message.

Code: Select all
2019-11-28 10:52:48: ERROR[Main]: ModError: Failed to load and run script from /home/[username]/snap/minetest-luk3yx-4/97/.minetest/clientmods/kick_csm/init.lua:
2019-11-28 10:52:48: ERROR[Main]: ...etest-luk3yx-4/97/.minetest/clientmods/kick_csm/init.lua:27: attempt to call field 'register_on_receiving_chat_message' (a nil value)
2019-11-28 10:52:48: ERROR[Main]: Check debug.txt for details.

(copied from debug.txt)


and this the code https://forum.minetest.net/download/file.php?id=20660

So it isnt solved and else I need an other option for getting the players who are online / joined
My English isn't very good because I'm Dutch ---- Check my mod "Doorbell"
 

micheal65536
Member
 
Posts: 160
Joined: Mon May 22, 2017 20:27

Re: Help with csm needed

by micheal65536 » Thu Nov 28, 2019 22:49

Miniontoby wrote:This is what he got

Sadly, upon testing the CSM, I got a very similar, if not the same, error message.

Code: Select all
2019-11-28 10:52:48: ERROR[Main]: ModError: Failed to load and run script from /home/[username]/snap/minetest-luk3yx-4/97/.minetest/clientmods/kick_csm/init.lua:
2019-11-28 10:52:48: ERROR[Main]: ...etest-luk3yx-4/97/.minetest/clientmods/kick_csm/init.lua:27: attempt to call field 'register_on_receiving_chat_message' (a nil value)
2019-11-28 10:52:48: ERROR[Main]: Check debug.txt for details.

(copied from debug.txt)


and this the code https://forum.minetest.net/download/file.php?id=20660

So it isnt solved and else I need an other option for getting the players who are online / joined

Is the person who is testing the mod using the latest version of Minetest (5.1.0)? If not, what version are they using? And why are you unable to test the mod yourself?
 

User avatar
Miniontoby
Member
 
Posts: 330
Joined: Fri Mar 01, 2019 19:25
Location: The Netherlands
In-game: Miniontoby

Re: Help with csm needed

by Miniontoby » Sat Nov 30, 2019 12:54

I did tested (I tried) but got an error when I runnend my server
Code: Select all
2019-11-30 13:52:09: ACTION[Main]: Server: Shutting down
2019-11-30 13:52:09: ERROR[Main]: In thread 1:
2019-11-30 13:52:09: ERROR[Main]: /home/stefan/mt-build/build/minetest_64/minetest/src/serverenvironment.cpp:e6: createIntroductionTimesString: A fatal error occurred: attempted to query on non fully set up LBMManager
My English isn't very good because I'm Dutch ---- Check my mod "Doorbell"
 

micheal65536
Member
 
Posts: 160
Joined: Mon May 22, 2017 20:27

Re: Help with csm needed

by micheal65536 » Sun Dec 01, 2019 21:20

Miniontoby wrote:I did tested (I tried) but got an error when I runnend my server
Code: Select all
2019-11-30 13:52:09: ACTION[Main]: Server: Shutting down
2019-11-30 13:52:09: ERROR[Main]: In thread 1:
2019-11-30 13:52:09: ERROR[Main]: /home/stefan/mt-build/build/minetest_64/minetest/src/serverenvironment.cpp:e6: createIntroductionTimesString: A fatal error occurred: attempted to query on non fully set up LBMManager

That error has nothing to do with client-side modding and indicates a problem with the Minetest "core" itself. Make sure that you are using version 5.1.0 of Minetest and not the "master" version. The correct source code can be found here: https://github.com/minetest/minetest/ar ... 1.0.tar.gz.
 

User avatar
Miniontoby
Member
 
Posts: 330
Joined: Fri Mar 01, 2019 19:25
Location: The Netherlands
In-game: Miniontoby

Re: Help with csm needed

by Miniontoby » Wed Dec 04, 2019 14:26

I have windows 10
My English isn't very good because I'm Dutch ---- Check my mod "Doorbell"
 

micheal65536
Member
 
Posts: 160
Joined: Mon May 22, 2017 20:27

Re: Help with csm needed

by micheal65536 » Thu Dec 05, 2019 20:20

Download the correct standalone Windows version of Minetest 5.1.0 and try it again: https://github.com/minetest/minetest/re ... -win64.zip
 

User avatar
Miniontoby
Member
 
Posts: 330
Joined: Fri Mar 01, 2019 19:25
Location: The Netherlands
In-game: Miniontoby

Re: Help with csm needed

by Miniontoby » Fri Dec 06, 2019 16:06

I did solved that minetest doesnt work by removing the env_meta.txt and now minetest works

and my code doesnt work. This is it now (only the automatic kick code)
Code: Select all
minetest.register_globalstep(function(dtime)
   local status = minetest.run_server_chatcommand("status")
   if string.find(status, "^# Server: .*clients={([^}]*)}") then
      local list = string.match(status, "^# Server: .*clients={([^}]*)}")
      for player in string.gmatch(list, "[^, ][^, ]*") do
         if storage:get_string(server_id .. "_kick_" .. player) == "true" then
            minetest.run_server_chatcommand("kick", player)
         end
      end
   end
end)
My English isn't very good because I'm Dutch ---- Check my mod "Doorbell"
 

micheal65536
Member
 
Posts: 160
Joined: Mon May 22, 2017 20:27

Re: Help with csm needed

by micheal65536 » Sun Dec 08, 2019 20:45

Miniontoby wrote:and my code doesnt work. This is it now (only the automatic kick code)
Code: Select all
minetest.register_globalstep(function(dtime)
   local status = minetest.run_server_chatcommand("status")
   if string.find(status, "^# Server: .*clients={([^}]*)}") then
      local list = string.match(status, "^# Server: .*clients={([^}]*)}")
      for player in string.gmatch(list, "[^, ][^, ]*") do
         if storage:get_string(server_id .. "_kick_" .. player) == "true" then
            minetest.run_server_chatcommand("kick", player)
         end
      end
   end
end)

That code will not work. minetest.run_server_chatcommand does not return a value. To get the reply from a server command, you have to monitor incoming chat messages (the same way that you're monitoring the chat messages to see when a player joins the server).

However, you should not use this code as it will flood the server with /status commands. Do not run this code on a public server, it will flood the server with /status commands. This code is also unnecessary. According to the code that you posted previously (which did not include this piece of code, and I assumed that you had posted the entire code), you're already monitoring for players joining the game and kicking them when they join, therefore there is no reason to also continually monitor the list of players on the server to check for the players that you want to kick.

The *only* reason why you would *ever* want to look at the server status message in your mod is if you join the game when the player that you want to kick is already online and you want to kick them straight away without having to manually kick them after you join. The reason for this is because you won't get a join message for the player that you want to kick if they're already online when you join, so your mod won't know to kick them. If you do want to do this, then you do not need to send the /status command at all because the server automatically sends the status message when you join. All that you need to do is write another minetest.register_on_receiving_chat_message section (I recommend using a separate one to the one that's checking for player join messages as it makes the code easier to understand - you can have more than one) and put the string.find/string.match stuff in there (do not include the minetest.run_server_chatcommand("status") line as this will flood the server with /status commands).
 

User avatar
Miniontoby
Member
 
Posts: 330
Joined: Fri Mar 01, 2019 19:25
Location: The Netherlands
In-game: Miniontoby

Re: Help with csm needed

by Miniontoby » Mon Dec 09, 2019 08:09

So how you recommend to have the code now??
My English isn't very good because I'm Dutch ---- Check my mod "Doorbell"
 

micheal65536
Member
 
Posts: 160
Joined: Mon May 22, 2017 20:27

Re: Help with csm needed

by micheal65536 » Wed Dec 11, 2019 22:14

Miniontoby wrote:So how you recommend to have the code now??

Exactly as I explained in my previous post. I will repeat the relevant parts here, because you are apparently unable to do anything with the information that I give you unless it is repeated twice.

micheal65536 wrote:According to the code that you posted previously, you're already monitoring for players joining the game and kicking them when they join, therefore there is no reason to also continually monitor the list of players on the server to check for the players that you want to kick.

In other words, completely remove that last piece of code that you posted (the minetest.register_globalstep part that constantly sends the /status command and tries to get a response) and just use the previous version that I have already tested and told you to use:
micheal65536 wrote:For reference, here is the complete code that I have tested:
Code: Select all
local storage = minetest.get_mod_storage()
local server_info = minetest.get_server_info()
local server_id = server_info.address .. ':' .. server_info.port

minetest.register_chatcommand("kick2", {
   params = "<playername> | <playername> <reason>",
   func = function(param)
      if string.find(param, "^[^ ]+%s+.+") then
         player_name, reason = string.match(param, "^([^ ]+)%s+(.+)")
         minetest.run_server_chatcommand("kick", player_name .. " " .. reason)
         storage:set_string(server_id .. "kick_" .. player_name, "true")
      else
         player_name = param
         minetest.run_server_chatcommand("kick", player_name)
         storage:set_string(server_id .. "kick_" .. player_name, "true")
      end
    end,   
})

minetest.register_chatcommand("unkick2", {
   params = "<playername>",
   func = function(param)
      storage:set_string(server_id .. "kick_" .. param, "")
    end,   
})

minetest.register_on_receiving_chat_message(function(message)
   if string.find(message, "^*** (%S*) joined the game%.$") then
      player_name = string.match(message, "^*** (%S*) joined the game%.$")
      if storage:get_string(server_id .. "kick_" .. player_name) == "true" then
         minetest.run_server_chatcommand("kick", player_name)
      end
   end
end)


micheal65536 wrote:The *only* reason why you would *ever* want to look at the server status message in your mod is if you join the game when the player that you want to kick is already online and you want to kick them straight away without having to manually kick them after you join. The reason for this is because you won't get a join message for the player that you want to kick if they're already online when you join, so your mod won't know to kick them. If you do want to do this, then you do not need to send the /status command at all because the server automatically sends the status message when you join. All that you need to do is write another minetest.register_on_receiving_chat_message section (I recommend using a separate one to the one that's checking for player join messages as it makes the code easier to understand - you can have more than one) and put the string.find/string.match stuff in there (do not include the minetest.run_server_chatcommand("status") line as this will flood the server with /status commands).

In other words, the preceding complete and working code that I quoted from one of my previous posts will only kick someone if they join after you, or you manually kick them. It will not automatically kick someone who is already online when you join the server. I already explained this to you before but you seem to have ignored it so I assumed that you understood this and were OK with it. If this is not OK and you want to automatically kick someone who is already online when you join the server, then copy and paste your existing minetest.register_on_receiving_chat_message section and replace the stuff inside with the stuff that you had inside your minetest.register_globalstep section (without the local status = minetest.run_server_chatcommand("status") line and using the message parameter in place of your status variable).
 

User avatar
Miniontoby
Member
 
Posts: 330
Joined: Fri Mar 01, 2019 19:25
Location: The Netherlands
In-game: Miniontoby

Re: Help with csm needed

by Miniontoby » Wed Jan 29, 2020 14:48

I have now an other one

I have this code
Code: Select all
minetest.register_chatcommand("antigravity", {
    func = function(name, param)
        local player = minetest.localplayer
        player:set_physics_override({
            gravity = 0.1,
        })
    end,
})

and it give an error
Code: Select all
2020-01-29 15:43:44: WARNING[Main]: Irrlicht: PNG warning: iCCP: known incorrect sRGB profile
2020-01-29 15:43:44: WARNING[Main]: Irrlicht: PNG warning: iCCP: known incorrect sRGB profile
2020-01-29 15:44:01: ERROR[Main]: ModError: Runtime error from mod 'fly' in callback on_sending_message(): fly:init.lua:4: attempt to call method 'set_physics_override' (a nil value)
2020-01-29 15:44:01: ERROR[Main]: stack traceback:
2020-01-29 15:44:01: ERROR[Main]:    fly:init.lua:4: in function 'func'
2020-01-29 15:44:01: ERROR[Main]:    *builtin*:client/chatcommands.lua:29: in function <*builtin*:client/chatcommands.lua:4>
2020-01-29 15:44:01: ERROR[Main]:    *builtin*:client/register.lua:19: in function <*builtin*:client/register.lua:7>
2020-01-29 15:44:01: ERROR[Main]: Check debug.txt for details.


Please help if there is an option to do this and else there is no option
My English isn't very good because I'm Dutch ---- Check my mod "Doorbell"
 

User avatar
Linuxdirk
Member
 
Posts: 2347
Joined: Wed Sep 17, 2014 11:21
Location: Germany
In-game: Linuxdirk
 

Previous

Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 6 guests