Rainbow

DenisOfficial

New member
Joined
Jun 11, 2018
Messages
4
Reaction score
0
Hi, i want do to rainbow stuff (Hud) (Car) (radardisc) etc.... how can i start?
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
[shcode=cpp]
{$CLEO}

thread "Rainbow"

if not 0@ = SAMP.Base()
then 0A93: end_custom_thread
end
while not SAMP.Available()
wait 100
end


Dialog.Create(1@, "{05cc02}Dialog")
Dialog.AddStatic(1@,1, "{ffffff}RAINBOW ON OFF", 130, 10, 600, 30)
Dialog.AddButton(1@,2,"{05cc02}HUD ON", 15, 40, 140, 30 )
Dialog.AddButton(1@,3,"{05cc02}HUD OFF", 180, 40, 140, 30 )
Dialog.AddButton(1@,36,"{05cc02}Close Menu", 180, 205, 130, 30 )

0B5A: get_screen_resolution 2@ 3@
3@ /= 2
2@ /=2
2@ +=100
0B84: samp dialog 1@ set_pos_XY 2@ 3@ size 325 380
0B86: samp dialog 1@ set_visible false

0B34: samp register_client_command "dialog" to_label @cmd

WHILE TRUE
wait 0

if 4@ == 1
then
0B8D: samp set_cursor_mode 2
0B86: samp dialog 1@ set_visible true
if 0AB0: key_pressed 1
then
0B5E: get_cursor_pos 28@ 27@
0B85: samp dialog 1@ get_position_to 26@ 25@ size_to 0@ 0@
if and
001D: 28@ > 26@
001D: 27@ > 25@
then
26@ += 340
25@ += 20
if and
001D: 26@ > 28@
001D: 25@ > 27@
then
26@ -= 340
25@ -= 20
0062: 28@ -= 26@
0062: 27@ -= 25@
while 0AB0: key_pressed 1
wait 0
0B5E: get_cursor_pos 26@ 25@
0062: 26@ -= 28@
0062: 25@ -= 27@
0B84: samp dialog 1@ set_pos_XY 26@ 25@ size 325 380
end
end
end
end

if
Dialog.PopEvent(1@, 5@, 6@)
then
if and
6@ == 2
5@ == 257
then
printf "~Y~Rainbow Hud ~G~ON" 1300
18@ = TRUE
END
IF AND
6@ == 3
5@ == 257
THEN
printf "~Y~Rainbow Hud ~R~OFF" 1300
18@ = FALSE
END
if and
6@ == 36
5@ == 257
then
0B8D: samp set_cursor_mode 0
0B86: samp dialog 1@ set_visible false
printf "~Y~Dialog ~R~CLOSED" 1300
4@ = 0
end
end
end



call @ShiftColorHue 3 speed_step 1{Change 1 to bigger if u wanna change rainbow speed} direction 1 hue_var 31@ _returned_hue_var 31@ // it increases/decreases 31@ variable between 0-359
call @GetCLRfromHSV 3 hue 31@ saturation 1.0 value 1.0 _returnedColor 11@ 12@ 13@

if 18@ == TRUE
then
0B67: render a 0xFF r 11@ g 12@ b 13@ to_argb 14@
0A8C: write_memory 0xBAB22C size 4 value 14@ virtual_protect 0
0A8C: write_memory 0xBAB230 size 4 value 14@ virtual_protect 0
0A8C: write_memory 0xBAB238 size 4 value 14@ virtual_protect 0
0A8C: write_memory 0xBAB240 size 4 value 14@ virtual_protect 0
0A8C: write_memory 0xBAB244 size 4 value 14@ virtual_protect 0
0A8C: write_memory 0xBAB24C size 4 value 14@ virtual_protect 0
0A8C: write_memory 0xBAB258 size 4 value 14@ virtual_protect 0
0A8C: write_memory 0x005507C0 size 4 value 14@ virtual_protect 0

for 15@ = 0 to 9400
if 0C5D: samp textdraw 15@ is_exists
then
0C5C: samp textdraw 15@ get_letter_size 16@ 17@ color -1
0C52: samp textdraw 15@ set_letter_size 16@ 17@ color 14@
end
end
end



END

:RYB_to_RGB_GetSingleClr
{
0@ - R
1@ - Y
2@ - B

3@ - front_up_left : [1, 1, 0],
4@ - front_up_right: [1, 0.5, 0],
5@ - "front_down_left": [1, 1, 1],
6@ - "front_down_right": [1, 0, 0],
7@ - "back_up_left": [0, 0.66, 0.2],
8@ - "back_up_right": [0.2, 0.094, 0],
9@ - "back_down_left": [0.163, 0.373, 0.6],
10@ - "back_down_right": [0.5, 0.0, 0.5],
}

