Jump to content

Add a context option for right clicking on player


nolanri

Recommended Posts

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

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

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.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...