Jump to content

help


Apo

Recommended Posts

Posted

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 ) 

only god (الله) اشهد ان لا اله الا الله واشهد ان محمد رسول الله

Posted
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

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted

yes worked :x

for bindkey?

disable all bindkey

only god (الله) اشهد ان لا اله الا الله واشهد ان محمد رسول الله

Posted

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

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted

not work

addEventHandler("onClientKey", thePlayer, function()

cancelEvent()

end

only god (الله) اشهد ان لا اله الا الله واشهد ان محمد رسول الله

Posted

yes fixed :x

but how to active all key and command?

only god (الله) اشهد ان لا اله الا الله واشهد ان محمد رسول الله

Posted

give the function a name and remove the event handler by function name

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted

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 ) 

only god (الله) اشهد ان لا اله الا الله واشهد ان محمد رسول الله

Posted

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 ) 

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...