Resource:Customblips: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with '{{Resource page}} __NOTOC__ The customblips resource allows you to create Blip icons clientside that appear on radar and on the F11 map. Custom blips can be any image or GUI…')
 
(Undo revision 50135 by Marcin778 (talk))
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Resource page}}
{{Resource page}}
__NOTOC__
__NOTOC__
The [[customblips]] resource allows you to create Blip icons clientside that appear on radar and on the F11 map.  Custom blips can be any image or GUI element.
The '''customblips''' resource allows you to create Blip icons clientside that appear on radar and on the F11 map.  Custom blips can be any image or GUI element.


==Exported Client functions==
==Exported Client functions==
* '''createCustomBlip'''
** This function creates a custom blip using DirectX image functions.  If the stream radius is lower than 180, then the blip will only appear when it is visible on the radar.
<syntaxhighlight lang="lua">
customblip exports.customblips:createCustomBlip ( float worldX, float worldY, int imageWidth, int imageHeight, string imagePath, [float streamRadius = 500] )
</syntaxhighlight>


This function creates a custom blip using DirectX image functions.  If the stream radius is lower than 180, then the blip will only appear when it is visible on the radar.
{| class="wikitable" border="0"
|-
|width="80pt"|<syntaxhighlight lang="lua">customblip</syntaxhighlight>
|width="110pt"|'''createCustomBlip'''
|<syntaxhighlight lang="lua">float worldX, float worldY, int imageWidth, int imageHeight, imagePath, [float streamRadius = 500]</syntaxhighlight>
|-
|}


This function creates a custom blip using any GUI element.  If the stream radius is lower than 180, then the blip will only appear when it is visible on the radar.
* '''guiConvertToCustomBlip'''
{| class="wikitable" border="0"
** This function creates a custom blip using any GUI element.  If the stream radius is lower than 180, then the blip will only appear when it is visible on the radar.
|-
<syntaxhighlight lang="lua">
|width="80pt"|<syntaxhighlight lang="lua">gui-elem</syntaxhighlight>
gui-elem exports.customblips:guiConvertToCustomBlip ( gui-element blipGUI, float worldX, float worldY, [float streamRadius = 500] )
|width="110pt"|'''guiConvertToCustomBlip'''
</syntaxhighlight>
|<syntaxhighlight lang="lua">gui-element blipGUI, float worldX, float worldY, [float streamRadius = 500]</syntaxhighlight>
|-
|}


This function gets the current stream radius of a customblip.  Note, stream radius does not affect the F11 map.
{| class="wikitable" border="0"
|-
|width="80pt"|<syntaxhighlight lang="lua">float</syntaxhighlight>
|width="110pt"|'''getCustomBlipStreamRadius'''
|<syntaxhighlight lang="lua">customblip theBlip</syntaxhighlight>
|-
|}


This function sets the current stream radius of a customblip.  Note, stream radius does not affect the F11 map.
* '''getCustomBlipStreamRadius'''
{| class="wikitable" border="0"
** This function gets the current stream radius of a customblip.  Note, stream radius does not affect the F11 map.
|-
<syntaxhighlight lang="lua">
|width="80pt"|<syntaxhighlight lang="lua">bool</syntaxhighlight>
float exports.customblips:getCustomBlipStreamRadius ( customblip theBlip )
|width="110pt"|'''setCustomBlipStreamRadius'''
</syntaxhighlight>
|<syntaxhighlight lang="lua">customblip theBlip, float streamRadius</syntaxhighlight>
 
|-
|}


This function gets the world position of a customblip.
* '''setCustomBlipStreamRadius'''
{| class="wikitable" border="0"
** This function sets the current stream radius of a customblip.  Note, stream radius does not affect the F11 map.
|-
<syntaxhighlight lang="lua">
|width="80pt"|<syntaxhighlight lang="lua">float worldX, float worldY</syntaxhighlight>
bool exports.customblips:setCustomBlipStreamRadius ( customblip theBlip, float streamRadius )
|width="110pt"|'''getCustomBlipPosition'''
</syntaxhighlight>
|<syntaxhighlight lang="lua">customblip theBlip</syntaxhighlight>
|-
|}


This function sets the world position of a customblip.
 
{| class="wikitable" border="0"
* '''getCustomBlipPosition'''
|-
** This function gets the world position of a customblip.
|width="80pt"|<syntaxhighlight lang="lua">bool</syntaxhighlight>
<syntaxhighlight lang="lua">
|width="110pt"|'''setCustomBlipPosition'''
float worldX, float worldY exports.customblips:getCustomBlipPosition ( customblip theBlip )
|<syntaxhighlight lang="lua">customblip theBlip, float worldX, float worldY</syntaxhighlight>
</syntaxhighlight>
|-
|}
 
