Jump to content

onColShapeHit [HELP]


Timiimit

Recommended Posts

Hi!

I want to know how "onColShapeHit" works!

I read the wiki page but i still don't get it.

I tried this:

  
function test( thePlayer ) 
outputChatBox("it's working!!") 
end 
addEventHandler("onColShapeHit", getRootElement(), test) 
  

...But it doesn't work.

I want to make script that outputs 'it's working!!' when I touch any object.

why noone knows?

Link to comment

I want it to trigger it only once!

not again when its not targeting anything.

+

nothing happens at this:

  
function onPlayerTarget ( targetElem ) 
    if getElementType ( targetElem ) == "object" then 
        output("someone touched an object!") 
    end 
end 
addEventHandler ( "onPlayerTarget", getRootElement(), onPlayerTarget ) 
  

HELP???!!!:::::-----....._____

Link to comment

  
<meta> 
        <info author="[GFL]TimiimiT" name="something" version="1.0"/> 
  
    <script src="test.lua"  /> 
</meta> 
  

btw I started the resource!

tried onPlayerContact not working:

  
function outputElementType ( prev, current ) 
    if ( current ) then 
        outputChatBox ( "You have hit an "..getElementType ( current ) ) 
    end 
end 
addEventHandler ( "onPlayerContact", getRootElement(), outputElementType ) 
  

Link to comment

This is an example

local hillArea = createColRectangle ( -2171.0678710938, 678.17950439453, 15, 15 ) 
  
-- add hill_Enter as a handler for when a player enters the hill area 
function hill_Enter ( thePlayer, matchingDimension ) 
        if getElementType ( thePlayer ) == "player" then --if the element that entered was player 
                --let's get the name of the player 
                local nameOfThePlayer = getPlayerName ( thePlayer ) 
            --announce to everyone that the player entered the hill 
            outputChatBox ( nameOfThePlayer.." entered the zone!", getRootElement(), 255, 255, 109 ) 
        end 
end 
addEventHandler ( "onColShapeHit", hillArea, hill_Enter ) 
  

Link to comment

why is this not working?:

  
local hillArea = getElementsByType( "object" ) 
  
-- add hill_Enter as a handler for when a player enters the hill area 
function hill_Enter ( thePlayer, matchingDimension ) 
        if getElementType ( thePlayer ) == "player" then --if the element that entered was player 
                --let's get the name of the player 
                local nameOfThePlayer = getPlayerName ( thePlayer ) 
            --announce to everyone that the player entered the hill 
            outputChatBox ( nameOfThePlayer.." entered the zone!", getRootElement(), 255, 255, 109 ) 
        end 
end 
addEventHandler ( "onColShapeHit", hillArea, hill_Enter ) 
  

Link to comment

Maybe because instead of a colshape you're using getElementsByType...

local hillArea = createColRectangle(arguments...) 
  
-- add hill_Enter as a handler for when a player enters the hill area 
function hill_Enter ( thePlayer, matchingDimension ) 
        if getElementType ( thePlayer ) == "player" then --if the element that entered was player 
                --let's get the name of the player 
                local nameOfThePlayer = getPlayerName ( thePlayer ) 
            --announce to everyone that the player entered the hill 
            outputChatBox ( nameOfThePlayer.." entered the zone!", getRootElement(), 255, 255, 109 ) 
        end 
end 
addEventHandler ( "onColShapeHit", hillArea, hill_Enter ) 

Link to comment

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...