swag_k_dog Posted January 1, 2017 Share Posted January 1, 2017 so I made this clientside: local missionMarker = createMarker(2153, -1799, 12.5, "cylinder", 1.1, 255, 0, 0, 100) local player = getLocalPlayer() function missionGui() missionName = guiCreateLabel(0.64, 0.85, 0.38, 0.13, "sweet buisness", true) local font0_gtasanandreas = guiCreateFont(":freeroam_login/images/gtasanandreas.ttf", 50) guiSetFont(missionName, font0_gtasanandreas) guiLabelSetColor(missionName, 252, 226, 81) end addEventHandler("onClientResourceStart", resourceRoot, missionGui) addEventHandler("onClientResourceStart", resourceRoot, function() guiSetVisible(missionName, false) end) function markerhit (player, missionMarker) guiSetVisible(missionName, true) fadeCamera(false,1.3) setTimer(fadeCamera,3000,1,true) setTimer(guiSetVisible,5500,1,missionName, false) end addEventHandler("onClientMarkerHit", missionMarker, markerhit) it works fine BUT. when my friend walks in the marker, the fadeCamera and guiSetVisible apply to me too. when I walk in it, it applies to him. How do I make it to work only for the person that walks in the marker? god thanks... Link to comment
Tails Posted January 1, 2017 Share Posted January 1, 2017 Check 2nd argument in your markerHit func. It's just dimension, you don't really need it. Also the onClientMarkerHit event gets triggered for every client (read the wiki page). So you just need to check that the player (1st argument) is indeed the localPlayer (you) that hit the marker. Also rename the 1st argument or remove this line: local player = getLocalPlayer() . It doesn't work that way. function markerhit(hitPlayer, missionMarker) if hitPlayer == localPlayer then guiSetVisible(missionName, true) fadeCamera(false,1.3) setTimer(fadeCamera,3000,1,true) setTimer(guiSetVisible,5500,1,missionName, false) end end addEventHandler("onClientMarkerHit", missionMarker, markerhit) Link to comment
Incama Posted January 1, 2017 Share Posted January 1, 2017 Spoiler local missionMarker = createMarker(2153, -1799, 12.5, "cylinder", 1.1, 255, 0, 0, 100) local FONT = guiCreateFont(":freeroam_login/images/gtasanandreas.ttf", 50) function missionGui() missionName = guiCreateLabel(0.64, 0.85, 0.38, 0.13, "sweet buisness", true) guiSetFont(missionName, FONT) guiLabelSetColor(missionName, 252, 226, 81) end function destroyGuis() if isElement(missionName) then destroyElement(missionName) end end addEventHandler("onClientMarkerHit", root, function(hitElement) if source == missionMarker and hitElement == localPlayer then triggerServerEvent("server->hitMarker", source, source) end end) addEventHandler("onClientMarkerLeave", root, function(hitElement) if source == missionMarker and hitElement == localPlayer then destroyGuis() end end) addEvent("client->hitMarker", true) addEventHandler("client->hitMarker", root, function(player) missionGui() fadeCamera(false,1.3) setTimer(function() fadeCamera() end, 3000, 1) setTimer(function() guiSetVisible(missionName, false) end, 5500, 1) end) client Spoiler addEvent("server->hitMarker", true) addEventHandler("server->hitMarker", root, function(player) if not client then return -- for security reasons, this helps against rouge clients end if not player then return -- the same end triggerClientEvent(client, "client->hitMarker", client, client) end) server Link to comment
swag_k_dog Posted January 1, 2017 Author Share Posted January 1, 2017 1 minute ago, Incama said: Hide contents local missionMarker = createMarker(2153, -1799, 12.5, "cylinder", 1.1, 255, 0, 0, 100) local FONT = guiCreateFont(":freeroam_login/images/gtasanandreas.ttf", 50) function missionGui() missionName = guiCreateLabel(0.64, 0.85, 0.38, 0.13, "sweet buisness", true) guiSetFont(missionName, FONT) guiLabelSetColor(missionName, 252, 226, 81) end function destroyGuis() if isElement(missionName) then destroyElement(missionName) end end addEventHandler("onClientMarkerHit", root, function(hitElement) if source == missionMarker and hitElement == localPlayer then triggerServerEvent("server->hitMarker", source, source) end end) addEventHandler("onClientMarkerLeave", root, function(hitElement) if source == missionMarker and hitElement == localPlayer then destroyGuis() end end) addEvent("client->hitMarker", true) addEventHandler("client->hitMarker", root, function(player) missionGui() fadeCamera(false,1.3) setTimer(function() fadeCamera() end, 3000, 1) setTimer(function() guiSetVisible(missionName, false) end, 5500, 1) end) client Hide contents addEvent("server->hitMarker", true) addEventHandler("server->hitMarker", root, function(player) if not client then return -- for security reasons, this helps against rouge clients end if not player then return -- the same end triggerClientEvent(client, "client->hitMarker", client, client) end) server doesnt work :c Link to comment
Incama Posted January 1, 2017 Share Posted January 1, 2017 Just now, swag_k_dog said: doesnt work :c What does the debugscript says? Link to comment
swag_k_dog Posted January 1, 2017 Author Share Posted January 1, 2017 Just now, Incama said: What does the debugscript says? nothing Link to comment
Incama Posted January 1, 2017 Share Posted January 1, 2017 Just now, swag_k_dog said: nothing lol, it should work. Link to comment
swag_k_dog Posted January 1, 2017 Author Share Posted January 1, 2017 1 minute ago, Incama said: lol, it should work. http://imgur.com/a/aiqGM Link to comment
KariiiM Posted January 2, 2017 Share Posted January 2, 2017 Hey swag_k_dog, try my code and let me know --CLIENT SIDE: local missionMarker = createMarker(2153, -1799, 12.5, "cylinder", 1.1, 255, 0, 0, 100) local FONT = guiCreateFont(":freeroam_login/images/gtasanandreas.ttf", 50) function missionGui() missionName = guiCreateLabel(0.64, 0.85, 0.38, 0.13, "sweet buisness", true) guiSetFont(missionName, FONT) guiLabelSetColor(missionName, 252, 226, 81) end function destroyGuis ( ) if isElement ( missionName ) then destroyElement ( missionName ) end end addEventHandler ( "onClientMarkerHit", missionMarker, function ( hitElement ) if ( isElement ( hitElement ) and hitElement == localPlayer ) then triggerServerEvent ( "server->hitMarker", localPlayer, localPlayer ) end end ) addEventHandler ( "onClientMarkerLeave", missionMarker, function ( hitElement ) if ( isElement ( hitElement ) and hitElement == localPlayer ) then destroyGuis ( ) end end ) addEvent ( "client->hitMarker", true ) addEventHandler ( "client->hitMarker", localPlayer, function ( ) missionGui ( ) fadeCamera ( false, 1.3 ) setTimer ( fadeCamera, 3000, 1, false, 1.3 ) setTimer ( guiSetVisible, 5500, 1, missionName, false ) end ) --SERVER SIDE: addEvent ( "server->hitMarker", true ) addEventHandler ( "server->hitMarker", root, function ( player ) if ( not client ) then return -- for security reasons, this helps against rouge clients end if ( not player ) then return -- the same end triggerClientEvent ( client, "client->hitMarker", client ) end ) Link to comment
swag_k_dog Posted January 2, 2017 Author Share Posted January 2, 2017 2 minutes ago, KariiiM said: Hey swag_k_dog, try my code and let me know --CLIENT SIDE: local missionMarker = createMarker(2153, -1799, 12.5, "cylinder", 1.1, 255, 0, 0, 100) local FONT = guiCreateFont(":freeroam_login/images/gtasanandreas.ttf", 50) function missionGui() missionName = guiCreateLabel(0.64, 0.85, 0.38, 0.13, "sweet buisness", true) guiSetFont(missionName, FONT) guiLabelSetColor(missionName, 252, 226, 81) end function destroyGuis ( ) if isElement ( missionName ) then destroyElement ( missionName ) end end addEventHandler ( "onClientMarkerHit", missionMarker, function ( hitElement ) if ( isElement ( hitElement ) and hitElement == localPlayer ) then triggerServerEvent ( "server->hitMarker", localPlayer, localPlayer ) end end ) addEventHandler ( "onClientMarkerLeave", missionMarker, function ( hitElement ) if ( isElement ( hitElement ) and hitElement == localPlayer ) then destroyGuis ( ) end end ) addEvent ( "client->hitMarker", true ) addEventHandler ( "client->hitMarker", localPlayer, function ( ) missionGui ( ) fadeCamera ( false, 1.3 ) setTimer ( fadeCamera, 3000, 1, false, 1.3 ) setTimer ( guiSetVisible, 5500, 1, missionName, false ) end ) --SERVER SIDE: addEvent ( "server->hitMarker", true ) addEventHandler ( "server->hitMarker", root, function ( player ) if ( not client ) then return -- for security reasons, this helps against rouge clients end if ( not player ) then return -- the same end triggerClientEvent ( client, "client->hitMarker", client ) end ) i'll try it tomorrow because I dont have someone to test with. my friend went to bed Link to comment
KariiiM Posted January 2, 2017 Share Posted January 2, 2017 1 minute ago, swag_k_dog said: i'll try it tomorrow because I dont have someone to test with. my friend went to bed Sure, good luck 1 Link to comment
Tails Posted January 2, 2017 Share Posted January 2, 2017 Just use my example. It works for what you're doing. No need to get all fancy right away, take it step by step. 3 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