Sparrow Posted March 19, 2012 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)
Gr0x Posted March 19, 2012 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
myonlake Posted March 19, 2012 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) If I helped you, please click the like button on the right Thanks!
drk Posted March 19, 2012 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 ) EPT Team Server Development: 0% Learning C++ | C++ is amazing
Sparrow Posted March 19, 2012 Author Posted March 19, 2012 it didn't work, no erros on debug, also I try it client side (onClientColShapeHit/onClientColShapeLeave)
Kenix Posted March 19, 2012 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 ) http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Kenix Posted March 19, 2012 Posted March 19, 2012 Try test with development mode. https://wiki.multitheftauto.com/wiki/SetDevelopmentMode http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Gr0x Posted March 19, 2012 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)
drk Posted March 19, 2012 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 EPT Team Server Development: 0% Learning C++ | C++ is amazing
Castillo Posted March 19, 2012 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. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted March 19, 2012 Posted March 19, 2012 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Gr0x Posted March 20, 2012 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.
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