CLEO Help Say a different message depending on the server hour

CLEO related

morgenstern09

Member
Joined
Apr 22, 2021
Messages
8
Reaction score
0
Location
Earth
Hello,

As the title says, I would like a CLEO script to show a different message depending on the current server hour.

To be more precise, I would like to have a function that if the hour is past 19, for example, it will say "Have a nice evening", and if it's past 06 am it would say "Have a nice day".

This would happen when I type a certain command in chat.

I already got the command typing stuff, but I don't really know how to do the message according to the server hour part.

Any help would be appreciated.
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,112
Solutions
5
Reaction score
878
Location
Lithuania
PHP:
{$CLEO .cs}

0000:

wait 8500

while true
wait 0

if 0256:   player $PLAYER_CHAR defined
then
    for 0@ = 0 to 2048 // 2048 = max TextDraw ID in decimal
        if 0AB1: @IsSampTextDrawExist 1 TextDrawID 0@
        then
            0AB1: @GetTextDrawText 1 TextDrawID 0@ _Returned: Text 1@
            if 0AD4: $NOT_USED = scan_string 1@ format "%d:%d:%d" 2@ 3@ 4@
            then
                if and
                2@ == 6 
                3@ == 0
                then
                    // do something...
                end
            end
        end
    end
end

end

:IsSampTextDrawExist
{
    0.3.7 - R1
    0AB1: @IsSampTextDrawExist 1 TextDrawID 0@
}
0AA2: 1@ = load_library "samp.dll"
1@ += 0x21A0F8 // SAMP_INFO_OFFSET
0A8D: 1@ readMem 1@ sz 4 vp 0
1@ += 0x3CD // SAMP_PPOOLS_OFFSET
0A8D: 1@ readMem 1@ sz 4 vp 0
1@ += 0x10 // SAMP_PPOOL_TEXTDRAW_OFFSET
0A8D: 1@ readMem 1@ sz 4 vp 0
0@ *= 0x4 // TEXTDRAW_ID * 4
005A: 1@ += 0@
0A8D: 2@ readMem 1@ sz 4 vp 0
IF 2@ == TRUE
THEN 0485:  return_true
ELSE 059A:  return_false
END
0AB2: 0

:GetTextDrawText
{
    0.3.7 - R1
    0AB1: @GetTextDrawText 1 TextDrawID 0@ _Returned: Text 1@
}
0AA2: 1@ = load_library "samp.dll"
1@ += 0x21A0F8 // SAMP_INFO_OFFSET
0A8D: 1@ readMem 1@ sz 4 vp 0
1@ += 0x3CD // SAMP_PPOOLS_OFFSET
0A8D: 1@ readMem 1@ sz 4 vp 0
1@ += 0x10 // SAMP_PPOOL_TEXTDRAW_OFFSET
0A8D: 1@ readMem 1@ sz 4 vp 0
0@ *= 0x4 // TEXTDRAW_ID * 4
005A: 1@ += 0@
0A8D: 2@ readMem 1@ sz 4 vp 0
IF 2@ == TRUE
THEN
    0485:  return_true
    1@ += 0x2400  // SAMP_TEXTDRAW_STRUCT_OFFSET
    0A8D: 1@ readMem 1@ sz 4 vp 0
    1@ += 0x0 // SAMP_TEXTDRAW_TEXT_OFFSET
    0AB2: 1 1@
ELSE 059A:  return_false
END
0AB2: 0
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,112
Solutions
5
Reaction score
878
Location
Lithuania
Sorry for the silence...

I want to try the code, but this is what Sanny Builder says:

https://i.postimg.cc/X7BsbbMG/image.png

If I do a comparison to a digit instead of doing it to "TRUE", then compiling works.

What could be wrong?
Not sure maybe your sanny builder version is diffretent.

I using 3.3.3 version, not rly liked updated version.


Here is compiled file:
 

Attachments

  • IDK.cs
    19.3 KB · Views: 6

morgenstern09

Member
Joined
Apr 22, 2021
Messages
8
Reaction score
0
Location
Earth
I installed Sanny Builder 3.3.3, but I still get the same error.

Would it be possible to share your SB installation folder, or maybe just the SB data folder for GTA SA?

It should have something to do with the OPCODEs configs.
 

morgenstern09

Member
Joined
Apr 22, 2021
Messages
8
Reaction score
0
Location
Earth
I just tested your code now in my script, and it works as intended!
https://i.postimg.cc/3Rrrzhwz/image.png


I already have a "WHILE" loop, and I put the code there (I'm not sure why I did that, I had an idea at first. Maybe I'll just put it in a separate function):
https://i.postimg.cc/L8hbCbRv/image.png

EDIT: I put it in the while loop because that's how it was in your example, actually. I already had something in the while loop, and I just put this additional code as well, and made it so you can trigger the hour check when needed.


I trigger this part with:
https://i.postimg.cc/NM8J2h7G/image.png


And I have the other two parts of your code at the end of the script:
https://i.postimg.cc/RVpPHLft/image.png


I can't seem to be able to link images, so I put the links instead.

Thanks again!
 

morgenstern09

Member
Joined
Apr 22, 2021
Messages
8
Reaction score
0
Location
Earth
Also...
Make sure you have right settings...

Thanks, I already did that again. When I had the previous version of Sanny Builder, I had the issue with the text in all-caps, so I knew about it.

I will try your data folder with the latest version of SB. It should work fine, as the issue here was the data folder, and not the SB version.
 
Top