Cuberite Forum
Get value from another plugin? - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: Get value from another plugin? (/thread-1417.html)



Get value from another plugin? - agusnat16 - 03-24-2014

Is possible, obtain the value of a variable from another plugin?

Plugin:
PHP Code:
variable1 Info[Player]; 

Another plugin:
PHP Code:
InfoGet[Player] = variable1

As "natives", pawno or only with sqlite, txt, etc?


RE: Get value from another plugin? - tigerw - 03-24-2014

See http://mc-server.xoft.cz/LuaAPI/cPluginManager.html -> CallPlugin for specifics and limitations.

Usage:
Code:
cPluginManager:CallPlugin("PluginName", "FunctionToCall", Optional Parameters)



RE: Get value from another plugin? - agusnat16 - 03-24-2014

Thanks for reply i don't see that, something?

Plugin "Game":
PHP Code:
function GetWinner()
      return 
ServerData.Winner;
end 

Plugin "Login":
PHP Code:
function GivePoints()
      
local WinnerName cPluginManager:CallPlugin("Game""GetWinner");
      
PlayerData.points[WinnerName] = PlayerData.points[WinnerName] +1;
end 



RE: Get value from another plugin? - xoft - 03-24-2014

First of all, check if there's any errors or warnings in the server console. That is the first place where problems are discovered.

Second, in the GetWinner() function, add logging to verify that you are sending over the proper value:
function GetWinner()
    LOG("Function GetWinner()")
    LOG("  type(ServerData.Winner) = " .. type(ServerData.Winner))
    LOG("  ServerData.Winner = " .. ServerData.Winner)
    return ServerData.Winner
end
Similarly, verify in the GivePoints() function that you're getting what you think you are getting.