/*
3@ *= 255.0
4@ *= 255.0
5@ *= 255.0
6@ *= 255.0
7@ *= 255.0
8@ *= 255.0
9@ *= 255.0
10@ *= 255.0
*/
//chatmsg "%.2f %.2f %.2f" -1 0@ 1@ 2@
call @Interpolate 5 val 0@ range 0.0 255.0 front_up_left 3@ front_up_right 4@ _side_front_up 11@
call @Interpolate 5 val 0@ range 0.0 255.0 front_down_left 5@ front_down_right 6@ _side_front_down 12@
call @Interpolate 5 val 0@ range 0.0 255.0 back_up_left 7@ back_up_right 8@ _side_back_up 13@
call @Interpolate 5 val 0@ range 0.0 255.0 back_down_left 9@ back_down_right 10@ _side_back_down 14@

//chatmsg "%.2f %.2f %.2f %.2f" -1 11@ 12@ 13@ 14@

call @Interpolate 5 val 1@ range 0.0 255.0 side_front_down 12@ side_front_up 11@ _side_vert_front 15@
call @Interpolate 5 val 1@ range 0.0 255.0 side_back_down 14@ side_back_up 13@ _side_vert_back 16@

call @Interpolate 5 val 2@ range 0.0 255.0 side_vert_front 15@ side_vert_back 16@ _returnedValue 17@

/*
sideways_front_up = Interpolate(r, [0,1], [
RYB_RGB_cube["front_up_left"],
RYB_RGB_cube["front_up_right"]
])

sideways_front_down = Interpolate(r, [0,1], [
RYB_RGB_cube["front_down_left"],
RYB_RGB_cube["front_down_right"]
])

sideways_back_up = Interpolate(r, [0,1], [
RYB_RGB_cube["back_up_left"],
RYB_RGB_cube["back_up_right"]
])

sideways_back_down = Interpolate(r, [0,1], [
RYB_RGB_cube["back_down_left"],
RYB_RGB_cube["back_down_right"]
])
*/

//17@ *= 255.0
0092: 17@ = float 17@ to_integer
ret 1 17@

:RYB_to_RGB
{
0@ 1@ 2@ - Red, Yellow, Blue (integers 0-255)
More info and python example: https://github.com/michalmonday/RGB_rainbowLoop/blob/master/RYB_RGB_conversion_rainbowLoop.py
}
0093: 0@ = integer 0@ to_float
0093: 1@ = integer 1@ to_float
0093: 2@ = integer 2@ to_float

call @RYB_to_RGB_GetSingleClr 11 RYB 0@ 1@ 2@ interpolation_cube_corners 255.0 255.0 255.0 255.0 0.0 51.0 41.565 127.5 _returnedRed 21@
call @RYB_to_RGB_GetSingleClr 11 RYB 0@ 1@ 2@ interpolation_cube_corners 255.0 127.5 255.0 0.0 168.3 23.97 95.115 0.0 _returnedGreen 22@
call @RYB_to_RGB_GetSingleClr 11 RYB 0@ 1@ 2@ interpolation_cube_corners 0.0 0.0 255.0 0.0 51.0 0.0 153.0 127.5 _returnedBlue 23@

ret 3 21@ 22@ 23@

:Interpolate
{
All floats:
0@ - value
1@ - Lower border of initial range
2@ - Higher border of initial range
3@ - Lower border of desired range
4@ - Higher border of desired range
}
0087: 31@ = 2@ // float
0063: 31@ -= 1@ // (s[1] - s[0])
0063: 0@ -= 1@ // (val - s[0])
0087: 30@ = 4@ // float
0063: 30@ -= 3@ // (s2[1] - s2[0])
006B: 30@ *= 0@ // (s2[1] - s2[0]) * (val - s[0])
0073: 30@ /= 31@ // (s2[1] - s2[0]) * (val - s[0]) / (s[1] - s[0])
005B: 3@ += 30@ // (float)
ret 1 3@



