Jump to content

is possible


Recommended Posts

Posted
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 ?

Posted

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
 

Posted
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

 

Posted

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

Posted (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 by SSKE
Posted (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 by killerProject

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...