Help CLEO SCRIPT

Haykelendin

New member
Joined
Jul 26, 2026
Messages
1
Reaction score
0
Hello, I want to create a CLEO script that automatically enters a command when I approach a toll booth. I made the following example for the L key. To open the toll booth, I need to type /gise in the chat. I couldn't figure out how to integrate this into the CLEO script. I want to automatically open the chat and type the /gise command.

{$CLEO .cs}

0000:

:1
wait 0

if
00EC: actor $PLAYER_ACTOR sphere 0 near_point 2342.8594 -2332.5425 radius 5.0 5.0
jf @1

0AD1: show_formatted_text_highpriority "GISE ~g~AKTIF" time 2000

// Press the L key
0AB1: @Set_Virtual_Key 2 KeyOffSet 0x4C state 255
wait 30
0AB1: @Set_Virtual_Key 2 KeyOffSet 0x4C state 0

wait 1000
jump @1


:Set_Virtual_Key
{
255 = true
0 = false
}

2@ = 0xB72CC8
0@ *= 2
005A: 2@ += 0@
0A8C: write_memory 2@ size 1 value 1@ virtual_protect 0
0AB2: ret 0
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,503
Solutions
1
Reaction score
247
Location
( ͡° ͜ʖ ͡°)
Here is what my friend Gemini told me, he is a good man.

To get this working, you must install SAMPFUNCS first. Standard CLEO doesn't have built-in commands for SA-MP (like sending chat messages or controlling SA-MP inputs).

Step 1: Install SAMPFUNCS​

  1. Download SAMPFUNCS (version 5.3.3 or 5.4.1 depending on your SA-MP version).
  2. Drop SAMPFUNCS.asi into your main GTA San Andreas game directory (where gta_sa.exe lives).
  3. Make sure your CLEO editor (like Sanny Builder) has SAMPFUNCS opcodes enabled in its settings.

Step 2: The Key Opcodes Used​

Instead of opening the chat box and simulating typing individual keys (which can easily lag or fail), SAMPFUNCS provides direct opcodes:

  • 0AF9: samp say_msg "string"
    Sends a chat message or command (like /gise) directly to the server immediately without opening the chat UI (T key) or pressing ENTER.
  • 0B56: set_game_key 1@ state 2@
    Emulates pressing an in-game control key (like Horn or Action key) programmatically without relying on Windows virtual key memory writes.
  • 0AFA: is_samp_available
    Ensures SA-MP has finished loading before the script tries to execute SA-MP functions, preventing game crashes on startup.

Step 3: Complete CLEO Script​

Here is the full code ready to compile:

Ini, TOML

{$CLEO .cs}

// Script Name: AutoToll.cs
// Requirements: CLEO 4 + SAMPFUNCS installed in your GTA SA directory.

0000:

:WAIT_SAMP
wait 400
// Wait until SA-MP API is fully loaded before executing SAMPFUNCS opcodes
if not 0AFA: is_samp_available
jf @WAIT_SAMP

:CHECK_NEAR
wait 0

// Check if player is near the toll booth coordinates
if
00EC: actor $PLAYER_ACTOR sphere 0 near_point 2342.8594 -2332.5425 radius 5.0 5.0
jf @CHECK_NEAR

// Visual notification on screen
0AD1: show_formatted_text_highpriority "GISE ~g~AKTIF" time 2000

// Send the /gise command directly to the server
0AF9: samp say_msg "/gise"

// Optional: If you ever need to emulate a game keypress via SAMPFUNCS (e.g. Horn / Key 15)
// 0B56: set_game_key 15 state 255
// wait 50
// 0B56: set_game_key 15 state 0

// Wait 5 seconds so it doesn't spam the server while standing near the booth
wait 5000
jump @CHECK_NEAR
 
Top