Fix crash when using chat commands affect/removeaffects

* related to pull request https://github.com/Bremaweb/adventuretest/pull/38
* related to pull request https://codeberg.org/minenux/minetest-game-adventuretest/pulls/38
* related to pull request #38
master
mckaygerhard 2023-01-12 17:38:51 -04:00
parent c55a8f8dcd
commit b2feac105a
1 changed files with 3 additions and 1 deletions

View File

@ -5,7 +5,9 @@ minetest.register_chatcommand("affect",{
privs = {affects=true},
func = function (name, param)
local aname, affectid = string.match(param, "([^ ]+) (.+)")
if ( affects.affectPlayer(aname,affectid) ) then
if ( aname == nil or aname == "" or affectid == nil or affectid == '' ) then
minetest.chat_send_player(name, "Syntax: affect <name> <affectid>")
elseif ( affects.affectPlayer(aname,affectid) ) then
minetest.chat_send_player(name,aname.." has been affected by "..affects._affects[affectid].name)
else
minetest.chat_send_player(name,"Unable to affect "..aname.." with "..affectid)