zUsername Posted February 25, 2016 Share Posted February 25, 2016 How can I check player press CTRL key ? I've tried doer.components.playercontroller:IsControlPressed(GLOBAL.CONTROL_FORCE_STACK) but it's not work in GLOBAL.ACTIONS.DROP.fn but it's work in GLOBAL.ACTIONS.DROP.strfn. Here is my code: local oldactiondrop = GLOBAL.ACTIONS.DROP.fn GLOBAL.ACTIONS.DROP.fn = function(act) if act.invobject:HasTag("trap") and act.doer.components.playercontroller:IsControlPressed(GLOBAL.CONTROL_FORCE_STACK) then -----------------NOT WORK----------------- return act.doer.components.inventory ~= nil and act.doer.components.inventory:DropItem(act.invobject,true,false,act.pos) or nil end return oldactiondrop(act) end local oldactiondropstr = GLOBAL.ACTIONS.DROP.strfn GLOBAL.ACTIONS.DROP.strfn = function(act) if act.invobject:HasTag("trap") and act.doer.components.playercontroller:IsControlPressed(GLOBAL.CONTROL_FORCE_STACK) then -----------------WORK----------------- return "DROPALL" end return oldactiondropstr(act) end Link to comment https://forums.kleientertainment.com/forums/topic/64748-help-checking-client-press-key/ Share on other sites More sharing options...
Muche Posted February 25, 2016 Share Posted February 25, 2016 I'd guess that's because actions (i.e. their fn) run on the server (thus don't have access to player's controller), but actions' descriptions (i.e. their strfn) run on the client. If am I not mistaken, widgets/invslot does this modifier key distinguishing on the client as well and then sends different RPCs based on what should be done (see prefabs/container_classified.lua). If you are creating you own actions+component actions, you could try checking for pressed CTRL in component action and based on CTRL status add different action into the actions table. Link to comment https://forums.kleientertainment.com/forums/topic/64748-help-checking-client-press-key/#findComment-726652 Share on other sites More sharing options...
zUsername Posted February 26, 2016 Author Share Posted February 26, 2016 Ok Thanks you @Muche. Problem solved. Link to comment https://forums.kleientertainment.com/forums/topic/64748-help-checking-client-press-key/#findComment-726979 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