Apo Posted June 5, 2016 Share Posted June 5, 2016 hi how to disabel(cancel) all command or command name( "heal" and "stat" and "dance" etc ...) in the faction sleep function sleep(thePlayer) local phealth = getElementHealth( thePlayer ) if ( phealth < 100 ) then if not isPedInVehicle( thePlayer ) then if getElementData( thePlayer, "sleep" ) ~= "activated" then setPedAnimation( thePlayer, "CRACK", "crckidle2", -1, true, false, true ) outputChatBox( "Sleeping Mode: On!", thePlayer, 255, 255, 0 ) setElementData( thePlayer, "sleep", "activated" ) toggleControl( thePlayer, "forward", false ) toggleControl( thePlayer, "jump", false ) toggleControl( thePlayer, "aim_weapon", false ) toggleControl( thePlayer, "fire", false ) else outputChatBox( "You can't sleep while sleeping O_o", thePlayer, 255, 0, 0 ) end else outputChatBox( "You can't sleep in a vehicle!", thePlayer, 255, 0, 0 ) end else outputChatBox( "You can't sleep while your health is full!", thePlayer, 255, 0, 0 ) end end addCommandHandler( "sleep", sleep ) Link to comment
ViRuZGamiing Posted June 5, 2016 Share Posted June 5, 2016 function sleep(thePlayer) addEventHandler("onPlayerCommand", thePlayer, function() cancelEvent() end) local phealth = getElementHealth( thePlayer ) if ( phealth < 100 ) then if not isPedInVehicle( thePlayer ) then if getElementData( thePlayer, "sleep" ) ~= "activated" then setPedAnimation( thePlayer, "CRACK", "crckidle2", -1, true, false, true ) outputChatBox( "Sleeping Mode: On!", thePlayer, 255, 255, 0 ) setElementData( thePlayer, "sleep", "activated" ) toggleControl( thePlayer, "forward", false ) toggleControl( thePlayer, "jump", false ) toggleControl( thePlayer, "aim_weapon", false ) toggleControl( thePlayer, "fire", false ) else outputChatBox( "You can't sleep while sleeping O_o", thePlayer, 255, 0, 0 ) end else outputChatBox( "You can't sleep in a vehicle!", thePlayer, 255, 0, 0 ) end else outputChatBox( "You can't sleep while your health is full!", thePlayer, 255, 0, 0 ) end end addCommandHandler( "sleep", sleep ) Try this you gotta remove the event handler on leaving the faction tho Link to comment
Apo Posted June 5, 2016 Author Share Posted June 5, 2016 yes worked for bindkey? disable all bindkey Link to comment
ViRuZGamiing Posted June 5, 2016 Share Posted June 5, 2016 not 100% if it cancels bindKey's but try this addEventHandler("onClientKey", thePlayer, function() cancelEvent() end EDIT: It will work If this event is canceled, then all GTA and MTA binds, bound to the canceled key, won't be triggered Link to comment
Apo Posted June 5, 2016 Author Share Posted June 5, 2016 not work addEventHandler("onClientKey", thePlayer, function() cancelEvent() end Link to comment
Apo Posted June 5, 2016 Author Share Posted June 5, 2016 yes fixed but how to active all key and command? Link to comment
ViRuZGamiing Posted June 5, 2016 Share Posted June 5, 2016 give the function a name and remove the event handler by function name Link to comment
Apo Posted June 5, 2016 Author Share Posted June 5, 2016 how to active bindkey and command in the faction function getup(thePlayer) if getElementData( thePlayer, "sleep") == "activated" then setPedAnimation( thePlayer, nil, nil ) outputChatBox( "Sleeping Mode: Off!", thePlayer, 255, 0, 0 ) setElementData( thePlayer, "sleep", "deactivated" ) toggleControl( thePlayer, "forward", true ) toggleControl( thePlayer, "jump", true ) toggleControl( thePlayer, "aim_weapon", true ) toggleControl( thePlayer, "fire", true ) else outputChatBox( "You aren't sleeping!", thePlayer, 255, 0, 0 ) end end addCommandHandler( "getup", getup ) Link to comment
ViRuZGamiing Posted June 5, 2016 Share Posted June 5, 2016 as I said remove the event handlers, function cancelEventFunc() cancelEvent() end function sleep(thePlayer) addEventHandler("onPlayerCommand", thePlayer, cancelEventFunc) addEventHandler("onClientKey", thePlayer, cancelEventFunc) local phealth = getElementHealth( thePlayer ) if ( phealth < 100 ) then if not isPedInVehicle( thePlayer ) then if getElementData( thePlayer, "sleep" ) ~= "activated" then setPedAnimation( thePlayer, "CRACK", "crckidle2", -1, true, false, true ) outputChatBox( "Sleeping Mode: On!", thePlayer, 255, 255, 0 ) setElementData( thePlayer, "sleep", "activated" ) toggleControl( thePlayer, "forward", false ) toggleControl( thePlayer, "jump", false ) toggleControl( thePlayer, "aim_weapon", false ) toggleControl( thePlayer, "fire", false ) else outputChatBox( "You can't sleep while sleeping O_o", thePlayer, 255, 0, 0 ) end else outputChatBox( "You can't sleep in a vehicle!", thePlayer, 255, 0, 0 ) end else outputChatBox( "You can't sleep while your health is full!", thePlayer, 255, 0, 0 ) end end addCommandHandler( "sleep", sleep ) function getup(thePlayer) removeEventHandler("onPlayerCommand", thePlayer, cancelEventFunc) removeEventHandler("onClientKey", thePlayer, cancelEventFunc) if getElementData( thePlayer, "sleep") == "activated" then setPedAnimation( thePlayer, nil, nil ) outputChatBox( "Sleeping Mode: Off!", thePlayer, 255, 0, 0 ) setElementData( thePlayer, "sleep", "deactivated" ) toggleControl( thePlayer, "forward", true ) toggleControl( thePlayer, "jump", true ) toggleControl( thePlayer, "aim_weapon", true ) toggleControl( thePlayer, "fire", true ) else outputChatBox( "You aren't sleeping!", thePlayer, 255, 0, 0 ) end end addCommandHandler( "getup", getup ) Link to comment
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