Upload 8 files
Browse files- car_custom_paintjob.lua +31 -0
- car_rgb_respray.lua +30 -0
- display_vehicle_components.lua +44 -0
- draw_circle.lua +25 -0
- draw_text.lua +29 -0
- draw_texture.lua +30 -0
- player_bones.lua +25 -0
- streetlights.lua +22 -0
car_custom_paintjob.lua
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
script_name('Vehicle Material Texture Example')
|
2 |
+
local mad = require 'MoonAdditions'
|
3 |
+
|
4 |
+
function main()
|
5 |
+
local pj_texture = assert(mad.load_png_texture(getWorkingDirectory() .. '/resource/texture/example/my_paintjob.png'))
|
6 |
+
while true do
|
7 |
+
wait(0)
|
8 |
+
if isPlayerPlaying(PLAYER_HANDLE) then
|
9 |
+
if isCharInAnyCar(PLAYER_PED) and testCheat('MYPJ') then
|
10 |
+
local car = storeCarCharIsInNoSave(PLAYER_PED)
|
11 |
+
local new_r, new_g, new_b = math.random(0, 255), math.random(0, 255), math.random(0, 255)
|
12 |
+
for_each_vehicle_material(car, function(mat)
|
13 |
+
local tex = mat:get_texture()
|
14 |
+
if tex ~= nil and string.sub(tex.name, 1, 1) == '#' then
|
15 |
+
mat:set_texture(pj_texture)
|
16 |
+
end
|
17 |
+
end)
|
18 |
+
end
|
19 |
+
end
|
20 |
+
end
|
21 |
+
end
|
22 |
+
|
23 |
+
function for_each_vehicle_material(car, func)
|
24 |
+
for _, comp in ipairs(mad.get_all_vehicle_components(car)) do
|
25 |
+
for _, obj in ipairs(comp:get_objects()) do
|
26 |
+
for _, mat in ipairs(obj:get_materials()) do
|
27 |
+
func(mat)
|
28 |
+
end
|
29 |
+
end
|
30 |
+
end
|
31 |
+
end
|
car_rgb_respray.lua
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
script_name('Vehicle Material Color Example')
|
2 |
+
local mad = require 'MoonAdditions'
|
3 |
+
|
4 |
+
function main()
|
5 |
+
while true do
|
6 |
+
wait(0)
|
7 |
+
if isPlayerPlaying(PLAYER_HANDLE) then
|
8 |
+
if isCharInAnyCar(PLAYER_PED) and testCheat('RESPRAY') then
|
9 |
+
local car = storeCarCharIsInNoSave(PLAYER_PED)
|
10 |
+
local new_r, new_g, new_b = math.random(0, 255), math.random(0, 255), math.random(0, 255)
|
11 |
+
for_each_vehicle_material(car, function(mat)
|
12 |
+
local r, g, b, a = mat:get_color()
|
13 |
+
if (r == 0x3C and g == 0xFF and b == 0x00) or (r == 0xFF and g == 0x00 and b == 0xAF) then
|
14 |
+
mat:set_color(new_r, new_g, new_b, a)
|
15 |
+
end
|
16 |
+
end)
|
17 |
+
end
|
18 |
+
end
|
19 |
+
end
|
20 |
+
end
|
21 |
+
|
22 |
+
function for_each_vehicle_material(car, func)
|
23 |
+
for _, comp in ipairs(mad.get_all_vehicle_components(car)) do
|
24 |
+
for _, obj in ipairs(comp:get_objects()) do
|
25 |
+
for _, mat in ipairs(obj:get_materials()) do
|
26 |
+
func(mat)
|
27 |
+
end
|
28 |
+
end
|
29 |
+
end
|
30 |
+
end
|
display_vehicle_components.lua
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
script_name('Display Vehicle Components Example')
|
2 |
+
local mad = require 'MoonAdditions'
|
3 |
+
|
4 |
+
function main()
|
5 |
+
while true do
|
6 |
+
wait(0)
|
7 |
+
if isPlayerPlaying(PLAYER_HANDLE) then
|
8 |
+
if isCharInAnyCar(PLAYER_PED) then
|
9 |
+
local car = storeCarCharIsInNoSave(PLAYER_PED)
|
10 |
+
local components = mad.get_all_vehicle_components(car)
|
11 |
+
for i, comp in ipairs(components) do
|
12 |
+
draw_component(comp, i)
|
13 |
+
end
|
14 |
+
end
|
15 |
+
end
|
16 |
+
end
|
17 |
+
end
|
18 |
+
|
19 |
+
function draw_component(component, id)
|
20 |
+
local x, y, z = component.matrix.pos:get()
|
21 |
+
local sx, sy = convert3DCoordsToScreen(x, y, z)
|
22 |
+
draw_text(string.format('Component #%d: ~y~%s', id, component.name), sx, sy, 255, 255, 255)
|
23 |
+
sx = sx + 4
|
24 |
+
-- draw objects
|
25 |
+
local objs = component:get_objects()
|
26 |
+
for i, obj in ipairs(objs) do
|
27 |
+
local mats = obj:get_materials()
|
28 |
+
sy = sy + 12
|
29 |
+
draw_text('Object #' .. i .. ' total materials: ~y~' .. #mats, sx, sy, 255, 255, 255)
|
30 |
+
-- draw materials
|
31 |
+
sx = sx + 4
|
32 |
+
for i, mat in ipairs(mats) do
|
33 |
+
local tex = mat:get_texture()
|
34 |
+
local tex_name = tex and ('~b~~h~~h~' .. tex.name) or '~r~no texture'
|
35 |
+
sy = sy + 12
|
36 |
+
draw_text('Material #' .. i .. ' texture: ' .. tex_name, sx, sy, 255, 255, 255)
|
37 |
+
end
|
38 |
+
sx = sx - 4
|
39 |
+
end
|
40 |
+
end
|
41 |
+
|
42 |
+
function draw_text(str, x, y, r, g, b)
|
43 |
+
mad.draw_text(str, x, y, mad.font_style.SUBTITLES, 0.3, 0.6, mad.font_align.LEFT, 2000, true, false, r, g, b, 255, 1, 0, 30, 30, 30, 120)
|
44 |
+
end
|
draw_circle.lua
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
script_name('Draw Shape Example')
|
2 |
+
local mad = require 'MoonAdditions'
|
3 |
+
|
4 |
+
function main()
|
5 |
+
local circle = mad.shape.new()
|
6 |
+
build_polygon(circle, 100, 100, 70, 100, 200, 0, 0, 200)
|
7 |
+
while true do
|
8 |
+
wait(0)
|
9 |
+
circle:draw(mad.primitive_type.TRIANGLEFAN, true, mad.blend_method.SRCCOLOR, mad.blend_method.SRCCOLOR)
|
10 |
+
end
|
11 |
+
end
|
12 |
+
|
13 |
+
function build_polygon(shape, x, y, c, size, r, g, b, alpha)
|
14 |
+
shape:add_vertex(x, y, r, g, b, alpha)
|
15 |
+
size = size / 2
|
16 |
+
local a = 0
|
17 |
+
local delta = math.pi * 2 / c
|
18 |
+
for i = 0, c do
|
19 |
+
a = a + delta
|
20 |
+
local cx = x + math.cos(a) * size
|
21 |
+
local cy = y + math.sin(a) * size
|
22 |
+
g = 255 - g
|
23 |
+
shape:add_vertex(cx, cy, r, g, b, alpha)
|
24 |
+
end
|
25 |
+
end
|
draw_text.lua
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
script_name('Draw Text Example')
|
2 |
+
local mad = require 'MoonAdditions'
|
3 |
+
|
4 |
+
function main()
|
5 |
+
-- create clock textdraw
|
6 |
+
-- once created textdraw will be visible until it became destroyed or hidden
|
7 |
+
local clock_textdraw = mad.textdraw.new('Test', 10, 350)
|
8 |
+
clock_textdraw.style = mad.font_style.PRICEDOWN
|
9 |
+
clock_textdraw.width = 0.4
|
10 |
+
clock_textdraw.height = 0.82
|
11 |
+
clock_textdraw.outline = 0
|
12 |
+
clock_textdraw.shadow = 1
|
13 |
+
clock_textdraw.background = true
|
14 |
+
clock_textdraw.wrap = 175
|
15 |
+
clock_textdraw:set_text_color(160, 81, 151, 250)
|
16 |
+
clock_textdraw:set_background_color(240, 240, 240, 120)
|
17 |
+
clock_textdraw:set_shadow_color(30, 30, 30, 60)
|
18 |
+
while true do
|
19 |
+
wait(0)
|
20 |
+
clock_textdraw.text = 'System Time: ' .. os.date("%X")
|
21 |
+
if isPlayerPlaying(PLAYER_HANDLE) then
|
22 |
+
if not isCharDead(PLAYER_PED) then
|
23 |
+
local hp_str = string.format('~w~Health: ~r~%d~n~~w~Armor: ~g~%d', getCharHealth(PLAYER_PED), getCharArmour(PLAYER_PED))
|
24 |
+
-- 'draw_text' displays text once for a frame
|
25 |
+
mad.draw_text(hp_str, 10, 372, mad.font_style.MENU, 0.4, 0.9, mad.font_align.LEFT, 640, true, false, 255, 255, 255, 255, 0, 1)
|
26 |
+
end
|
27 |
+
end
|
28 |
+
end
|
29 |
+
end
|
draw_texture.lua
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
script_name('Textures Example')
|
2 |
+
local mad = require 'MoonAdditions'
|
3 |
+
|
4 |
+
function main()
|
5 |
+
local textures_path = getWorkingDirectory() .. '/resource/texture/example/'
|
6 |
+
local dds_texture = assert(mad.load_dds_texture(textures_path .. 'example_dds.dss'))
|
7 |
+
local png_texture = assert(mad.load_png_texture(textures_path .. 'example_png.png'))
|
8 |
+
local bmp_texture = assert(mad.load_bmp_texture_with_mask(textures_path .. 'example_bmp.bmp', textures_path .. 'example_bmp_a.bmp'))
|
9 |
+
local txd = assert(mad.load_txd(getWorkingDirectory() .. '/resource/txd/example/example_txd.txd'))
|
10 |
+
local texture_from_txd = assert(txd:get_texture('example_txd'))
|
11 |
+
while true do
|
12 |
+
wait(0)
|
13 |
+
local resx, resy = getScreenResolution()
|
14 |
+
local x, y = 120, 120
|
15 |
+
local width, height = resx - 120 * 2, resy - 120 * 2
|
16 |
+
mad.draw_rect_with_gradient(x, y, x + width, y + height, --[[1]] 220, 220, 220, 240, --[[2]] 128, 158, 182, 240, --[[3]] 220, 220, 220, 240, --[[4]] 220, 220, 220, 240)
|
17 |
+
|
18 |
+
local tex_w = (width - 20 * 3) / 2
|
19 |
+
local tex_h = (height - 30 * 3) / 2
|
20 |
+
function display_texture(tex, x, y)
|
21 |
+
tex:draw(x, y, x + tex_w, y + tex_h)
|
22 |
+
mad.draw_text(tex.name, x, y + tex_h + 2)
|
23 |
+
end
|
24 |
+
|
25 |
+
display_texture(png_texture, x + 20, y + 20)
|
26 |
+
display_texture(bmp_texture, x + tex_w + 20 + 20, y + 20)
|
27 |
+
display_texture(dds_texture, x + 20, y + tex_h + 20 + 30)
|
28 |
+
display_texture(texture_from_txd, x + tex_w + 20 + 20, y + tex_h + 20 + 30)
|
29 |
+
end
|
30 |
+
end
|
player_bones.lua
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
script_name('Display Player Bones Example')
|
2 |
+
local mad = require 'MoonAdditions'
|
3 |
+
|
4 |
+
function main()
|
5 |
+
while true do
|
6 |
+
wait(0)
|
7 |
+
if isPlayerPlaying(PLAYER_HANDLE) then
|
8 |
+
if isCharOnFoot(PLAYER_PED) and not isCharDead(PLAYER_PED) then
|
9 |
+
local color_b = 255
|
10 |
+
for name, id in pairs(mad.bone_id) do
|
11 |
+
local bone = mad.get_char_bone(PLAYER_PED, id)
|
12 |
+
if bone then
|
13 |
+
local bone_pos = bone.matrix.pos
|
14 |
+
local sx, sy = convert3DCoordsToScreen(bone_pos.x, bone_pos.y, bone_pos.z)
|
15 |
+
draw_text('#' .. id .. ': ' .. name, sx, sy, 255, 255, math.fmod(id, 2) == 1 and 255 or 120)
|
16 |
+
end
|
17 |
+
end
|
18 |
+
end
|
19 |
+
end
|
20 |
+
end
|
21 |
+
end
|
22 |
+
|
23 |
+
function draw_text(str, x, y, r, g, b)
|
24 |
+
mad.draw_text(str, x, y, mad.font_style.SUBTITLES, 0.3, 0.6, mad.font_align.LEFT, 2000, true, false, r, g, b, 255, 1, 0, 30, 30, 30, 120)
|
25 |
+
end
|
streetlights.lua
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
script_name('Spotlight Example')
|
2 |
+
local mad = require 'MoonAdditions'
|
3 |
+
|
4 |
+
function main()
|
5 |
+
while true do
|
6 |
+
wait(0)
|
7 |
+
if isPlayerPlaying(PLAYER_HANDLE) then
|
8 |
+
local x, y, z = getCharCoordinates(PLAYER_PED)
|
9 |
+
for _, object in ipairs(mad.get_all_objects(x, y, z, 300)) do
|
10 |
+
local model = getObjectModel(object)
|
11 |
+
if model == 1226 and getObjectHealth(object) > 0 then
|
12 |
+
local matrix = mad.get_object_matrix(object)
|
13 |
+
if matrix then
|
14 |
+
local objx, objy, objz = matrix:get_coords_with_offset(-1.3, 0.165, 3.69)
|
15 |
+
local ground_z = getGroundZFor3dCoord(objx, objy, objz)
|
16 |
+
mad.draw_spotlight(objx, objy, objz, objx, objy, ground_z, 0.065, 27)
|
17 |
+
end
|
18 |
+
end
|
19 |
+
end
|
20 |
+
end
|
21 |
+
end
|
22 |
+
end
|