* '''setCustomBlipPosition'''
** This function sets the world position of a customblip.
<syntaxhighlight lang="lua">
bool exports.customblips:setCustomBlipPosition ( customblip theBlip, float worldX, float worldY )
</syntaxhighlight>
 
 
* '''setCustomBlipRadarScale'''
** This function sets the scale (where 0 is invisible, and 1 is 100% size. Going beyond 1 will increase the size) of the blip when it appears on the radar, relative to the size specified during creation.  Passing nil will default to GTA's radar blip size.
<syntaxhighlight lang="lua">
bool exports.customblips:setCustomBlipRadarScale ( customblip theBlip, float scale )
</syntaxhighlight>
 
 
* '''setCustomBlipAlpha'''
** This function sets the alpha (values 0-1) of the blip, allowing the adjustment of transparency.
<syntaxhighlight lang="lua">
bool exports.customblips:setCustomBlipAlpha ( customblip theBlip, float alpha )
</syntaxhighlight>
 
 
* '''setCustomBlipVisible'''
** This function sets the visibility of the blip.  Invisible blips will not be drawn.
<syntaxhighlight lang="lua">
bool exports.customblips:setCustomBlipAlpha ( customblip theBlip, bool visible )
</syntaxhighlight>
 
 
* '''destroyCustomBlip'''
** This function destroys a custom blip.
<syntaxhighlight lang="lua">
bool exports.customblips:destroyCustomBlip ( customblip theBlip )
</syntaxhighlight>


==Examples==
==Examples==
<section show="true" name="Client" class="class">
'''Example 1'''
This example creates a blip that says 'Spawn' at Toreno's house, using GUI
This example creates a blip that says 'Spawn' at Toreno's house, using GUI
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 67: Line 81:
local blip = guiCreateButton ( 0, 0, 25, 20, "Spawn", false )
local blip = guiCreateButton ( 0, 0, 25, 20, "Spawn", false )
guiSetFont(blip,"default-small")
guiSetFont(blip,"default-small")
guiConvertToCustomBlip ( blip, -700, 960, 10 )
exports.customblips:guiConvertToCustomBlip ( blip, -700, 960, 10 )
end
end
)
)
</syntaxhighlight>
</syntaxhighlight>


<section show="true" name="Client" class="class">
 
'''Example 2'''
This example creates an image blip of "icon.png" at 0,0 - assuming the size of the image is 20x20px.
This example creates an image blip of "icon.png" at 0,0 - assuming the size of the image is 20x20px.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()),
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()),
function()
function()
guiConvertToCustomBlip ( 0,0, 20, 20, "icon.png" )
exports.customblips:createCustomBlip ( 0,0, 20, 20, "icon.png" )
end
end
)
)
</syntaxhighlight>
</syntaxhighlight>
[[ru:Resource:Customblips]]

Latest revision as of 18:22, 1 January 2017

The customblips resource allows you to create Blip icons clientside that appear on radar and on the F11 map. Custom blips can be any image or GUI element.

Exported Client functions

  • createCustomBlip
    • This function creates a custom blip using DirectX image functions. If the stream radius is lower than 180, then the blip will only appear when it is visible on the radar.
customblip exports.customblips:createCustomBlip ( float worldX, float worldY, int imageWidth, int imageHeight, string imagePath, [float streamRadius = 500] )


  • guiConvertToCustomBlip
    • This function creates a custom blip using any GUI element. If the stream radius is lower than 180, then the blip will only appear when it is visible on the radar.
gui-elem exports.customblips:guiConvertToCustomBlip ( gui-element blipGUI, float worldX, float worldY, [float streamRadius = 500] )


  • getCustomBlipStreamRadius
    • This function gets the current stream radius of a customblip. Note, stream radius does not affect the F11 map.
float exports.customblips:getCustomBlipStreamRadius ( customblip theBlip )


  • setCustomBlipStreamRadius
    • This function sets the current stream radius of a customblip. Note, stream radius does not affect the F11 map.
bool exports.customblips:setCustomBlipStreamRadius ( customblip theBlip, float streamRadius )


  • getCustomBlipPosition
    • This function gets the world position of a customblip.
float worldX, float worldY exports.customblips:getCustomBlipPosition ( customblip theBlip )


  • setCustomBlipPosition
    • This function sets the world position of a customblip.
bool exports.customblips:setCustomBlipPosition ( customblip theBlip, float worldX, float worldY )


  • setCustomBlipRadarScale
    • This function sets the scale (where 0 is invisible, and 1 is 100% size. Going beyond 1 will increase the size) of the blip when it appears on the radar, relative to the size specified during creation. Passing nil will default to GTA's radar blip size.
bool exports.customblips:setCustomBlipRadarScale ( customblip theBlip, float scale )


  • setCustomBlipAlpha
    • This function sets the alpha (values 0-1) of the blip, allowing the adjustment of transparency.
bool exports.customblips:setCustomBlipAlpha ( customblip theBlip, float alpha )


  • setCustomBlipVisible
    • This function sets the visibility of the blip. Invisible blips will not be drawn.
bool exports.customblips:setCustomBlipAlpha ( customblip theBlip, bool visible )


  • destroyCustomBlip
    • This function destroys a custom blip.
bool exports.customblips:destroyCustomBlip ( customblip theBlip )

Examples

Example 1 This example creates a blip that says 'Spawn' at Toreno's house, using GUI

addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()),
	function()
		local blip = guiCreateButton ( 0, 0, 25, 20, "Spawn", false )
		guiSetFont(blip,"default-small")
		exports.customblips:guiConvertToCustomBlip ( blip, -700, 960, 10 )
	end
)


Example 2 This example creates an image blip of "icon.png" at 0,0 - assuming the size of the image is 20x20px.

addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()),
	function()
		exports.customblips:createCustomBlip ( 0,0, 20, 20, "icon.png" )
	end
)