kevincouto6 Posted November 29, 2018 Share Posted November 29, 2018 Hello, I am not able to make "onMarkerHit" work on the Client because I need to have the marker be created in the Client because it is individual for each player, but it is important to "onMarkerHit" work on the Client while on the server, If someone can help me, thx Server --mission five-- cardrivepoints = 0 i = 1 -- contador global veh5 = {} -- Recomendo que evite posi趥s decimais muito grandes. Use s?頳 casas decimais. localitionveh55 = { [1] = {401, 216.82504, 1870.22961, 17.3440, 0, 0, 270}, [2] = {401, 216.82504, 1870.22961, 17.3440, 0, 0, 270}, [3] = {401, 216.82504, 1870.22961, 17.3440, 0, 0, 270}, [4] = {401, 216.82504, 1870.22961, 17.3440, 0, 0, 270}, [5] = {401, 216.82504, 1870.22961, 17.3440, 0, 0, 270}, -- O primeiro, quinto e sexto valor das posi趥s n䯠est䯠sendo usados. Recomendo que delete-os. } function inicio5 () if isElement (veh5[client]) then -- Client = localPlayer, somente neste caso. destroyElement (veh5[client]) veh5[client] = nil end local vx ,vy, vz, vrot = localitionveh55[ i ][ 2 ], localitionveh55[ i ][ 3 ], localitionveh55[ i ][ 4 ], localitionveh55[ i ][ 7 ] i = i + 1 if i > #localitionveh55 then -- se i > 5, ent䯺 i = 1 end Trabalho = true veh5[client] = createVehicle ( 401, vx, vy, vz, 0, 0, vrot ) warpPedIntoVehicle (client, veh5[client]) outputChatBox ("#ffff00Drive the veh5icle to the checkpoint. Note: You cannot leave the car during the mission.", client, 0, 0, 0, true) triggerClientEvent (client, "mission5", client) function partfim1 (source) if veh5[client] and isElement(veh5[client]) then cardrivepoints = cardrivepoints+1 outputChatBox("Funcionando!",source,0,0,0,true) destroyElement (markerElement1) setElementVisibleTo ( markerFim1, root, false ) end if cardrivepoints >= 5 then completed(source) end end addEventHandler("onMarkerHit",markerElement1 ,partfim1) function partfim2 (source) if veh5[source] and isElement(veh5[source]) then cardrivepoints = cardrivepoints+1 outputChatBox("Funcionando!",source,0,0,0,true) destroyElement (markerElement2) setElementVisibleTo ( markerFim2, root, false ) end if cardrivepoints >= 5 then completed(source) end end addEventHandler("onMarkerHit",markerElement2 ,partfim2) function partfim3 (source) if veh5[source] and isElement(veh5[source]) then cardrivepoints = cardrivepoints+1 outputChatBox("Funcionando!",source,0,0,0,true) destroyElement (markerElement3) setElementVisibleTo ( markerFim3, root, false ) end if cardrivepoints >= 5 then completed(source) end end addEventHandler("onMarkerHit",markerElement3 ,partfim3) function partfim4 (source) if veh5[source] and isElement(veh5[source]) then cardrivepoints = cardrivepoints+1 outputChatBox("Funcionando!",source,0,0,0,true) destroyElement (markerElement4) setElementVisibleTo ( markerFim4, root, false ) end if cardrivepoints >= 5 then completed(source) end end addEventHandler("onMarkerHit",markerElement4 ,partfim4) function partfim5 (source) if veh5[source] and isElement(veh5[source]) then cardrivepoints = cardrivepoints+1 outputChatBox("Funcionando!",source,0,0,0,true) destroyElement (markerElement5) setElementVisibleTo ( markerFim5, root, false ) end if cardrivepoints >= 5 then completed(source) end end addEventHandler("onMarkerHit",markerElement5 ,partfim5) local player2 = client addEventHandler ( "onVehicleExplode", veh5[client], function () if (veh5[player2]) and isElement(veh5[player2]) then destroyElement (source) takePlayerMoney ( player2, 5000 ) outputChatBox("Mission failed, your veh5icle blew up.", player2 , 255, 0, 0) end end) end addEvent ("iniciaJob5", true) -- Cria o evento "iniciaJob e permite que ele seja chamado pelo client. addEventHandler ("iniciaJob5", getRootElement(), inicio5) -- Executa essa fun褯 quando o evento "iniciaJob" for chamado. Client createMarkerLocations1 = { {231.41704, 1877.68689, 17.64063 -1, "cylinder", 4, 0 ,255 ,0, 255}, {231.41704, 1877.68689, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {231.41704, 1877.68689, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, {231.41704, 1877.68689, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {231.41704, 1877.68689, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, } createMarkerLocations2 = { {231.85756, 1892.57666, 17.64063 -1, "cylinder", 4, 0 ,255 ,0, 255}, {231.85756, 1892.57666, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {231.85756, 1892.57666, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, {231.85756, 1892.57666, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {231.85756, 1892.57666, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, } createMarkerLocations3 = { {229.22476, 1906.36658, 17.64063 -1, "cylinder", 4, 0 ,255 ,0, 255}, {229.22476, 1906.36658, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {229.22476, 1906.36658, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, {229.22476, 1906.36658, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {229.22476, 1906.36658, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, } createMarkerLocations4 = { {212.10025, 1908.91870, 17.64063 -1, "cylinder", 4, 0 ,255 ,0, 255}, {212.10025, 1908.91870, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {212.10025, 1908.91870, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, {212.10025, 1908.91870, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {212.10025, 1908.91870, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, } createMarkerLocations5 = { {192.29828, 1911.02271, 17.64063 -1, "cylinder", 4, 0 ,255 ,0, 255}, {192.29828, 1911.02271, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {192.29828, 1911.02271, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, {192.29828, 1911.02271, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {192.29828, 1911.02271, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, } function callServerFunction() function createRandomMarker(table) local randomRow = math.random(1,#table) return createMarker(table[randomRow][1], table[randomRow][2], table[randomRow][3], table[randomRow][4], table[randomRow][5], table[randomRow][6], table[randomRow][7], table[randomRow][8], table[randomRow][9]) end local markerElement1 = createRandomMarker(createMarkerLocations1) markerFim1 = createBlipAttachedTo ( markerElement1, 19 ) local markerElement2 = createRandomMarker(createMarkerLocations2) markerFim2 = createBlipAttachedTo ( markerElement2, 19 ) local markerElement3 = createRandomMarker(createMarkerLocations3) markerFim3 = createBlipAttachedTo ( markerElement3, 19 ) local markerElement4 = createRandomMarker(createMarkerLocations4) markerFim4 = createBlipAttachedTo ( markerElement4, 19 ) local markerElement5 = createRandomMarker(createMarkerLocations5) markerFim5 = createBlipAttachedTo ( markerElement5, 19 ) end addEvent ("mission5", true) addEventHandler ("mission5", getRootElement(), callServerFunction) Link to comment
Skully Posted November 29, 2018 Share Posted November 29, 2018 onMarkerHit is a server-sided event, use OnClientMarkerHit client side, you can then use this to trigger an event on the server end to do what you need to. Keep in mind that you cannot use OnClientMarkerHit for markers created by the server. Link to comment
kevincouto6 Posted November 30, 2018 Author Share Posted November 30, 2018 22 hours ago, Skully said: could help me, I passed the markers to the client side, but now it is not possible to detect the car that is on the server side, it is possible to change "if veh5[source] and isElement(veh5[source]) then" to detect on the side server ? client createMarkerLocations1 = { {231.41704, 1877.68689, 17.64063 -1, "cylinder", 4, 0 ,255 ,0, 255}, {231.41704, 1877.68689, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {231.41704, 1877.68689, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, {231.41704, 1877.68689, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {231.41704, 1877.68689, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, } createMarkerLocations2 = { {231.85756, 1892.57666, 17.64063 -1, "cylinder", 4, 0 ,255 ,0, 255}, {231.85756, 1892.57666, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {231.85756, 1892.57666, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, {231.85756, 1892.57666, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {231.85756, 1892.57666, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, } createMarkerLocations3 = { {229.22476, 1906.36658, 17.64063 -1, "cylinder", 4, 0 ,255 ,0, 255}, {229.22476, 1906.36658, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {229.22476, 1906.36658, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, {229.22476, 1906.36658, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {229.22476, 1906.36658, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, } createMarkerLocations4 = { {212.10025, 1908.91870, 17.64063 -1, "cylinder", 4, 0 ,255 ,0, 255}, {212.10025, 1908.91870, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {212.10025, 1908.91870, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, {212.10025, 1908.91870, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {212.10025, 1908.91870, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, } createMarkerLocations5 = { {192.29828, 1911.02271, 17.64063 -1, "cylinder", 4, 0 ,255 ,0, 255}, {192.29828, 1911.02271, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {192.29828, 1911.02271, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, {192.29828, 1911.02271, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170 }, {192.29828, 1911.02271, 17.64063 -1, "cylinder", 4, 255, 255, 0, 170}, } function callServerFunction() function createRandomMarker(table) local randomRow = math.random(1,#table) return createMarker(table[randomRow][1], table[randomRow][2], table[randomRow][3], table[randomRow][4], table[randomRow][5], table[randomRow][6], table[randomRow][7], table[randomRow][8], table[randomRow][9]) end local markerElement1 = createRandomMarker(createMarkerLocations1) markerFim1 = createBlipAttachedTo ( markerElement1, 19 ) local markerElement2 = createRandomMarker(createMarkerLocations2) markerFim2 = createBlipAttachedTo ( markerElement2, 19 ) local markerElement3 = createRandomMarker(createMarkerLocations3) markerFim3 = createBlipAttachedTo ( markerElement3, 19 ) local markerElement4 = createRandomMarker(createMarkerLocations4) markerFim4 = createBlipAttachedTo ( markerElement4, 19 ) local markerElement5 = createRandomMarker(createMarkerLocations5) markerFim5 = createBlipAttachedTo ( markerElement5, 19 ) function partfim1 (source) if veh5[client] and isElement(veh5[client]) then cardrivepoints = cardrivepoints+1 outputChatBox("Funcionando!",source,0,0,0,true) destroyElement (markerElement1) setElementVisibleTo ( markerFim1, root, false ) end if cardrivepoints >= 5 then completed(source) end end addEventHandler("onClientMarkerHit",markerElement1 ,partfim1) function partfim2 (source) if veh5[source] and isElement(veh5[source]) then cardrivepoints = cardrivepoints+1 outputChatBox("Funcionando!",source,0,0,0,true) destroyElement (markerElement2) setElementVisibleTo ( markerFim2, root, false ) end if cardrivepoints >= 5 then completed(source) end end addEventHandler("onClientMarkerHit",markerElement2 ,partfim2) function partfim3 (source) if callServerFunction (server, veh5[source]) and isElement(veh5[source]) then cardrivepoints = cardrivepoints+1 outputChatBox("Funcionando!",source,0,0,0,true) destroyElement (markerElement3) setElementVisibleTo ( markerFim3, root, false ) end if cardrivepoints >= 5 then completed(source) end end addEventHandler("onClientMarkerHit",markerElement3 ,partfim3) function partfim4 (source) if veh5[source] and isElement(veh5[source]) then cardrivepoints = cardrivepoints+1 outputChatBox("Funcionando!",source,0,0,0,true) destroyElement (markerElement4) setElementVisibleTo ( markerFim4, root, false ) end if cardrivepoints >= 5 then completed(source) end end addEventHandler("onClientMarkerHit",markerElement4 ,partfim4) function partfim5 (source) if veh5[source] and isElement(veh5[source]) then cardrivepoints = cardrivepoints+1 outputChatBox("Funcionando!",source,0,0,0,true) destroyElement (markerElement5) setElementVisibleTo ( markerFim5, root, false ) end if cardrivepoints >= 5 then completed(source) end end addEventHandler("onClientMarkerHit",markerElement5 ,partfim5) end addEvent ("mission5", true) addEventHandler ("mission5", getRootElement(), callServerFunction) server --mission five-- cardrivepoints = 0 i = 1 -- contador global veh5 = {} -- Recomendo que evite posi趥s decimais muito grandes. Use s?頳 casas decimais. localitionveh55 = { [1] = {401, 216.82504, 1870.22961, 17.3440, 0, 0, 270}, [2] = {401, 216.82504, 1870.22961, 17.3440, 0, 0, 270}, [3] = {401, 216.82504, 1870.22961, 17.3440, 0, 0, 270}, [4] = {401, 216.82504, 1870.22961, 17.3440, 0, 0, 270}, [5] = {401, 216.82504, 1870.22961, 17.3440, 0, 0, 270}, -- O primeiro, quinto e sexto valor das posi趥s n䯠est䯠sendo usados. Recomendo que delete-os. } function inicio5 () if isElement (veh5[client]) then -- Client = localPlayer, somente neste caso. destroyElement (veh5[client]) veh5[client] = nil end local vx ,vy, vz, vrot = localitionveh55[ i ][ 2 ], localitionveh55[ i ][ 3 ], localitionveh55[ i ][ 4 ], localitionveh55[ i ][ 7 ] i = i + 1 if i > #localitionveh55 then -- se i > 5, ent䯺 i = 1 end Trabalho = true veh5[client] = createVehicle ( 401, vx, vy, vz, 0, 0, vrot ) warpPedIntoVehicle (client, veh5[client]) outputChatBox ("#ffff00Drive the veh5icle to the checkpoint. Note: You cannot leave the car during the mission.", client, 0, 0, 0, true) triggerClientEvent (client, "mission5", client) local player2 = client addEventHandler ( "onVehicleExplode", veh5[client], function () if (veh5[player2]) and isElement(veh5[player2]) then destroyElement (source) takePlayerMoney ( player2, 5000 ) outputChatBox("Mission failed, your veh5icle blew up.", player2 , 255, 0, 0) end end) end addEvent ("iniciaJob5", true) -- Cria o evento "iniciaJob e permite que ele seja chamado pelo client. addEventHandler ("iniciaJob5", getRootElement(), inicio5) -- Executa essa fun褯 quando o evento "iniciaJob" for chamado. 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