Jump to content

Col Shape


Sparrow

Recommended Posts

Posted

well, this is my first time I use col shape and the radar stuffs.

I've created a radar and a rectangle, this what I did, it didn't work.

local radar = createRadarArea(-466.317, -468.559, -150, -90, 255, 255, 0, 175) 
local colRectangle = createColRectangle(-466.317, -468.559, -150, -90) 
  
function onEnter(thePlayer) 
    if (getElementType(player) == "player") then 
        outputChatBox("You entered the zone, welcome.", thePlayer, 0, 255, 0) 
    end 
end 
addEventHandler("onColShapeHit", colRectangle, onEnter) 
  
function onExit(thePlayer) 
    if (getElementType(player) == "player") then 
        outputChatBox("You left the zone, good bye.", thePlayer, 0, 255, 0) 
    end 
end 
addEventHandler("onColShapeLeave", colRectangle, onExit) 

Posted (edited)

Try this:

  
local radar = createRadarArea(-466.317, -468.559, -150, -90, 255, 255, 0, 175) 
local colRectangle = createColRectangle(-466.317, -468.559, -150.0, -90.0) 
  
function onEnter(hitElement) 
    if (getElementType(hitElement) == "player") then 
        outputChatBox("You entered the zone, welcome.", hitElement, 0, 255, 0) 
    end 
end 
addEventHandler("onColShapeHit", colRectangle, onEnter) 
  
function onExit(hitElement) 
    if (getElementType(hitElement) == "player") then 
        outputChatBox("You left the zone, good bye.", hitElement, 0, 255, 0) 
    end 
end 
addEventHandler("onColShapeLeave", colRectangle, onExit) 
  

Edited by Guest
Posted

To prevent dimension problems and so on, you can try this:

local radar = createRadarArea(-466.317, -468.559, -150, -90, 255, 255, 0, 175) 
local colRectangle = createColRectangle(-466.317, -468.559, -150, -90) 
  
function onEnter(hitElement, matchingDimension) 
    if matchingDimension then 
        if (getElementType(player) == "player") then 
            outputChatBox("You entered the zone, welcome.", hitElement, 0, 255, 0) 
        end 
    end 
end 
addEventHandler("onColShapeHit", colRectangle, onEnter) 
  
function onExit(hitElement, matchingDimension) 
    if matchingDimension then 
        if (getElementType(hitElement) == "player") then 
            outputChatBox("You left the zone, good bye.", hitElement, 0, 255, 0) 
        end 
    end 
end 
addEventHandler("onColShapeLeave", colRectangle, onExit) 

Posted
local radar = createRadarArea(-466.317, -468.559, -150, -90, 255, 255, 0, 175) 
local colRectangle = createColRectangle(-466.317, -468.559, -150, -90) 
  
addEventHandler ( "onColShapeHit", root, 
     function ( element, dimension ) 
        if ( source == colRectangle and getElementType ( element ) == "player" ) then 
            outputChatBox ( "You entered the zone. Welcome!", element, 0, 255, 0, false ) 
        end 
     end 
) 
  
addEventHandler ( "onColShapeLeave", root, 
     function ( element, dimension ) 
        if ( source == colRectangle and getElementType ( element ) == "player" ) then 
            outputChatBox ( "You left the zone. Bye bye!", element, 0, 255, 0, false ) 
        end 
     end 
) 

Posted

Server

  
local uRadar = createRadarArea( -466.317, -468.559, -150, -90, 255, 255, 0, 175 ) 
local uRectangle = createColRectangle( -466.317, -468.559, -150, -90 ) 
  
function fColshapeManager ( uElement, bDim ) 
    if getElementType( uElement ) == 'player' then 
        outputChatBox(  
            eventName == 'onColShapeHit' and 'You entered the zone. Welcome!' or 
            eventName == 'onColShapeLeave' and 'You left the zone. Bye bye!', 
            uElement, 
            0, 
            255, 
            0 
        ) 
    end 
end 
addEventHandler ( 'onColShapeHit',      uRectangle, fColshapeManager ) 
addEventHandler ( 'onColShapeLeave',    uRectangle, fColshapeManager ) 
  

Posted

Try this:

local radar = createRadarArea(-466.317, -468.559, -150, -90, 255, 255, 0, 175) 
local colRectangle = createColRectangle(-466.317, -468.559, -150.0, -90.0) 
  
function onEnter(hitElement) 
    if (getElementType(hitElement) == "player" and source == colRectangle) then 
        outputChatBox("You entered the zone, welcome.", hitElement, 0, 255, 0) 
    end 
end 
addEventHandler("onColShapeHit", root, onEnter) 
  
function onExit(hitElement) 
    if (getElementType(hitElement) == "player" and source == colRectangle) then 
        outputChatBox("You left the zone, good bye.", hitElement, 0, 255, 0) 
    end 
end 
addEventHandler("onColShapeLeave", root, onExit) 

Posted

lol? You have only changed a simple things in my code. Same as mine dude, stop posting only to get better rank lol

Posted
local uRadar = createRadarArea( -466.317, -468.559, -150, -90, 255, 255, 0, 175 ) 
local uRectangle = createColRectangle( -624, -563, 158, 95 ) 
  
function fColshapeManager ( uElement, bDim ) 
    if getElementType( uElement ) == 'player' then 
        outputChatBox( 
            eventName == 'onColShapeHit' and 'You entered the zone. Welcome!' or 
            eventName == 'onColShapeLeave' and 'You left the zone. Bye bye!', 
            uElement, 
            0, 
            255, 
            0 
        ) 
    end 
end 
addEventHandler ( 'onColShapeHit',      uRectangle, fColshapeManager ) 
addEventHandler ( 'onColShapeLeave',    uRectangle, fColshapeManager ) 

Your colshape wasn't the same size as the radar area, must be because of the negative values.

Posted
lol? You have only changed a simple things in my code. Same as mine dude, stop posting only to get better rank lol

I rewrited my code (Not your) and i not make it for "Better rank". Ranks unnecessary.

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