nolanri Posted December 11, 2016 Share Posted December 11, 2016 Spoiler SleepInCars.doMenu = function(player, context, items) for i,v in ipairs(items) do local tempitem = v; if not instanceof(v, "InventoryItem") then tempitem = v.items[1]; end if (tempitem:getModData().isCar == true) then context:addOption("Sleep in this Vehicle", worldobjects, SleepInCars.onSleep, player, sleep); end end end SleepInCars.onSleep = function(item, player) local playerObj = getSpecificPlayer(player); if(item ~= nil) then setGcar(item) end; DriveCarsSaveBodyDamage(playerObj); ISTimedActionQueue.clear(playerObj) ISWorldObjectContextMenu.onSleepWalkToComplete(player) end Events.OnFillInventoryObjectContextMenu.Add(SleepInCars.doMenu); I have made a context menu entry for inventory items. But now i need to add right click context menu for right click on players, Is there an event similar to this but for players? Link to comment Share on other sites More sharing options...
EUDOXIO Posted December 11, 2016 Share Posted December 11, 2016 There should be something, since you can see other players health menu's and heal them if you are not hemophobic. Link to comment Share on other sites More sharing options...
nolanri Posted December 11, 2016 Author Share Posted December 11, 2016 but it needs to be a method in LUA. if its java, would require pasting over java classes in PZ install directory and I have had enough of people asking how to do that. Link to comment Share on other sites More sharing options...
EnigmaGrey Posted December 11, 2016 Share Posted December 11, 2016 You're just inserting a item into the right click context menu if the area clicked contains a player. That doesn't need to be done in Java, as EUDOXIO tried to point out. Look at ISWorldObjectContextMenu.lua and see how the medical check panel is called. EUDOXIO 1 Link to comment Share on other sites More sharing options...
nolanri Posted December 12, 2016 Author Share Posted December 12, 2016 the contents of ISWorldObjectContextMenu.lua was very helpful. Thanks guys. EUDOXIO 1 Link to comment Share on other sites More sharing options...
EUDOXIO Posted December 12, 2016 Share Posted December 12, 2016 (edited) Well i dont really know lua or java, and so many year now since i did some programming, but the bases are kinda the same, so thanks Bot, for naming what i was pointing out Edited December 12, 2016 by EUDOXIO Link to comment Share on other sites More sharing options...
nolanri Posted December 12, 2016 Author Share Posted December 12, 2016 I still have a problem though. since ISWorldObjectContextMenu already creates a menu when you right click on the ground. I can't just create a new menu, but i have to add to that menu that gets created. In my code in first post for item context menu, this uses an event that returns the context object. So I dont know how I can fetch the context menu object that gets created on right clicks on the ground so that I can add an option to it. Link to comment Share on other sites More sharing options...
EnigmaGrey Posted December 12, 2016 Share Posted December 12, 2016 Take a look at ISBuildMenu.lua to see how the game handles populating this menu. It uses this event: Events.OnFillWorldObjectContextMenu.Add(blarg:arg) which provides the menu as a parameter. New items and sub-menus can then be added to it when it's called. nolanri 1 Link to comment Share on other sites More sharing options...
nolanri Posted December 12, 2016 Author Share Posted December 12, 2016 12 minutes ago, Butter Bot said: Take a look at ISBuildMenu.lua to see how the game handles populating this menu: function blarg.arg(player, context, worldobjects, test) base_menu = context:addOption("Option name", worldobjects, nil) . . . end Events.OnFillWorldObjectContextMenu.Add(blarg.arg) I am now a believer that you are who you say you are. EUDOXIO 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now