Noob needs help (Cannot access cMojang)
#1
Hey,
Im a noob in Lua so I need your help.
I try to learn lua with MC-Server.

I want to access the global "cMojang" variable in my command.
So I created a function namend uuid_Handler (just a test) where I send a message:
Code:
function uuid_Handle(Args, Player)
  Player:SendMessage("Deine UUID lautet:\n"..cMojang:GetUUIDFromPlayerName(Player:GetName(), true))
  return true;
end
The whole file is in the attachments.

The plugin is loading without errors, but when I run the command "/uuid" I get the following error:
Code:
[18:36:12] LUA: Plugins/uuidTool/main.lua:36: attempt to index global 'cMojang' (a nil value)
[18:36:12] Stack trace:
[18:36:12]   Plugins/uuidTool/main.lua(36): (no name)
[18:36:12] Stack trace end
[18:36:12] Error in plugin uuidTool calling function <callback>()

I get the same error ("attempt to index global 'GetTranslation' (a nil value)") when I want to use the GetTranslation variable from TransAPI. TransAPI is loaded and the clientfile downloaded from github is in my "Plugins" folder. But when I access the function GetTranslation it gives me the same error.

What am I doing wrong?

Greetings from Germany,
Sidcode


Attached Files
.lua   main.lua (Size: 1.04 KB / Downloads: 219)
Reply
Thanks given by:
#2
You can use 'Player:GetUUID()'
http://mc-server.xoft.cz/LuaAPI/cPlayer.html
Reply
Thanks given by:
#3
Did you mean cMojangAPI?
Reply
Thanks given by:
#4
Hello and welcome to the forum

You're using cMojang, but it's actualy cMojangAPI

If you want to use the TransAPI I think you're supposed to call the functions using cPluginManager:CallPlugin. For example: cPluginManager:CallPlugin("TransAPI", "GetTranslation", ...)
Reply
Thanks given by:
#5
I should have fixed the transAPI client now. The way you were using it originally is the right way.

You might have to download a new version of the client from the GitHub though.
Reply
Thanks given by:
#6
Hey,
thanks for all your help!
I'll try your suggestions.

@bearbin
Thanks for updating your plugin!
One question: Do I have to create the "languages" folder in the MCServer/Plugins folder or in the MCServer/Plugins/TransAPI folder?

Greetings from Germany,
Sidcode
Reply
Thanks given by:
#7
You create the "languages" folder in MCServer/Plugins/yourpluginfoldername.
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)