//call @ShiftColor 2 speed_step 3 direction 1 variable_keeping_track 31@
:ShiftColorHue
{
0@ - speed_step - how fast the color change occurs
1@ - direction (1-rgb order, 2-reversed order)
2@ - hue variable which needs to be dedicated for this snippet (it's actually the only variable that is required in external code for this snippet)
}
if 1@ == 1
then
005A: 2@ += 0@ // (int)
if 2@ > 359
then
2@ = 0
end
end

if 1@ == 2
then
0062: 2@ -= 0@ // (int)
if 001B: 0 > 2@
then
2@ = 359
end
end
ret 1 2@

//call @GetRGBfromHSV 3 hue 31@ saturation 1.0 value 1.0 _returnedRGB 1@ 2@ 3@
:GetCLRfromHSV
{
0@ - Hue (0 - 360 int)
1@ - Saturation (0.0 - 1.0 float)
2@ - Value (0.0 - 1.0 float)
}
0085: 25@ = 0@ // hue copy
0093: 0@ = integer 0@ to_float

//C = value * saturation
0087: 31@ = 1@ // C
006B: 31@ *= 2@ // C

//X = C * (1.0 - abs((hue/60.0)%2 - 1.0))
0087: 30@ = 0@ // hue
30@ /= 60.0 // (hue/60.0)

if and // fix for the bugged 0b14 (when float is used, idk if it happens with int too)
30@ >= 2.0
0023: 4.0 > 30@
then
30@ -= 2.0
else
if and
30@ >= 4.0
0023: 6.0 > 30@
then
30@ -= 4.0
else
if and
30@ >= 6.0
0023: 8.0 > 30@
then
30@ -= 6.0
end
end
end

0B14: 30@ = 30@ MOD 2.0 // sampfuncs modulo function is probably not working for numbers that are at least twice as big, or because it's float... idk
//printf "X= %.2f" 1000 30@
30@ -= 1.0
0097: make 30@ absolute_float
29@ = 1.0
0063: 29@ -= 30@ // (1.0 - abs((hue/60.0)%2 - 1.0))
0087: 30@ = 31@ // X = C *
006B: 30@ *= 29@ // X = C * (1.0 - abs((hue/60.0)%2 - 1.0))

//m = value - C
0087: 29@ = 2@
0063: 29@ -= 31@ // m = value - C

// C = 31@
// X = 30@
// m = 29@

//printf "C= %.2f X= %.2f m= %.2f" 1000 31@ 30@ 29@

//sectionList (0 - 0, C - 1, X - 2)
alloc 28@ 100
0085: 27@ = 28@ // (int)
0085: 26@ = 28@ // (int)

//[C, X, 0],
0A8C: write_memory 28@ size 4 value 1 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 2 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 0 virtual_protect 0
28@+=4

//[X, C, 0],
0A8C: write_memory 28@ size 4 value 2 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 1 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 0 virtual_protect 0
28@+=4

//[0, C, X],
0A8C: write_memory 28@ size 4 value 0 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 1 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 2 virtual_protect 0
28@+=4

//[0, X, C],
0A8C: write_memory 28@ size 4 value 0 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 2 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 1 virtual_protect 0
28@+=4

//[X, 0, C],
0A8C: write_memory 28@ size 4 value 2 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 0 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 1 virtual_protect 0
28@+=4

//[C, 0, X],
0A8C: write_memory 28@ size 4 value 1 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 0 virtual_protect 0
28@+=4
0A8C: write_memory 28@ size 4 value 2 virtual_protect 0


//section = sectionList[hue/60]
25@ /= 60 // hue/60
25@ *= 12
005A: 27@ += 25@ // (int)
0A8D: 21@ = read_memory 27@ size 4 virtual_protect 0
27@ += 4
0A8D: 22@ = read_memory 27@ size 4 virtual_protect 0
27@ += 4
0A8D: 23@ = read_memory 27@ size 4 virtual_protect 0

// 21@ 22@ 23@ have now values from 0 to 2 (they're just indicators)
0093: 21@ = integer 21@ to_float
0093: 22@ = integer 22@ to_float
0093: 23@ = integer 23@ to_float
call @AssignHSVSectionValue 3 21@ 31@ 30@ _ret 21@
call @AssignHSVSectionValue 3 22@ 31@ 30@ _ret 22@
call @AssignHSVSectionValue 3 23@ 31@ 30@ _ret 23@

005A: 21@ += 29@ // (int)
005A: 22@ += 29@ // (int)
005A: 23@ += 29@ // (int)
21@ *= 255.0
22@ *= 255.0
23@ *= 255.0
0092: 21@ = float 21@ to_integer
0092: 22@ = float 22@ to_integer
0092: 23@ = float 23@ to_integer

free 26@

ret 3 21@ 22@ 23@

:AssignHSVSectionValue
{
0@ - indicator_1
1@ - val_C
2@ - val_X
}
if 0@ == 0.0
then
ret 1 0.0
else
if 0@ == 1.0
then
ret 1 1@
else
if 0@ == 2.0
then
ret 1 2@
end
end
end
ret 1 0.0

:cmd
4@ = TRUE
cmdret
[/shcode]
 

ini

Well-known member
Joined
Sep 28, 2015
Messages
321
Reaction score
115
This must be a joke, there is a plague of Romanians asking for rainbow and imgui shit!
 
Top