Jump to content

[Help]How To Disable CancelEvent() ?


Perfect

Recommended Posts

Hi, I was making a script and I have came to a Problem, when i want to Disable/Reverse/Off cancelEvent().

Here is My Script:-

function stopKnifeKill ( attacker, weapon, bodypart ) 
    if ( weapon == 4 ) then 
        cancelEvent() 
        outputChatBox('#00ff0Server: Knife Godmode On!',source,0,255,0) 
    else 
        outputChatBox('#00ff00Server: Knife Godmode Off!',source,255,0,0,true) 
        return false -- What should i do here to Disable cancelEvent ? 
    end 
end 
addEventHandler ( "onClientPlayerDamage", root, stopKnifeKill ) 
addCommandHandler("kinfe",stopKnifeKill) 

Link to comment

If i understand correctly, this is what you looking for:

-- Client Side -- 
  
addCommandHandler("kinfe", 
function() 
    if not kinfeKill then 
        outputChatBox("#00ff0Server: Knife Godmode On!", 0, 255, 0, true) 
    else 
        outputChatBox("#00ff00Server: Knife Godmode Off!", 255, 0, 0, true) 
    end 
    kinfeKill = not kinfeKill 
end) 
  
function stopKnifeKill() 
    if kinfeKill then 
        cancelEvent() 
    end 
end 
addEventHandler("onClientPlayerStealthKill", localPlayer, stopKnifeKill) 

Link to comment

Sorry as i didn't describe correctly what i want to do.

Ok, I want to disable/enable knife kills by command /knife.

By knife kills i mean player killing each other with knife.

When knife kill is disable player can't kill with knife (cancelEvent onplayerdamage),

When knife kill is enable player can kill with knife.(get event back onplayerdamage).

If i understand correctly, this is what you looking for:
-- Client Side -- 
  
addCommandHandler("kinfe", 
function() 
    if not kinfeKill then 
        outputChatBox("#00ff0Server: Knife Godmode On!", 0, 255, 0, true) 
    else 
        outputChatBox("#00ff00Server: Knife Godmode Off!", 255, 0, 0, true) 
    end 
    kinfeKill = not kinfeKill 
end) 
  
function stopKnifeKill() 
    if kinfeKill then 
        cancelEvent() 
    end 
end 
addEventHandler("onClientPlayerStealthKill", localPlayer, stopKnifeKill) 

Sorry, can you please define stealth kill ?

And as i can't see knife id there, i think it will not disable players killing with knife with 1 click(backside-neck)

Link to comment

can you please solve this one ?

function fire() 
    setPedOnFire(source,true) 
    setElementHealth(source,true) 
end 
function fireme() 
    local stimer = setTimer(fire,1000,0) 
end 
function unfire() 
    if isTimer ( stimer ) then  
    killTimer ( stimer )  
    end 
end 
addCommandHandler("fireme",fireme) 
addCommandHandler("unfireme",unfire) 
  

errors at setPedOnFire and setPedHealth

Link to comment
-- Client Side -- 
  
function fire() 
    setPedOnFire(localPlayer,true) 
    setElementHealth(localPlayer,Here-Must-Be-Number) -- only number no bool. 
end 
function fireme() 
    local stimer = setTimer(fire,1000,0) 
end 
function unfire() 
    if isTimer ( stimer ) then 
    killTimer ( stimer ) 
    end 
end 
addCommandHandler("fireme",fireme) 
addCommandHandler("unfireme",unfire) 

Link to comment
  • 2 years later...
On 12/29/2013 at 8:49 PM, TAPL said:

If i understand correctly, this is what you looking for:


-- Client Side -- 
  
addCommandHandler("kinfe", 
function() 
    if not kinfeKill then 
        outputChatBox("#00ff0Server: Knife Godmode On!", 0, 255, 0, true) 
    else 
        outputChatBox("#00ff00Server: Knife Godmode Off!", 255, 0, 0, true) 
    end 
    kinfeKill = not kinfeKill 
end) 
  
function stopKnifeKill() 
    if kinfeKill then 
        cancelEvent() 
    end 
end 
addEventHandler("onClientPlayerStealthKill", localPlayer, stopKnifeKill) 
 

 

It good works but how can i add this mode of disableknife in f1 panel? Can u suggest me

For example like this- jetpack option in freeroam same likethat disableknife-on or off 

Link to comment
2 minutes ago, FaHaD said:

 

Actually it's not a radio button it's a check-box use : 

 

guiCheckBoxGetSelected

 

Instead of guiRadioButtonGetSelected

 

Yea bro its guicheck but i need to know what is cilent and server side ? Wt it mean can u tell me

4 minutes ago, FaHaD said:

 

Actually it's not a radio button it's a check-box use : 

 

guiCheckBoxGetSelected

 

Instead of guiRadioButtonGetSelected

 

GUI create button or checkbox?

Link to comment
Just now, Khadeer143 said:

Yea bro its guicheck but i need to know what is cilent and server side ? Wt it mean can u tell me

 

Go to the freeroam resource open fr_client.lua go to line 1522 and add this under fall of bike :

 

{ 'chk',id = 'StealthKill',text = 'Disable Knifing',onclick = toggleStealthKill },
{ 'br' },

 

 

And in the last of the file the same file fr_client.lua use this function to toggleStealthKill :

 

---------------------------
-- Knifing toggle
---------------------------
function toggleStealthKill (	)
	if guiCheckBoxGetSelected ( getControl ( wndMain,'StealthKill' ) ) and not kinfeKill then
				outputChatBox ( 'Server: Knife Godmode On!', 0,255,0 ) 
		else
				outputChatBox ( 'Server: Knife Godmode Off!',255,0,0 )  
			end
	kinfeKill  = not kinfeKill 
end
addEventHandler ( 'onClientPlayerStealthKill',localPlayer,
	function ( )
		if kinfeKill then
			cancelEvent (	)
		end
	end
)

 

 

Try this.

  • Thanks 1
Link to comment
On 12/30/2013 at 2:40 AM, TAPL said:

-- Client Side -- 
  
function fire() 
    setPedOnFire(localPlayer,true) 
    setElementHealth(localPlayer,Here-Must-Be-Number) -- only number no bool. 
end 
function fireme() 
    local stimer = setTimer(fire,1000,0) 
end 
function unfire() 
    if isTimer ( stimer ) then 
    killTimer ( stimer ) 
    end 
end 
addCommandHandler("fireme",fireme) 
addCommandHandler("unfireme",unfire) 
 

 

Wet is this fireme? Script

Link to comment
  • 10 months later...
On 10/26/2016 at 04:02, iPrestege said:

 

Go to the freeroam resource open fr_client.lua go to line 1522 and add this under fall of bike :

 


{ 'chk',id = 'StealthKill',text = 'Disable Knifing',onclick = toggleStealthKill },
{ 'br' },

 

 

And in the last of the file the same file fr_client.lua use this function to toggleStealthKill :

 


---------------------------
-- Knifing toggle
---------------------------
function toggleStealthKill (	)
	if guiCheckBoxGetSelected ( getControl ( wndMain,'StealthKill' ) ) and not kinfeKill then
				outputChatBox ( 'Server: Knife Godmode On!', 0,255,0 ) 
		else
				outputChatBox ( 'Server: Knife Godmode Off!',255,0,0 )  
			end
	kinfeKill  = not kinfeKill 
end
addEventHandler ( 'onClientPlayerStealthKill',localPlayer,
	function ( )
		if kinfeKill then
			cancelEvent (	)
		end
	end
)

 

 

Try this.

i added on cilent side but nothing happen no errors and no freeroam panel i cant spawn freeroam panel 

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