'~DaLesTe^' Posted April 9, 2020 Share Posted April 9, 2020 Spoiler stime = false function unblockl(source) stime = false toggleControl (source,"fire", true) setElementAlpha(source, 255) end ----how to cancel client player damage? function blockl(source) stime = true toggleControl (source,"fire", false) setElementAlpha(source, 100) triggerClientEvent(client, "onClientPlayerDamage", resourceRoot) end function fire(source) stime = false end addEventHandler("onPlayerWeaponFire", root, fire) local CommandSpam , AntiTeleport , AfterDamageTeleportTime = {} , {} , 5000 teleportes = { {"aa", 1415,5,1000.4,135, "Sample text"} , } addEventHandler ( "onPlayerCommand" , root , function ( Command ) if getElementDimension ( source ) == 0 and getElementInterior ( source ) == 0 then for _ , Value in pairs ( teleportes ) do if Value [ 1 ] == Command then if not AntiTeleport [ source ] then if not CommandSpam [ source ] then local Vehicle = getPedOccupiedVehicle ( source ) if Vehicle then setElementPosition ( Vehicle , Value [ 2 ] , Value [ 3 ] , Value [ 4 ] ) else setElementPosition ( source , Value [ 2 ] , Value [ 3 ] , Value [ 4 ] ) end if Value [ 5 ] then stime = true ----- ok setTimer(blockl,100,1,source) ----- after teleport, "bloclk" cancel the playerdamage to prevent "respawn kill" setTimer(unblockl,5000,1,source) ----- "unblock" after 5s cancel the "respawnkill protection" and normalize the player protection local playertag = getElementData ( source , "gang.tag" ) or "" exports["killmessages2"]:outputMessage ( "#ffffff" ..playertag.. "".. getPlayerName(source) .."#ffffff(ID:" .. (getPlayerID(source) or "???") .. ")#AC0000 Foi Para "..Value [ 5].." #ffffff(/" ..Value [ 1].. ") ", root, 0, 255, 0, true ) outputChatBox( "#AC0000[TELE] #ffffff" ..playertag.. "".. getPlayerName(source) .."(ID:" .. (getPlayerID(source) or "???") .. ")#c4c4c4 você foi para /" ..Value [ 1].. "", source, 0, 255, 0, true ) end CommandSpam [ source ] = setTimer ( function ( source ) CommandSpam [ source ] = false end , 5000 , 1 , source ) else exports["killmessages2"]:outputMessage ( "Aguarde ".. (CommandSpam [ source ] and math.floor ( getTimerDetails ( CommandSpam [ source ] ) / 1000 ) or 5 ) .." segundos para se teleportar novamente!", source) end else exports["killmessages2"]:outputMessage ( "Não é possivel teleportar em combate" , source , 255 , 0 , 0 , true ) end break end end end end ) addEventHandler ( "onPlayerDamage" , root , function ( ) if AntiTeleport [ source ] and isTimer ( AntiTeleport [ source ] ) then resetTimer ( AntiTeleport [ source ] ) return end AntiTeleport [ source ] = setTimer ( function ( source ) AntiTeleport [ source ] = false end , AfterDamageTeleportTime , 1 , source ) end ) function getPlayerFromID(id) return call(getResourceFromName("game_id2"), "getPlayerFromID", tonumber(id)) end function getPlayerID(player) return getElementData(player,"id") end Serverside ^ Spoiler addEvent ( "onClientPlayerDamage", true ) addEventHandler("onClientPlayerDamage", recourceRoot, function stopSK (attacker) if stime == true then cancelEvent() end end ) Clientside ^ I am trying to cancel the damage after the player teleports, after he teleports, to be immune to damage for 5 seconds, and after 5 seconds to return to normal. Link to comment
Infinity-War Posted April 9, 2020 Share Posted April 9, 2020 when player transport : -- # Server Side . triggerClientEvent ( Element , 'CancelDamage;' , Element ) Add this in client side : addEvent ( 'CancelDamage;' , true ) addEventHandler ( 'CancelDamage;' , root , function ( ) addEventHandler ( 'onClientPlayerDamage' , localPlayer , cancelEvent ) end ) Link to comment
'~DaLesTe^' Posted April 9, 2020 Author Share Posted April 9, 2020 14 hours ago, Infinity-War said: when player transport : -- # Server Side . triggerClientEvent ( Element , 'CancelDamage;' , Element ) Add this in client side : addEvent ( 'CancelDamage;' , true ) addEventHandler ( 'CancelDamage;' , root , function ( ) addEventHandler ( 'onClientPlayerDamage' , localPlayer , cancelEvent ) end ) not work Serverside: Spoiler stime = false function unblockl(source) stime = false toggleControl (source,"fire", true) setElementAlpha(source, 255) end function blockl(source) stime = true toggleControl (source,"fire", false) setElementAlpha(source, 100) triggerClientEvent ( Element , 'CancelDamage;' , Element ) end function fire(source) stime = false end addEventHandler("onPlayerWeaponFire", root, fire) local CommandSpam , AntiTeleport , AfterDamageTeleportTime = {} , {} , 5000 teleportes = { {"aa", 1415,5,1000.4,135, "Sample text"} , } addEventHandler ( "onPlayerCommand" , root , function ( Command ) if getElementDimension ( source ) == 0 and getElementInterior ( source ) == 0 then for _ , Value in pairs ( teleportes ) do if Value [ 1 ] == Command then if not AntiTeleport [ source ] then if not CommandSpam [ source ] then local Vehicle = getPedOccupiedVehicle ( source ) if Vehicle then setElementPosition ( Vehicle , Value [ 2 ] , Value [ 3 ] , Value [ 4 ] ) else setElementPosition ( source , Value [ 2 ] , Value [ 3 ] , Value [ 4 ] ) end if Value [ 5 ] then stime = true setTimer(blockl,100,1,source) setTimer(unblockl,5000,1,source) local playertag = getElementData ( source , "gang.tag" ) or "" exports["killmessages2"]:outputMessage ( "#ffffff" ..playertag.. "".. getPlayerName(source) .."#ffffff(ID:" .. (getPlayerID(source) or "???") .. ")#AC0000 Foi Para "..Value [ 5].." #ffffff(/" ..Value [ 1].. ") ", root, 0, 255, 0, true ) outputChatBox( "#AC0000[TELE] #ffffff" ..playertag.. "".. getPlayerName(source) .."(ID:" .. (getPlayerID(source) or "???") .. ")#c4c4c4 você foi para /" ..Value [ 1].. "", source, 0, 255, 0, true ) end CommandSpam [ source ] = setTimer ( function ( source ) CommandSpam [ source ] = false end , 5000 , 1 , source ) else --- outputChatBox ( "Aguarde ".. (CommandSpam [ source ] and math.floor ( getTimerDetails ( CommandSpam [ source ] ) / 1000 ) or 5 ) .." segundos para se teleportar novamente!", source) exports["killmessages2"]:outputMessage ( "Aguarde ".. (CommandSpam [ source ] and math.floor ( getTimerDetails ( CommandSpam [ source ] ) / 1000 ) or 5 ) .." segundos para se teleportar novamente!", source) end else --- outputChatBox ( "Não é possivel teleportar em combate" , source , 255 , 0 , 0 , true ) exports["killmessages2"]:outputMessage ( "Não é possivel teleportar em combate" , source , 255 , 0 , 0 , true ) end break end end end end ) addEventHandler ( "onPlayerDamage" , root , function ( ) if AntiTeleport [ source ] and isTimer ( AntiTeleport [ source ] ) then resetTimer ( AntiTeleport [ source ] ) return end AntiTeleport [ source ] = setTimer ( function ( source ) AntiTeleport [ source ] = false end , AfterDamageTeleportTime , 1 , source ) end ) function getPlayerFromID(id) return call(getResourceFromName("game_id2"), "getPlayerFromID", tonumber(id)) end function getPlayerID(player) return getElementData(player,"id") end Clientside: Spoiler addEvent ( 'CancelDamage;' , true ) addEventHandler ( 'CancelDamage;' , root , function ( ) cancelEvent() addEventHandler ( 'onClientPlayerDamage' , localPlayer , cancelEvent ) end ) the player still takes damage after teleporting Link to comment
'~DaLesTe^' Posted April 10, 2020 Author Share Posted April 10, 2020 i make, thanks for help. Solved 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