Jump to content

Players Blip Visibility in Server


Zuher Laith

Recommended Posts

Hi everyone,

So I'm working on making the blip on a player (which is blip 0) being removed in the server,

But I'm taking this on another level,
each player near me in the radar, his blip will show up in specific color lets say white, if he is outside my radar view and far, his blip will be destroyed (for client)
this is a GIF to make the idea more clear:
4s4OOygmQ_6DZ32wHcKkzA.gif
I have done this in a custom blip (I created myself) not a player blip, but same idea.

Another thing.. If I created a blip 0 (by another resource) on player, and make it colored to blue for example, It works fine but when I go near that blue blip and the code gets executed it will be destroyed, so we need an exception (for color maybe?..)

I've found some examples here on destroying each player blip being activated by a commandhandler for once, not what I need ..

About the code ..
well, I have the idea but I don't know what to do in code to make all this possible ..

Any help is appreciated .

Link to comment
1 hour ago, Zuher Laith said:

Hi everyone,

So I'm working on making the blip on a player (which is blip 0) being removed in the server,

But I'm taking this on another level,
each player near me in the radar, his blip will show up in specific color lets say white, if he is outside my radar view and far, his blip will be destroyed (for client)
this is a GIF to make the idea more clear:
4s4OOygmQ_6DZ32wHcKkzA.gif
I have done this in a custom blip (I created myself) not a player blip, but same idea.

Another thing.. If I created a blip 0 (by another resource) on player, and make it colored to blue for example, It works fine but when I go near that blue blip and the code gets executed it will be destroyed, so we need an exception (for color maybe?..)

I've found some examples here on destroying each player blip being activated by a commandhandler for once, not what I need ..

About the code ..
well, I have the idea but I don't know what to do in code to make all this possible ..

Any help is appreciated .

Create marker on blip position and hide blip from all then add events 'onMarkerHit','onMarkerLeave' 

and show the blip to player on 'onMarkerHit'
or hide the blip from player on 'onMarkerLeave'

use 

setElementVisibleTo

to show/hide

Link to comment

here is what I came up with (a result that needs work)

Spoiler

Server Side Only:


function Init ( )
	for index, element in ipairs ( getAttachedElements ( source ) ) do 
		if ( getElementType ( element ) == "blip" ) then 
			destroyElement ( element ) 
		end 
	end 
	
	local x,y,z = getElementPosition( source )
	theMarker = createMarker ( x, y, z, "cylinder", 40, 0, 0, 0, 0 ) -- not sure of the size cause I didn't test it
	setElementParent( source, theMarker )
end
addEventHandler ( "onPlayerJoin", getRootElement(), Init )


function MarkerHit( hitElement, matchingDimension )
    if ( getElementType ( element ) == "blip" ) then 
		setElementVisibleTo ( element, source, true )
	end 
end
function MarkerLeave( leaveElement, matchingDimension )
    if ( getElementType ( element ) == "blip" ) then 
		setElementVisibleTo ( element, source, false )
	end 
end
addEventHandler( "onMarkerHit", myMarker, MarkerHit )
addEventHandler( "onMarkerLeave", myMarker, MarkerLeave )

 

The marker is not moving when the player move .

I didn't test this so far .. I feel Its not right,

Link to comment
On 12/8/2017 at 19:29, Tails said:

Make it client side and exclude the local player when you're creating the blips for the players

Also use

https://wiki.multitheftauto.com/wiki/SetBlipVisibleDistance

to set the visible distance

 

The players blip originally created by a resource called "playerblips"
I should stop that .. right ?,

and what do you exactly mean by "excluding the local player"?

do you think it might work If I used SetBlipVisibleDistance when creating the blip in "playerblips" resource ?

Link to comment
10 hours ago, Tails said:

Yeah, you could edit the original resource.

https://github.com/multitheftauto/mtasa-resources/blob/master/[gameplay]/playerblips/playerblips.lua

Under line 32 add another line:


blip[plr]:setVisibleDistance(50)

replace the number with anything you like.

Yes I was focusing on that line, and it should work properly.

but how about if another resource created a blip attached on a player and I want it to be visible with no Distance Visibility ?

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