mouse 53 Report post Posted June 30, 2015 Long story short:I created a series of buttons. When the player clicks a button, all buttons disappear and things happen.One of the things that happen is giving the player an item. Right now that's not happening.From what I understand, all I have to do is:local function eventxfunction() print("stuff happens")endAddPlayerPostInit(function(inst) inst.eventx=GLOBAL.net_event(inst.GUID, "eventxname", eventxfunction)end)AddClassPostConstruct("widgets/statusdisplays", function(self)--blah blah blah button stuff buttonx:SetOnClick(function() self.owner.eventx:Push() end)end)But that gives the error: "push" is a nil value.Am I using net_event wrong or something? Share this post Link to post Share on other sites
Kzisor 1060 Report post Posted June 30, 2015 @mouse, from client to server you need to use MOD RPC's. http://forums.kleientertainment.com/files/file/1126-tutorial-mod-rpcs-with-keyhandler/ Server to client it's net_event. Share this post Link to post Share on other sites
mouse 53 Report post Posted July 1, 2015 @mouse, from client to server you need to use MOD RPC's. http://forums.kleientertainment.com/files/file/1126-tutorial-mod-rpcs-with-keyhandler/ Server to client it's net_event. No sorry, by "button" I mean imagebutton. It's a series of GUI buttons on the screen. For anybody stumbling across this thread in the future, the first problem was "Push" isn't supposed to be capitalized. Now the problem I'm having is I can't give any items to the player after the button is clicked. I take it the client can't change a server value via inst._netvar:set(var)? Share this post Link to post Share on other sites
DarkXero 2889 Report post Posted July 1, 2015 I take it the client can't change a server value via inst._netvar:set(var)? A netvar is a variable that exists both in the server and the client.If the server sets the variable, then the changes propagate. A client can change a netvar like that, for example, the one that tells you that you are taking fire damage in health replica.The arrow down for the health badge will pop up. However your health won't go down.This change won't propagate to the server. And if the server changes the netvar, the netvar in the client will change. This is what Kzisor means:AddModRPCHandler(modname, "GiveItem", function(player) local item = GLOBAL.SpawnPrefab("meat") player.components.inventory:GiveItem(item)end) AddClassPostConstruct("widgets/statusdisplays", function(self) --blah blah blah button stuff buttonx:SetOnClick(function() SendModRPCToServer(MOD_RPC[modname]["GiveItem"]) end)end) Share this post Link to post Share on other sites
mouse 53 Report post Posted July 1, 2015 A netvar is a variable that exists both in the server and the client.If the server sets the variable, then the changes propagate.I know. I was just using "netvar" as a generic variable name. Like:local stringvar="hello" A client can change a netvar like that, for example, the one that tells you that you are taking fire damage in health replica.The arrow down for the health badge will pop up. However your health won't go down.This change won't propagate to the server. And if the server changes the netvar, the netvar in the client will change. This is what Kzisor means:AddModRPCHandler(modname, "GiveItem", function(player) local item = GLOBAL.SpawnPrefab("meat") player.components.inventory:GiveItem(item)end) AddClassPostConstruct("widgets/statusdisplays", function(self) --blah blah blah button stuff buttonx:SetOnClick(function() SendModRPCToServer(MOD_RPC[modname]["GiveItem"]) end)end)That RPC handler stuff is pretty important. I wish I had known about it sooner. BTW, what does RPC stand for?Anyhow, that did the trick and now I can finally move on to other parts of the mod. Thank you very much. Share this post Link to post Share on other sites
DarkXero 2889 Report post Posted July 1, 2015 what does RPC stand for? https://en.wikipedia.org/wiki/Remote_procedure_call Share this post Link to post Share on other sites