Jump to content

help


Apo

Recommended Posts

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
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

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

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

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...