Skip to content

Commit ba7f7f2

Browse files
committed
Blip functions
1 parent 967b41a commit ba7f7f2

37 files changed

+606
-87
lines changed

functions/Blip/createBlip.yaml

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,75 @@
1-
# Scraped from: https://wiki.multitheftauto.com/wiki/createBlip
21
shared: &shared
32
name: createBlip
4-
description: TODO
5-
incomplete: true
6-
3+
description: This function creates a [[blip]] element, which is displayed as an icon on the client's radar.
4+
oop:
5+
element: blip
6+
constructorclass: Blip
7+
parameters:
8+
- name: x
9+
type: float
10+
description: The x position of the blip, in world coordinates.
11+
- name: 'y'
12+
type: float
13+
description: The y position of the blip, in world coordinates.
14+
- name: z
15+
type: float
16+
description: The z position of the blip, in world coordinates.
17+
- name: icon
18+
type: int
19+
description: The icon that the radar blips should be. Default is 0. Valid values can be seen at [Radar Blips](/reference/ID_Lists/Blips).
20+
default: '0'
21+
- name: size
22+
type: int
23+
description: The size of the radar blip. Only applicable to the Marker icon. Default is 2. Maximum is 25.
24+
default: '2'
25+
- name: r
26+
type: int
27+
description: The amount of red in the blip's color (0-255). Only applicable to the Marker icon. Default is 255.
28+
default: '255'
29+
- name: g
30+
type: int
31+
description: The amount of green in the blip's color (0-255). Only applicable to the Marker icon. Default is 0.
32+
default: '0'
33+
- name: b
34+
type: int
35+
description: The amount of blue in the blip's color (0-255). Only applicable to the Marker icon. Default is 0.
36+
default: '0'
37+
- name: a
38+
type: int
39+
description: The amount of alpha in the blip's color (0-255). Only applicable to the Marker icon. Default is 255.
40+
default: '255'
41+
- name: ordering
42+
type: int
43+
description: This defines the blip's Z-level ordering (-32768-32767). Default is 0.
44+
default: '0'
45+
- name: visibleDistance
46+
type: float
47+
description: The maximum distance from the camera at which the blip is still visible (0-65535).
48+
default: '16383.0'
49+
- name: visibleTo
50+
type: element
51+
description: This defines which elements can see the blip. Defaults to visible to everyone. See [[visibility]].
52+
default: 'getRootElement()'
53+
returns:
54+
values:
55+
- type: blip|false
56+
name: created-blip
57+
description: Returns an element of the [[blip]] if it was created successfully, false otherwise.
58+
preview_images:
59+
- path: radar-blip.png
60+
description: Example blip.
761
server:
862
<<: *shared
63+
examples:
64+
- path: examples/createBlip-1.lua
65+
description: This example creates a radar [[blip]] at a random player's position and makes it so that it is only visible to that player.
66+
- path: examples/createBlip_OOP-1.lua
67+
description: This example creates a radar [[blip]] at a random player's position and makes it so that it is only visible to that player.
68+
oop: true
69+
- path: examples/createBlip-2.lua
70+
description: This example attaches a blip to a player. You can attach a blip to an element by just setting the blip's parent to that element.
971
client:
10-
<<: *shared
72+
<<: *shared
73+
ignore_parameters:
74+
- visibleTo
75+
Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,65 @@
1-
# Scraped from: https://wiki.multitheftauto.com/wiki/createBlipAttachedTo
21
shared: &shared
32
name: createBlipAttachedTo
4-
description: TODO
5-
incomplete: true
6-
3+
description: This function creates a [[blip]] that is attached to an [[element]]. This blip is displayed as an icon on the client's radar and will 'follow' the element that it is attached to around.
4+
oop:
5+
element: blip
6+
method: createAttachedTo
7+
static: true
8+
parameters:
9+
- name: elementToAttachTo
10+
type: element
11+
description: The [[element]] to attach the blip to.
12+
- name: icon
13+
type: int
14+
description: The icon that the radar blips should be. Default is 0. Valid values can be seen at [Radar Blips](/reference/ID_Lists/Blips).
15+
default: '0'
16+
- name: size
17+
type: int
18+
description: The size of the radar blip. Only applicable to the Marker icon. Default is 2. Maximum is 25.
19+
default: '2'
20+
- name: r
21+
type: int
22+
description: The amount of red in the blip's color (0-255). Only applicable to the Marker icon. Default is 255.
23+
default: '255'
24+
- name: g
25+
type: int
26+
description: The amount of green in the blip's color (0-255). Only applicable to the Marker icon. Default is 0.
27+
default: '0'
28+
- name: b
29+
type: int
30+
description: The amount of blue in the blip's color (0-255). Only applicable to the Marker icon. Default is 0.
31+
default: '0'
32+
- name: a
33+
type: int
34+
description: The amount of alpha in the blip's color (0-255). Only applicable to the Marker icon. Default is 255.
35+
default: '255'
36+
- name: ordering
37+
type: int
38+
description: This defines the blip's Z-level ordering (-32768-32767). Default is 0.
39+
default: '0'
40+
- name: visibleDistance
41+
type: float
42+
description: The maximum distance from the camera at which the blip is still visible (0-65535).
43+
default: '16383.0'
44+
- name: visibleTo
45+
type: element
46+
description: This defines which elements can see the blip. Defaults to visible to everyone. See [[visibility]].
47+
default: 'getRootElement()'
48+
returns:
49+
values:
50+
- type: blip|false
51+
name: created-blip
52+
description: Returns an element of the [[blip]] if it was created successfully, false otherwise.
753
server:
854
<<: *shared
55+
examples:
56+
- path: examples/createBlipAttachedTo-1.lua
57+
description: This example creates a radar [[blip]] attached to a random [[player]], visible to everyone. The blip will follow the player around as they move. This could be used for manhunt, to emphasise a random player.
58+
- path: examples/createBlipAttachedTo_OOP-1.lua
59+
description: This example creates a radar [[blip]] attached to a random [[player]], visible to everyone. The blip will follow the player around as they move. This could be used for manhunt, to emphasise a random player.
60+
oop: true
961
client:
10-
<<: *shared
62+
<<: *shared
63+
ignore_parameters:
64+
- visibleTo
65+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Pick a random player
2+
local myPlayer = getRandomPlayer( )
3+
-- Retrieve the player's position and store it in the variables x, y and z
4+
local x, y, z = getElementPosition( myPlayer )
5+
-- Create a radar blip at the player's position, with a 'cash' icon and only visible to the player
6+
local myBlip = createBlip( x, y, z, 51, 0, 0, 0, 255, myPlayer )
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Pick a random player
2+
local myPlayer = getRandomPlayer( )
3+
-- Create a radar blip in the middle of the map
4+
local myBlip = createBlip( 0, 0, 0 )
5+
-- Make the player the parent of the blip, so that the blip follows the player around
6+
setElementParent( myBlip, myPlayer )
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Pick a random player
2+
function setupRandomRobber ()
3+
local myPlayer = getRandomPlayer ()
4+
-- Create a radar blip at the player's position, with a 'cash' icon and only visible to everyone (no 'visibleTo' parameter)
5+
local myBlip = createBlipAttachedTo ( myPlayer, 52 )
6+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Pick a random player
2+
function setupRandomRobber ()
3+
local myPlayer = Player.getRandom()
4+
-- Create a radar blip at the player's position, with a 'cash' icon and only visible to everyone (no 'visibleTo' parameter)
5+
local myBlip = Blip.createAttachedTo ( myPlayer, 52 )
6+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Pick a random player
2+
local myPlayer = Player.getRandom()
3+
-- Retrieve the player's position and store it in the variables x, y and z
4+
local x, y, z = myPlayer.position
5+
-- Create a radar blip at the player's position, with a 'cash' icon and only visible to the player
6+
local myBlip = Blip( x, y, z, 51, 0, 0, 0, 255, myPlayer )
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- Retrieve a table containing all the blips that exist
2+
local blips = getElementsByType ( "blip" )
3+
-- Loop through the list, storing the blip from the table in the variable blipValue
4+
for blipKey, blipValue in ipairs(blips) do
5+
-- Retrieve the blip's colors into the variables red, green, blue and alpha
6+
local red, green, blue, alpha = getBlipColor ( blipValue )
7+
-- If the blip's icon isn't white already
8+
if ( red ~= 255 or green ~= 255 or blue ~= 255 or alpha ~= 255 ) then
9+
-- Set the blip's color to white
10+
setBlipColor ( blipValue, 255, 255, 255, 255 )
11+
end
12+
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- Retrieve a table containing all the blips that exist
2+
local blips = Element.getAllByType ( "blip" )
3+
-- Loop through the list, storing the blip from the table in the variable blipValue
4+
for blipKey, blipValue in ipairs(blips) do
5+
-- Retrieve the blip's colors into the variables red, green, blue and alpha
6+
local red, green, blue, alpha = blipValue:getColor()
7+
-- If the blip's icon isn't white already
8+
if ( red ~= 255 or green ~= 255 or blue ~= 255 or alpha ~= 255 ) then
9+
-- Set the blip's color to white
10+
blipValue:setColor( 255, 255, 255, 255 )
11+
end
12+
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- Retrieve a table containing all the blips that exist
2+
local blips = getElementsByType ( "blip" )
3+
-- Loop through the list, storing the blip from the table in the variable blipValue
4+
for blipKey, blipValue in ipairs(blips) do
5+
-- Retrieve the blip's icon into the variable 'blipIcon'
6+
local blipIcon = getBlipIcon ( blipValue )
7+
-- If the blip's icon wasn't the default already
8+
if ( blipIcon ~= 0 ) then
9+
-- Set the blip's icon to the default
10+
setBlipIcon ( blipValue, 0 )
11+
end
12+
end

0 commit comments

Comments
 (0)