DiosSasuke Posted May 24, 2018 Share Posted May 24, 2018 Is it possible to make an object lower the player's life? Link to comment
Captain Cody Posted May 24, 2018 Share Posted May 24, 2018 Yes, however you'd need to explain a little bit better (What exactly you are attempting to achieve) to get the best help possible. Link to comment
itHyperoX Posted May 24, 2018 Share Posted May 24, 2018 if you want to create an object under player, yes you can x , y , z , you need to calculate the Z value Link to comment
DiosSasuke Posted May 24, 2018 Author Share Posted May 24, 2018 What I want is that when a player shock with the object, it takes away life Link to comment
AHMED MOSTAFA Posted May 24, 2018 Share Posted May 24, 2018 15 minutes ago, DiosSasuke said: What I want is that when a player shock with the object, it takes away life do u mean set/getElementHealth ? Link to comment
AHMED MOSTAFA Posted May 24, 2018 Share Posted May 24, 2018 4 minutes ago, DiosSasuke said: I think so Unfortunately, i do not understand you Can you please explain more? do u mean >> on player damage something or on player damaged by something ? or u want to create an object and its health is lower than the player's health ? Link to comment
DiosSasuke Posted May 24, 2018 Author Share Posted May 24, 2018 what I want is to create an object and when the object hits the player it will take damage. with hitting I mean the object touches the player and takes the player's life the player Link to comment
AHMED MOSTAFA Posted May 24, 2018 Share Posted May 24, 2018 3 minutes ago, DiosSasuke said: what I want is to create an object and when the object hits the player it will take damage. with hitting I mean the object touches the player and takes the player's life the player i think u need to create two things 1- the object 2- a marker and use attachElements to attach the marker with the object and use "onClientMarkerHit" or "onMarkerHit" and use setElementHealth, getElementHealth to set the player's health when the player hits the marker so u need createObject -- the object which u want to create createMarker attachElements -- to attach the marker and tha object "onMarkerHit" or "onClientMarkerHit" setElementHealth getElementHealth Link to comment
DiosSasuke Posted May 24, 2018 Author Share Posted May 24, 2018 Well, I'm sorry but I'm new and I dont know use all that . Could you give me an example? of all the unique thing I know how to use is the createobject everything else is new to me Link to comment
WiBox Posted May 26, 2018 Share Posted May 26, 2018 (edited) .object = createObject ( 980, 1619, 1842, 11, 90, 0, 0 ) -- object position is at LV Hospital. function RemoveHpWhenObjectHitThePlayer ( thePlayer ) local x, y, z = getElementPosition ( object ) local marker = createMarker ( x + 1, x + 2, 2, "cylinder", 1, 255, 255, 0, 0 ) attachElements ( marker , thePlayer , 0, 0, 0 ) if isElementWithinMarker ( thePlayer , marker) do setElementHealth ( thePlayer, getElementHealth( thePlayer ) - 10 ) -- - 10 is how much it damage him, make it the number you like. end end addEventHandler ( "onMarkerHit", marker, RemoveHpWhenObjectHitThePlayer) i'm not sure if it will work but test it ~ Edited May 26, 2018 by SSKE Link to comment
DiosSasuke Posted May 26, 2018 Author Share Posted May 26, 2018 thank you I'll try it when I enter the pc Link to comment
AHMED MOSTAFA Posted May 28, 2018 Share Posted May 28, 2018 (edited) On 5/26/2018 at 15:44, DiosSasuke said: thank you I'll try it when I enter the pc test this local object = createObject ( ... ) local marker = createMarker ( 0, 0, 0 ) attachElements ( marker, object ) setElementData ( marker, "harmful", true ) function hit ( player ) if player == localPlayer then -- if u use client file if getElementData ( source, "harmful" ) then setElementHealth ( player, getElementHealth ( player ) - 10 ) end end -- if u use client file end addEventHandler ( "onClientMarkerHit", root, hit ) -- if u will use client file addEventHandler ( "onMarkerHit", root, hit ) -- if u will use server file " i did not test it " Edited May 28, 2018 by killerProject 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