SoManyTears Posted February 24, 2020 Share Posted February 24, 2020 The sound still does not play when I enter the cities.what's wrong ? can someone help? cities = { ["Bone County"] = true, ["Tierra Robada"] = true, } addEventHandler('onClientResourceStart', localPlayer, function () local x,y,z = getElementPosition(localPlayer) local city = getZoneName(x,y,z, true) if cities[city] then playSound("sound.mp3",true) end end ) Link to comment
Moderators Patrick Posted February 24, 2020 Moderators Share Posted February 24, 2020 onClientResourceStart call the function once, when resource started. If in this time, `localPlayer` is not inside the zone, the music don't start. You have two options: - Place down looped 3D sound. - Check player's position in every second, and start sound if inside the zone (and music isn't playing) or stop sound if outside the zone (and music plays) Link to comment
The_GTA Posted February 24, 2020 Share Posted February 24, 2020 How about looking into the game's info.zon file? You find the entries... zone (...) BONE, 0, -480.539, 596.349, -242.99, 869.461, 2993.87, 900.0, 1, BONE ROBAD, 0, -2997.47, 1659.68, -242.99, -480.539, 2993.87, 900.0, 1, ROBAD (...) end zonename, interior, start_x, start_y, start_z, end_x, end_y, end_z, levelNumber, gxtName You can use colshape createColRectangle ( float fX, float fY, float fWidth, float fHeight ) and then use addEventHandler with "onClientElementColShapeHit" and "onClientElementColShapeLeave" to detect player position, playSound if inside colshape, then stopSound if leaving colshape. Hopefully this helps! Link to comment
Moderators Patrick Posted February 24, 2020 Moderators Share Posted February 24, 2020 (edited) 4 minutes ago, The_GTA said: How about looking into the game's info.zon file? You find the entries... zone (...) BONE, 0, -480.539, 596.349, -242.99, 869.461, 2993.87, 900.0, 1, BONE ROBAD, 0, -2997.47, 1659.68, -242.99, -480.539, 2993.87, 900.0, 1, ROBAD (...) end zonename, interior, start_x, start_y, start_z, end_x, end_y, end_z, levelNumber, gxtName You can use colshape createColRectangle ( float fX, float fY, float fWidth, float fHeight ) and then use addEventHandler with "onClientElementColShapeHit" and "onClientElementColShapeLeave" to detect player position, playSound if inside colshape, then stopSound if leaving colshape. Hopefully this helps! This is a solution too, if you make a colshape around the center of the music's place. Edited February 24, 2020 by Patrick 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