local oldState = 0local newState = 0function checkVehiclesGearboxChange()local vehicle = getPedOccupiedVehicle(localPlayer)if vehicle and getElementData(vehicle, \"veh:performance_turbo\") == 5 then newState = getVehicleCurrentGear(vehicle) if newState ~= oldState then oldState = newState local x, y, z = getElementPosition(vehicle) local sound = playSound3D(\"files/turbo.mp3\", x, y, z, false) setSoundMaxDistance(sound, 1000) setSoundVolume(sound, 0.7) endendendsetTimer(checkVehiclesGearboxChange, 500, 0)
Át kell triggerelni a hangot szerver oldalra.
local oldState = 0local newState = 0function checkVehiclesGearboxChange(vehicle)local vehicle = getPedOccupiedVehicle(localPlayer)if vehicle and getElementData(vehicle, \"veh:performance_turbo\") == 5 then newState = getVehicleCurrentGear(vehicle) if newState ~= oldState then oldState = newState local x, y, z = getElementPosition(vehicle) triggerServerEvent(\"serverturbo\", root, x, y, z) endendendsetTimer(checkVehiclesGearboxChange, 500, 0)addEvent(\"turbohang\", true) addEventHandler(\"turbohang\", getRootElement(), function(x, y, z) sound = playSound3D(\"files/turbo.mp3\", x, y, z) setSoundVolume(sound, 0.7) setSoundMaxDistance (sound, 100) attachElements (sound, localPlayer) end)
addEvent(\"serverturbo\", true)addEventHandler(\"serverturbo\", getRootElement(), function(x, y, z) if client then triggerClientEvent(client, \"turbohang\", client, x, y, z) endend)
triggerClientEvent(client, \"turbohang\", client, x, y, z)
triggerClientEvent(client, \"turbohang\", client, x, y, z) Mert itt, csakis egy játékosnak triggereled az eventet, nem pedig többnek. Az első paraméter helyére rakhatsz egy táblát is, tele játékos elementtel, akiknek elszeretnéd küldeni a hangot.
addEvent(\"serverturbo\", true)addEventHandler(\"serverturbo\", getRootElement(), function(x, y, z) local turboCol = createColSphere( x, y, z, 100 ) local nearbyPlayers = getElementsWithinColShape( turboCol, \"player\" ) destroyElement( turboCol ) for index, nearbyPlayer in ipairs( nearbyPlayers ) do if client then triggerClientEvent(nearbyPlayer, \"turbohang\", nearbyPlayer, x, y, z) outputChatBox(\"Turbo\", nearbyPlayer) --teszt end endend)
Szia, most erre jutottam outputChatBox-ban kiírja hogy létezik a turbó hang és lekérdezi a 100-as körzetben lévő játékosokat amiket bele is rak, de a hang nem játszódik le valószínűleg a triggerClientEvent rossz.... Most így néz ki a dolog: addEvent(\"serverturbo\", true)addEventHandler(\"serverturbo\", getRootElement(), function(x, y, z) local turboCol = createColSphere( x, y, z, 100 ) local nearbyPlayers = getElementsWithinColShape( turboCol, \"player\" ) destroyElement( turboCol ) for index, nearbyPlayer in ipairs( nearbyPlayers ) do if client then triggerClientEvent(nearbyPlayer, \"turbohang\", nearbyPlayer, x, y, z) outputChatBox(\"Turbo\", nearbyPlayer) --teszt end endend)
addEvent(\"serverturbo\", true)addEventHandler(\"serverturbo\", getRootElement(), function(x, y, z) local turboCol = createColSphere( x, y, z, 100 ) setTimer(function() local nearbyPlayers = getElementsWithinColShape( turboCol, \"player\" )for index, nearbyPlayer in ipairs( nearbyPlayers ) do if client then triggerClientEvent(nearbyPlayer, \"turbohang\", nearbyPlayer, x, y, z) outputChatBox(\"Turbo\", nearbyPlayer) --teszt end end end, 100, 1) destroyElement( turboCol )end)
addEvent(\"serverturbo\", true)addEventHandler(\"serverturbo\", getRootElement(), function(x, y, z)local turboCol = createColSphere( x, y, z, 100 )local nearbyPlayers = getElementsWithinColShape( turboCol, \"player\" )triggerClientEvent(nearbyPlayers, \"turbohang\", client, x, y, z)destroyElement( turboCol )end)
<min_mta_version client=\"1.3.1\" server=\"1.3.1\" />
Az csak egy figyelmeztetés, hogy ezt a lehetőséget (hogy egy player tömböt adj meg a triggerClientEventnek) csak 1.3.0-9.04570-től elérhető. Írja is a wiki changelog résznél: Link Csak írb bele a metába, hogy <min_mta_version client=\"1.3.1\" server=\"1.3.1\" />