Sparrow Posted March 19, 2012 Share Posted March 19, 2012 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) Link to comment
Gr0x Posted March 19, 2012 Share Posted March 19, 2012 (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 March 19, 2012 by Guest Link to comment
myonlake Posted March 19, 2012 Share Posted March 19, 2012 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) Link to comment
Sparrow Posted March 19, 2012 Author Share Posted March 19, 2012 didn't work, no erros on debug Link to comment
drk Posted March 19, 2012 Share Posted March 19, 2012 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 ) Link to comment
Sparrow Posted March 19, 2012 Author Share Posted March 19, 2012 it didn't work, no erros on debug, also I try it client side (onClientColShapeHit/onClientColShapeLeave) Link to comment
Kenix Posted March 19, 2012 Share Posted March 19, 2012 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 ) Link to comment
Kenix Posted March 19, 2012 Share Posted March 19, 2012 Try test with development mode. https://wiki.multitheftauto.com/wiki/SetDevelopmentMode Link to comment
Gr0x Posted March 19, 2012 Share Posted March 19, 2012 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) Link to comment
drk Posted March 19, 2012 Share Posted March 19, 2012 lol? You have only changed a simple things in my code. Same as mine dude, stop posting only to get better rank lol Link to comment
Castillo Posted March 19, 2012 Share Posted March 19, 2012 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. Link to comment
Sparrow Posted March 19, 2012 Author Share Posted March 19, 2012 thanks castillo, it works. Link to comment
Gr0x Posted March 20, 2012 Share Posted March 20, 2012 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. 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