FlyingSpoon Posted April 19, 2015 Share Posted April 19, 2015 How can I add the event back? addEventHandler ( "onClientPlayerDamage", root, function() cancelEvent() end) I know how to cancel but how can I add it back? Link to comment
xXMADEXx Posted April 19, 2015 Share Posted April 19, 2015 Give the function an name, then just remove the event handler for it. Here's an example: addEventHandler ( 'onClientPlayerDamage', root, cancelEvent ); setTimer ( removeEventHandler, 3000, 1, 'onClientPlayerDamage', root, cancelEvent ); Link to comment
#RooTs Posted April 19, 2015 Share Posted April 19, 2015 try this server.lua function togglestaffMode(thePlayer) if hasObjectPermissionTo(thePlayer,"general.adminpanel",false) then if getElementData(thePlayer,"invincible") then setElementData(thePlayer,"invincible",false) outputChatBox("member of team." .. getPlayerName(thePlayer) .. " Is unprotected!", getRootElement(), 255, 255, 255,true ) else setElementData(thePlayer,"invincible",true) outputChatBox("member of team." .. getPlayerName(thePlayer) .. " Is protected!", getRootElement(), 255, 255, 255,true ) end end end addCommandHandler("GodMode",togglestaffMode) client.lua addEventHandler ( "onClientPlayerDamage",root, function () if getElementData(source,"invincible") then cancelEvent() end end) addEventHandler("onClientPlayerStealthKill",localPlayer, function (targetPlayer) if getElementData(targetPlayer,"invincible") then cancelEvent() end end) Link to comment
FlyingSpoon Posted April 19, 2015 Author Share Posted April 19, 2015 function dontTryBug(element) if element == localPlayer then if ( guiGetVisible ( oneMinute ) ~= true ) then if source == injectMarker then addEventHandler ("onClientRender", root, dxMenu ) guiSetVisible ( injectBtn, true ) showCursor ( true ) addEventHandler ( "onClientPlayerDamage", root, function() cancelEvent() end) else if timeRem ~= "Time Remaining : 0 Seconds" then if source == injectMarker then showCursor ( false ) guiSetVisible ( injectBtn, false ) removeEventHandler ("onClientRender", root, dxMenu ) end end end end end end addEventHandler("onClientMarkerHit", getRootElement(), dontTryBug) See I added the cancel event, now I want to remove it ! Link to comment
RenanPG Posted April 19, 2015 Share Posted April 19, 2015 Use xXMADEXx's example, that you can add and remove cancelEvent. Link to comment
#RooTs Posted April 19, 2015 Share Posted April 19, 2015 Use xXMADEXx's example, that you can add and remove cancelEvent. got it. the did he want to do very nice Link to comment
RenanPG Posted April 19, 2015 Share Posted April 19, 2015 Use xXMADEXx's example, that you can add and remove cancelEvent. got it. the did he want to do very nice What do you mean? Link to comment
FlyingSpoon Posted April 20, 2015 Author Share Posted April 20, 2015 function one() guiSetText ( oneMinute, "Damage On") setTimer ( two, 1000, 1) addEventHandler ( 'onClientPlayerDamage', root, cancelEvent ); end function two() guiSetText ( oneMinute, "Damage Off") setTimer ( one, 1000, 1) setTimer ( removeEventHandler, 1000, 1, 'onClientPlayerDamage', root, cancelEvent ); end Bad argument @ 'removeEventHandler' [Expected function at argument 3, got nil] Link to comment
Dimos7 Posted April 20, 2015 Share Posted April 20, 2015 function one() guiSetText(oneMinute, "Damage On") setTimer(two, 1000, 1) cancelEvent() end addEventHandler("onClientPlayerDamage", root, one) function two() guiSetText(oneMinute, "Damage Off") setTimer(one, 1000, 1) cancelEvent() end removeEventHandler("onClientPlayerDamage", root, two) Link to comment
ALw7sH Posted April 20, 2015 Share Posted April 20, 2015 function one() guiSetText(oneMinute, "Damage On") setTimer(two, 1000, 1) cancelEvent() end addEventHandler("onClientPlayerDamage", root, one) function two() guiSetText(oneMinute, "Damage Off") setTimer(one, 1000, 1) cancelEvent() end removeEventHandler("onClientPlayerDamage", root, two) There's no event attached to function two, so why you are using removeEventHandler lol --- You dont really need to delete the event handler just use element data function godMode() if getElementData(source,"godMode") == true then cancelEvent() end end addEventHandler("onClientPlayerDamage",root,godMode) Link to comment
FlyingSpoon Posted April 20, 2015 Author Share Posted April 20, 2015 So how do I add the event back in then? In my function two() Link to comment
Dimos7 Posted April 20, 2015 Share Posted April 20, 2015 function one() guiSetText(oneMinute, "Damage On") setTimer(two, 1000, 1) cancelEvent() addEventHandler("onClientPlayerDamage", root, one) end function two() guiSetText(oneMinute, "Damage Off") setTimer(one, 1000, 1) removeEventHandler("onClientPlayerDamage", root, one) end Link to comment
FlyingSpoon Posted April 20, 2015 Author Share Posted April 20, 2015 Huh? But I dont want the onClientPlayerDamage to be on I want it to be off. You functions adds the client player damage. Link to comment
WhoAmI Posted April 20, 2015 Share Posted April 20, 2015 Tell me exactly what you want to do. Link to comment
FlyingSpoon Posted April 20, 2015 Author Share Posted April 20, 2015 Well I have a little timer, like 10 Seconds, And when the 10 Seconds start, It adds in god mode, When 10 seconds stop, It removes god mode. My script is like this, function hundredtsixt() guiSetText ( oneMinute, "GodMode On!") setTimer ( hundredtsevt, 1000, 1) --- Starts the god mode end function hundredtsevt() guiSetText ( oneMinute, "GodMode Off!") setTimer ( hundredteht, 1000, 1) --- Stops GodMode end Link to comment
WhoAmI Posted April 20, 2015 Share Posted April 20, 2015 function hundredtsixt ( ) guiSetText ( oneMinute, "GodMode On!" ); setTimer ( setElementData, 1000, 1, localPlayer, "godmode", true ); end function hundredtsevt ( ) guiSetText ( oneMinute, "GodMode Off!" ); setTimer ( setElementData, 1000, 1, localPlayer, "godmode", false ); end addEventHandler ( "onClientPlayerDamage", root, function ( ) if ( getElementData ( source, "godmode" ) ) then cancelEvent ( ); end end ); 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