anumaz Posted March 26, 2014 Share Posted March 26, 2014 Hey, I created a little script that works just fine client-side: It creates a fire, a blip and PlaySound3D. However, that is all client-side and no one in the server can see/hear them. These functions (or most of them) are just available client-side. My question is: how to make them hearable/visible to others? Thanks, Anumaz Link to comment
WhoAmI Posted March 26, 2014 Share Posted March 26, 2014 Create blip server side. With sound is other story. You have to trigger for all players from server side event which is added client side, then it would be hearable for all players. Link to comment
anumaz Posted March 26, 2014 Author Share Posted March 26, 2014 I don't really know how to do that. Maybe you can indicate me a tutorial or something? Link to comment
WhoAmI Posted March 26, 2014 Share Posted March 26, 2014 I'm not at computer atm, but here is my old topic I go the same problem. viewtopic.php?f=91&t=72058&hilit=+sound that should help you Link to comment
anumaz Posted March 27, 2014 Author Share Posted March 27, 2014 function makeitburn (player, commandName, fdfire) triggerClientEvent( "createfdfire", getRootElement(), fdfire ) end addCommandHandler ( "fdfire", makeitburn ) Anything wrong with that? It always shows the syntax as if I didn't put a number next to it? Link to comment
WhoAmI Posted March 27, 2014 Share Posted March 27, 2014 function makeitburn (player, commandName, fdfire) triggerClientEvent( "createfdfire", player, fdfire ) end addCommandHandler ( "fdfire", makeitburn ) /fdfire something If doesn't work show us clientside. Link to comment
anumaz Posted March 27, 2014 Author Share Posted March 27, 2014 Client side: function fdbell() local Sound = playSound3D( "alarm/firealarm.mp3", 1725, -1130, 24, false ) setElementInterior(Sound, getElementInterior(localPlayer)) setElementDimension(Sound, getElementDimension(localPlayer)) setSoundMinDistance(Sound, 25) setSoundMaxDistance(Sound, 70) -- setSoundVolume( Sound, 1 ) end addEvent("ringTheBell", true) addEventHandler("ringTheBell", root, fdbell) function loadthescript() outputChatBox("Script loaded -- debug") end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), loadthescript) addCommandHandler("bell", fdbell) function fdfire(commandName, fireid) if fireid then if tonumber(fireid) == 1 then createFire(1700, -1168, 23, 60) createFire(1698, -1168, 23, 60) local blipicon = createBlip( 1700, -1168, 23, 43, 0, 0, 0, 255 ) outputChatBox("Fire created at 1700, -1168, 23") local onlinePlayers = getElementsByType("player") for index, player in pairs(onlinePlayers) do local x, y, z = getElementPosition(player) local distance = getDistanceBetweenPoints3D(1725, -1130, 24, x, y, z) if (distance <50) then setTimer(function () destroyElement(blipicon) end, 900000, 1) setTimer(function () triggerEvent("ringTheBell", player) end, 5000, 1) end end elseif tonumber(fireid) == 2 then createFire(1729, -1174, 23, 60) createFire(1727, -1174, 23, 60) local blipicon = createBlip( 1729, -1174, 23, 43, 0, 0, 0, 255 ) outputChatBox("Fire created at 1729, -1174, 23") local onlinePlayers = getElementsByType("player") for index, player in pairs(onlinePlayers) do local x, y, z = getElementPosition(player) local distance = getDistanceBetweenPoints3D(1725, -1130, 24, x, y, z) if (distance <50) then setTimer(function () destroyElement(blipicon) end, 900000, 1) setTimer(function () triggerEvent("ringTheBell", player) end, 5000, 1) end end else outputChatBox("Missing ID") end else outputChatBox("Syntax: /fdfire [id]", thePlayer) outputChatBox("IDs available: 1, 2", thePlayer) end end -- addCommandHandler("fdfire", fdfire) addEvent ( "createfdfire", true ) addEventHandler ( "createfdfire", getRootElement(), fdfire ) Server side: function makeitburn (player, commandName, fdfire) triggerClientEvent( "createfdfire", getRootElement(), fdfire ) end addCommandHandler ( "fdfire", makeitburn ) Issue is it doesn't get the numer I type (1 or 2) after /fdfire. It always outputs the syntax as if there was no number. Link to comment
WhoAmI Posted March 27, 2014 Share Posted March 27, 2014 --SERVER function makeitburn ( player, commandName, fdfire ) triggerClientEvent( "createfdfire", player, fdfire ) end addCommandHandler ( "fdfire", makeitburn ) --CLIENT function fdfire ( fireid ) if fireid then if tonumber(fireid) == 1 then createFire(1700, -1168, 23, 60) createFire(1698, -1168, 23, 60) local blipicon = createBlip( 1700, -1168, 23, 43, 0, 0, 0, 255 ) outputChatBox("Fire created at 1700, -1168, 23") local onlinePlayers = getElementsByType("player") for index, player in pairs(onlinePlayers) do local x, y, z = getElementPosition(player) local distance = getDistanceBetweenPoints3D(1725, -1130, 24, x, y, z) if (distance <50) then setTimer(function () destroyElement(blipicon) end, 900000, 1) setTimer(function () triggerEvent("ringTheBell", player) end, 5000, 1) end end elseif tonumber(fireid) == 2 then createFire(1729, -1174, 23, 60) createFire(1727, -1174, 23, 60) local blipicon = createBlip( 1729, -1174, 23, 43, 0, 0, 0, 255 ) outputChatBox("Fire created at 1729, -1174, 23") local onlinePlayers = getElementsByType("player") for index, player in pairs(onlinePlayers) do local x, y, z = getElementPosition(player) local distance = getDistanceBetweenPoints3D(1725, -1130, 24, x, y, z) if (distance <50) then setTimer(function () destroyElement(blipicon) end, 900000, 1) setTimer(function () triggerEvent("ringTheBell", player) end, 5000, 1) end end else outputChatBox("Missing ID") end else outputChatBox("Syntax: /fdfire [id]", thePlayer) outputChatBox("IDs available: 1, 2", thePlayer) end end -- addCommandHandler("fdfire", fdfire) addEvent ( "createfdfire", true ) addEventHandler ( "createfdfire", root, fdfire ) 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