Help [CLEO] Help with timer script

easanchez

Member
Joined
Nov 1, 2023
Messages
7
Reaction score
0
Location
Canada
Hello everyone,

I'm looking for help creating or finding a script that performs a specific function on a server. I need the script to automatically detect when the message "Vehicles have been respawned" appears in the server chat. Upon detection of this message, I would like a TextDraw to be displayed just above the minimap with the text "Next respawn: [minutes:seconds]".

The idea is that this TextDraw acts as a countdown timer, starting its countdown from the moment the message is detected in the chat. It is important to mention that server vehicle respawns occur every 5 minutes, so the timer should be set to this interval.

Does anyone know of an existing script that meets these characteristics or could guide me on how to implement this functionality?
 
Joined
Jul 14, 2015
Messages
1,459
Solutions
5
Reaction score
913
Location
Israel
Hello everyone,

I'm looking for help creating or finding a script that performs a specific function on a server. I need the script to automatically detect when the message "Vehicles have been respawned" appears in the server chat. Upon detection of this message, I would like a TextDraw to be displayed just above the minimap with the text "Next respawn: [minutes:seconds]".

The idea is that this TextDraw acts as a countdown timer, starting its countdown from the moment the message is detected in the chat. It is important to mention that server vehicle respawns occur every 5 minutes, so the timer should be set to this interval.

Does anyone know of an existing script that meets these characteristics or could guide me on how to implement this functionality?
They won't do that to you b Textdraw They will do it to you Text on the screen, and it's not a problem to do it. Send here Chatlog of the chat message is accurate and they will do it for you
 

affar

Member
Joined
Feb 21, 2023
Messages
15
Reaction score
0
They won't do that to you b Textdraw They will do it to you Text on the screen, and it's not a problem to do it. Send here Chatlog of the chat message is accurate and they will do it for you
i was also looking a mod like this if i type /loadtruck , i need a textdraw that shows 60 sec cooldown samp version 0.3.7 r1
 

Zin

Expert
Joined
Aug 1, 2013
Messages
1,713
Solutions
1
Reaction score
111
i was also looking a mod like this if i type /loadtruck , i need a textdraw that shows 60 sec cooldown samp version 0.3.7 r1
Write command twice to cancel timer if you need (it will give prompt for this), done the code as best as possible for modification (i.e. position on screen, restarting cleo).
Code:
{$CLEO .cs}

THREAD 'LOADTRUCK'

REPEAT
    WAIT 0
UNTIL 0AFA:

0B34: samp register_client_command "LOADTRUCK" to_label @LOADTRUCK

// SETTINGS

CONST
    COOLDOWN = 60000 // TIME IN MS
    FONT = 31@
    TIMER = 30@
    OVERRIDE = 29@
    X = 28@
    Y 27@
    DEBUG = 26@
END

DEBUG = FALSE // SET TO FALSE ONCE ADJUSTMENTS MADE!
X = 498.333344 // SCREEN X POS FOR TEXT
Y = 101.214813 // SCREEN Y POS FOR TEXT

32@ = COOLDOWN // MAYBE NEEDED??

0B6D: render FONT = create_font "Arial" height 0@ flags 0x04

WHILE TRUE
    WAIT 0
    
    // DEBUG
    IF 
        DEBUG == TRUE
    THEN
        // COORDINATE FINDER
        0B5E: get_cursor_pos X Y
        0B5F: convert_window_screen_coords X Y to_game_screen_coords X Y
        IF
            KEY_DOWN 1
        THEN
            LOG "%f %f" X Y // WRITES TO SAMPFUNCS CONSOLE, CONSOLE SHOWN BY PRESSING @ OR ' KEY.
        END
        // RESTARTER
         0AB1: @RESTART 1 WITH_KEY 88 // KEY_X
    ELSE
        
    END
    
    IF AND
        32@ >= 0
        32@ < COOLDOWN
    THEN
        // TIMER
        alloc 0@ 256
        0093: 1@ = integer 32@ to_float
        1@ /= 1000.0
        1@ -= 60.0
        0097: make 1@ absolute_float
        0AD3: 0@ = format "/LOADTRUCK cooldown: %f seconds" 1@
        0B60: convert_game_screen_coords X Y to_window_screen_coords 1@ 2@
        0B6F: render FONT draw_text 0@ pos 1@ 2@ color 0xFFff00c9
        free 0@
    END
    
END

:LOADTRUCK
IF
    32@ > COOLDOWN
THEN
    // START TIMER
    SAY "/LOADTRUCK"
    32@ = 0
    OVERRIDE = FALSE
ELSE
    IF
        OVERRIDE == FALSE
    THEN
        CHATMSG "/LOADTRUCK timer already active, type cmd again to cancel!" 0xff00c9
        OVERRIDE = TRUE
    ELSE
        // STOP TIMER
        32@ = COOLDOWN
        OVERRIDE = FALSE
    END 
END   
SAMP.CmdRet()

:RESTART
IF
0AB0: 0@
THEN
    REPEAT
        WAIT 0
        PRINT "~R~RESTART: ~w~cmdtimer.CS" 100
    UNTIL 8AB0: 0@
0A92: RESTART "cmdtimer.CS"
004E: STOP THIS CLEO
END
0AB2: 0
 

Attachments

  • cmdtimer.cs
    19.8 KB · Views: 3
Top