Jump to content

lol dis crap again


swag_k_dog

Recommended Posts

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

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
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
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

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...