goofie88 Posted February 15, 2013 Posted February 15, 2013 Hello everyone I have a question, how to make so theres no damage when a player enters a marker? I was confused because onPlayerDamage and onMarkerHit are 2 different events how could I combine them?
TAPL Posted February 15, 2013 Posted February 15, 2013 isElementWithinMarker cancelEvent Event: "onClientPlayerDamage"
Baseplate Posted February 15, 2013 Posted February 15, 2013 isElementWithinMarker So theMarker = createMarker(x, y, z, "cylinder") addEventHandler("onClientPlayerDamage", root, function(attacker, weapon, bodypart, loss) if (isElementWithinMarker(source, theMarker)) then cancelEvent() end end )
Baseplate Posted February 15, 2013 Posted February 15, 2013 No problem, does it work?? make sure it's client-sided
goofie88 Posted February 15, 2013 Author Posted February 15, 2013 Yes it worked when client side but I have my marker in server side and everything is based on server side so actually it didnt really work
PaiN^ Posted February 15, 2013 Posted February 15, 2013 Yes it worked when client side but I have my marker in server side and everything is based on server side so actually it didnt really work addEventHandler("onClientPlayerDamage", root, function(attacker, weapon, bodypart, loss) if (isElementWithinMarker(source, theMarker)) then cancelEvent() end end ) Line 4 --> Replace theMarker with your marker name . -- Server addEventHandler( "onMarkerHit", root, function ( player ) if ( getElementType ( player ) == "player" ) then triggerClientEvent( "onClientPlayerDamage", getRootElement( ), player ) end end ) Line 2 --> Replace root with your marker name .
iPrestege Posted February 15, 2013 Posted February 15, 2013 Yes it worked when client side but I have my marker in server side and everything is based on server side so actually it didnt really work addEventHandler("onClientPlayerDamage", root, function(attacker, weapon, bodypart, loss) if (isElementWithinMarker(source, theMarker)) then cancelEvent() end end ) Line 4 --> Replace theMarker with your marker name . -- Server addEventHandler( "onMarkerHit", root, function ( player ) if ( getElementType ( player ) == "player" ) then triggerClientEvent( "onClientPlayerDamage", getRootElement( ), player ) end end ) Line 2 --> Replace root with your marker name . Wrong,The code is not complete .
PaiN^ Posted February 15, 2013 Posted February 15, 2013 Wrong,The code is not complete . Then fix it, And show me my errors please
iPrestege Posted February 15, 2013 Posted February 15, 2013 Wrong,The code is not complete . Then fix it, And show me my errors please isElementWithinMarker(source,theMarker) you use it on the client side and the marker isn,t on the client side you will get BadArg if you do it .
goofie88 Posted February 15, 2013 Author Posted February 15, 2013 Thanks for trying to help me Mr.ALM but everyone within marker is still vulnerable to damage even when i replaced source to localPlayer in client side script
PaiN^ Posted February 15, 2013 Posted February 15, 2013 I had some errors like Mr.Pres[T]ege said, That why it didn't work :{ But i tried to fix it and i came up with this code : -- Server : marker = creatMarker( X, Y, Z, "cylinder" ) addEventHandler( "onMarkerHit", marker, function ( player ) if ( getElementType ( player ) == "player" ) then if isElementWithinMarker ( player, marker ) then triggerClientEvent( "onClientPlayerDamage", getRootElement( ), player ) end end end ) -- Client : addEventHandler( "onClientPlayerDamage", root, function ( player ) cancelEvent ( ) end ) fix any errors please ..
goofie88 Posted February 15, 2013 Author Posted February 15, 2013 Yep this one worked like a charm but player stays invincible even when not within marker when he leaves ;(
PaiN^ Posted February 15, 2013 Posted February 15, 2013 -- Server : marker = creatMarker( X, Y, Z, "cylinder" ) addEventHandler( "onMarkerHit", marker, function ( player ) if ( getElementType ( player ) == "player" ) then if isElementWithinMarker ( player, marker ) then triggerClientEvent( "onClientPlayerDamage", getRootElement( ), player ) else cancelEvent( "onClientPlayerDamage", true ) end end end ) -- Client : addEventHandler( "onClientPlayerDamage", root, function ( player ) cancelEvent ( ) end )
PaiN^ Posted February 15, 2013 Posted February 15, 2013 -- Server : marker = creatMarker( X, Y, Z, "cylinder" ) addEventHandler( "onMarkerHit", marker, function ( player ) if ( getElementType ( player ) == "player" ) then if isElementWithinMarker ( player, marker ) then triggerClientEvent( "onClientPlayerDamage", getRootElement( ), player ) end end end ) addEventHandler( "onMarkerLeave", marker, function ( player ) if ( getElementType ( player ) == "player" ) then cancelEvent( "onClientPlayerDamage", true ) end end ) -- Client : addEventHandler( "onClientPlayerDamage", root, function ( player ) cancelEvent ( ) end )
albers14 Posted February 15, 2013 Posted February 15, 2013 Confuses me why you guys dont do it all serversided? Giving the element a data when he hits the marker and when he leave the marker removes it. Use onPlayerDamage and getElementData to check if the player should be hurt or not, if not then cancelEvent() Done.
PaiN^ Posted February 15, 2013 Posted February 15, 2013 Confuses me why you guys dont do it all serversided? Giving the element a data when he hits the marker and when he leave the marker removes it. Use onPlayerDamage and getElementData to check if the player should be hurt or not, if not then cancelEvent()Done. Because i have been told that you can't cancel onPlayerDamage event . But if you meant any other way, Then make your code and lay it for us so we can learn
albers14 Posted February 15, 2013 Posted February 15, 2013 Confuses me why you guys dont do it all serversided? Giving the element a data when he hits the marker and when he leave the marker removes it. Use onPlayerDamage and getElementData to check if the player should be hurt or not, if not then cancelEvent()Done. Because i have been told that you can't cancel onPlayerDamage event . But if you meant any other way, Then make your code and lay it for us so we can learn marker = createMarker(x,y,z,"cylinder") function hitMarker(hitElement) if getElementType(hitElement) == "player" then setElementData(hitElement, "godmode", true) end end addEventHandler('onMarkerHit', marker, hitMarker) function leaveMarker(hitElement) if getElementType(hitElement) == "player" then removeElementData(hitElement, "godmode") end end addEventHandler('onMarkerLeave', marker, leaveMarker) client:: function onDamage() if getElementData(source, "godmode") then cancelEvent() end end addEventHandler('onClientPlayerDamage', getLocalPlayer, onDamage)
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