Jump to content

Ediția 10 de Miss&Mister B-Zone a început. Aplicați aici

Recrutăm designeri audio și video. Aplicați aici

Sign in to follow this  
D J C

[CLEO] / [HELP] Const function

Recommended Posts

  • Problem description:

Can you give explanations of const function and where can be used for ?!

 

  • Code (the source on which to help you, if necessary):
const
_WHITE = 0xFFFFFF
_RED = 0xFF0000
_BLUE = 0x0000FF
end

 

  • Other remarks:

My issue:

chatmsg "{%x}Test red color, {%x}Test blue color, {%x}Test white color." -1 _RED _BLUE _WHITE

Output:

Test red color, [0000FF]Test blue color, Test white color.

Share this post


Link to post
Share on other sites
Posted (edited)

Hi,

 

const can be use for define some variables, like integers, floats or colors which always have the same value

 

const
max_numbers = 10
max_distance = 25.0
COLOR_RED = 0xFF0000
end

 

if 0@ == max_numbers
then
        some code ...
end

if 0@ == max_distance
then
        some code ...
end

chatmsg "{%x}This is a message" -1 COLOR_RED

 

Unfortunately it cannot be used for the string, because it does not allow the use of space to separate two or more words, but only one single word with a small number of characters.

cont
specific_word = "house"
end

if 0C29: 33@ = stristr string1 0@ string2 specific_word
then
        some code ...
end

 

Edited by Tupi

Share this post


Link to post
Share on other sites
{$CLEO}
{$CLEO .cs}

//----MAIN----

03A4: name_thread "test"
0001: wait 609 ms

0B34: samp register_client_command "test" to_label @test

const
_WHITE = 0xFFFFFF
_RED = 0xFF0000
_BLUE = 0x0000FF
end

:looper
0001: wait 0 ms
0002: jump @looper

  
:test
chatmsg "{%x}Test red color, {%x}Test blue color, {%x}Test white color." -1 _RED _BLUE _WHITE
0B43: samp cmd_ret

 

Output:

 

Ai8hFAf.png

Share this post


Link to post
Share on other sites

Try to use a different hex code for blue color.

Share this post


Link to post
Share on other sites

I realized that when the hex color code starts from 0x0_ _ _ _ _, unfortunately, the bug I put in the previous comment will be created.

 

const
_BLUE = 0x0000FF
end

chatmsg "{%x}Test blue color" -1 _BLUE

The output will be like this > {FF}Test blue color

kinda buggy

 

Code:

{$CLEO}
{$CLEO .cs}

//----MAIN----

03A4: name_thread "test"
0001: wait 609 ms

0B34: samp register_client_command "test" to_label @test

const
_WHITE = 0xFFFFFF
_RED = 0xFF0000
_YELLOW = 0xFFFF1A
_BLACK = 0x141414
_BLUE = 0x8C1AFF
_ORANGE = 0xFF8C1A
_SFSI = 0x11FF82
_PD = 0x1E519D
_NEWS = 0xC2A2DA
end

:looper
0001: wait 0 ms
0002: jump @looper

  
:test
chatmsg "{%x}Test red color, {%x}Test blue color, {%x}Test white color." -1 _RED _YELLOW _WHITE
chatmsg "{%x}Test BLACK color, {%x}Test BLUE color, {%x}Test ORANGE color." -1 _BLACK _BLUE _ORANGE
chatmsg "{%x}Test SI color, {%x}Test PD color, {%x}Test NEWS color." -1 _SFSI _PD _NEWS
0B43: samp cmd_ret

 

Output:

9VD5EXC.png

 

 

Anyway thanks,

the main problem solved.

Share this post


Link to post
Share on other sites

:topic_closed:

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.