3B00DG4MER Posted March 26, 2014 Posted March 26, 2014 Hello,today I've made script which if player within colshap Cancel Event of Damage and Wasted All Things Works only Cancel Event Please Reply Fast function protect() if isElementWithinColShape ( localPlayer, CSSZ1 ) then local sWidth,sHeight = guiGetScreenSize() -- The variables dxDrawText("Protected Area Comp",sWidth*0.668, sHeight*0.952, sWidth*0.715, sHeight*0.997,tocolor(0,255,0,255),1.0,"pricedown","left","bottom",false,false,false) addEventHandler("onClientPedDamage", getRootElement(),function() cancelEvent() end) addEventHandler("onClientPedWasted", getRootElement(),function() cancelEvent() end) end end addEventHandler ( "onClientRender", root, protect )
xXMADEXx Posted March 26, 2014 Posted March 26, 2014 Try using this, although, I didn't test it. -- Server: -- create your colshape function onColEvent( p ) if ( getElementType ( p ) == "vehicle" ) then p = getVehicleOccupant ( p ) end if ( not isElement ( p ) ) then return end if ( eventName == "onColShapeHit" ) then setElementData ( p, "isClientInProtectedArea", true ) else setElementData ( p, "isClientInProtectedArea", false ) end triggerClientEvent ( p, "onClientProtectedAreaEventChange", p, eventName ) end addEventHandler ( "onColShapeHit", CSSZ1, onColEvent ) addEventHandler ( "onColShapeLeave", CSSZ1, onColEvent ) -- client addEventHandler ( "onClientPlayerDamage", root, function ( ) if ( getElementData ( source, "isClientInProtectedArea" ) ) then cancelEvent ( ) end end ) addEvent ( "onClientProtectedAreaEventChange", true ) addEventHandler ( "onClientProtectedAreaEventChange", root, function ( e ) if ( e == "onColShapeHit" and not isRender ) then render = true addEventHandler ( "onClientRender", root, onClientRender ) elseif ( e == "onColShapeLeave" ) then render = false end end ) local isRender = false local sWidth,sHeight = guiGetScreenSize() function onClientRender ( ) if ( not isRender ) then removeEventHandler ( "onClientRender", root, onClientRender ) end dxDrawText("Protected Area Comp",sWidth*0.668, sHeight*0.952, sWidth*0.715, sHeight*0.997,tocolor(0,255,0,255),1.0,"pricedown","left","bottom",false,false,false) end
3B00DG4MER Posted March 27, 2014 Author Posted March 27, 2014 Try using this, although, I didn't test it. -- Server: -- create your colshape function onColEvent( p ) if ( getElementType ( p ) == "vehicle" ) then p = getVehicleOccupant ( p ) end if ( not isElement ( p ) ) then return end if ( eventName == "onColShapeHit" ) then setElementData ( p, "isClientInProtectedArea", true ) else setElementData ( p, "isClientInProtectedArea", false ) end triggerClientEvent ( p, "onClientProtectedAreaEventChange", p, eventName ) end addEventHandler ( "onColShapeHit", CSSZ1, onColEvent ) addEventHandler ( "onColShapeLeave", CSSZ1, onColEvent ) -- client addEventHandler ( "onClientPlayerDamage", root, function ( ) if ( getElementData ( source, "isClientInProtectedArea" ) ) then cancelEvent ( ) end end ) addEvent ( "onClientProtectedAreaEventChange", true ) addEventHandler ( "onClientProtectedAreaEventChange", root, function ( e ) if ( e == "onColShapeHit" and not isRender ) then render = true addEventHandler ( "onClientRender", root, onClientRender ) elseif ( e == "onColShapeLeave" ) then render = false end end ) local isRender = false local sWidth,sHeight = guiGetScreenSize() function onClientRender ( ) if ( not isRender ) then removeEventHandler ( "onClientRender", root, onClientRender ) end dxDrawText("Protected Area Comp",sWidth*0.668, sHeight*0.952, sWidth*0.715, sHeight*0.997,tocolor(0,255,0,255),1.0,"pricedown","left","bottom",false,false,false) end There is Bug When Col Shape Leave Please Fix FAST
3B00DG4MER Posted March 27, 2014 Author Posted March 27, 2014 Lol, man. What bug? Any errors in debug? There is Bug When Col Shape Leave
WhoAmI Posted March 27, 2014 Posted March 27, 2014 But what bug? USE BRAIN. Any errors? Don't act like stupid.
3B00DG4MER Posted March 27, 2014 Author Posted March 27, 2014 But what bug? USE BRAIN. Any errors? Don't act like stupid. There is no error !!!!!!!! But when You leave ColShape the Dx Text won't hide !!
Moderators IIYAMA Posted March 27, 2014 Moderators Posted March 27, 2014 -- Server: -- create your colshape function onColEvent( p ) if ( getElementType ( p ) == "vehicle" ) then p = getVehicleOccupant ( p ) end if ( not isElement ( p ) ) then return end if ( eventName == "onColShapeHit" ) then setElementData ( p, "isClientInProtectedArea", true ) else setElementData ( p, "isClientInProtectedArea", false ) end triggerClientEvent ( p, "onClientProtectedAreaEventChange", p, eventName ) end addEventHandler ( "onColShapeHit", CSSZ1, onColEvent ) addEventHandler ( "onColShapeLeave", CSSZ1, onColEvent ) -- client addEventHandler ( "onClientPlayerDamage", root, function ( ) if ( getElementData ( source, "isClientInProtectedArea" ) ) then cancelEvent ( ) end end ) addEvent ( "onClientProtectedAreaEventChange", true ) addEventHandler ( "onClientProtectedAreaEventChange", root, function ( e ) if ( e == "onColShapeHit" and not isRender ) then [color=#FF0000] render = true[/color] addEventHandler ( "onClientRender", root, onClientRender ) elseif ( e == "onColShapeLeave" ) then [color=#FF0000] render = false[/color] end end ) [color=#FF8000]local[/color] [color=#FF0000]isRender = false[/color] local sWidth,sHeight = guiGetScreenSize() function onClientRender ( ) if ( not [color=#FF0000]isRender[/color] ) then removeEventHandler ( "onClientRender", root, onClientRender ) end dxDrawText("Protected Area Comp",sWidth*0.668, sHeight*0.952, sWidth*0.715, sHeight*0.997,tocolor(0,255,0,255),1.0,"pricedown","left","bottom",false,false,false) end It is obviously. The names don't match and the variable should be on top of the code (local variables).
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