Snippets

This section is only for CLEO Snippet threads. This section is mainly for posting snippets which users can use to develop their own cleo, for example "Draw line snippet". Do not post any releases, help, requests or tutorials&guides threads in this section. If you would like to release a new cleo, visit: >> https://ugbase.eu/releases-6/ If you need to ask for help or help other users about something to do with cleo, visit >> https://ugbase.eu/help-7/ If you would like to request or help to develop a cleo, visit: >> https://ugbase.eu/requests-10/ If you would like to post any Tutorials&Guides threads or learn new things about cleo, visit: >> https://ugbase.eu/tutorials/ Posting different threads which do not have anything to do with...
I want to know what a snippet clearly means. What does it stand for ? Can we use it ?
This can be used to create scripts that work with various samp versions. In order to use it, I suggest to create "includes" folder inside the "gta_sa/cleo" folder. Then create "get_samp_version.txt" file inside it and paste the code below into it. The code below contains 2 functions: - get_samp_version_id (returning arbitrary number so you can easily compare it in your scripts) - get_samp_version_name /* get_samp_version_id function is reading the "IMAGE_FILE_HEADER" of samp.dll (TimeDateStamp to be specific) That TimeDateStamp is based on compilation time. See this for more info: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#file-headers "TimeDateStamp = The low 32 bits of the number of seconds...
Snippet which allows you to call mouse events. With these functions you can move the Gta Sa Camera. Usually these snippet is used for aimbots and other things.. Originally made by @Opcode.eXe and lost after forum updates.. :MouseMOVE_RIGHT // 0AB1: @MouseMOVE_RIGHT 0 0AA2: 31@ = load_library "user32.dll" 0AA4: 30@ = get_proc_address "mouse_event" library 31@ IF 0A4C: mouse_not_inverted_vertically THEN 0AA5: call 30@ num_params 5 pop 0 0 0 0 -2 0 ELSE 0AA5: call 30@ num_params 5 pop 0 0 0 0 2 0 END 0AA3: free_library 31@ 0AB2: 0 :MouseMOVE_LEFT // 0AB1: @MouseMOVE_LEFT 0 0AA2: 31@ = load_library "user32.dll" 0AA4: 30@ = get_proc_address "mouse_event" library 31@ IF 0A4C: mouse_not_inverted_vertically THEN 0AA5...
Not enough cleo timers? Create/use unlimited number of precise timers with this snippet! Difference between cleo built-in TIMERA/TIMERB and this Snippet: Cleo timers depend on ingame tick, unstable FPS leads to unprecise timer measurements on both TIMERA and TIMERB. This snippets uses your Operating System's Tick Timer as reference to do precise timing measurements. To Increase the number of custom timers, Find(CTRL+F) CustomTimerRegion and add 4 bytes of hex for each new index you create. :GetLapseOfCustomTimer // 0AB1: @GetLapseOfCustomTimer 1 _TimerIndex 0@ _ReturnLapseOfTime 30@ 0AC6: 31@ = label @CustomTimerRegion pointer 0@ *= 4 // 4 bytes for each index 005A: 31@ += 0@ // custom timer index pointer 0A8D: 31@...
Example without SAMPFUNCS. For 0.3.DL, works everywhere and easy to change. {$CLEO .cs} {$USE bitwise} 0000: WHILE TRUE WAIT 0 IF 0AB0: is_key_pressed 99 // Numpad 3 THEN 0B12: 31@ = 31@ XOR 1 IF 0039: 31@ == 1 THEN 0AD1: show_formatted_text_highpriority "~r~PBS: ~y~Auta~n~~g~Wlaczone" time 1000 ELSE 0AD1: show_formatted_text_highpriority "~r~PBS: ~y~Auta~n~~r~Wylaczone" time 1000 END WAIT 1000 END IF 31@ == 1 THEN IF 0256: player $PLAYER_CHAR defined THEN 0AC8: 1@ = allocate_memory_size 1024 0AC8: 2@ = allocate_memory_size 1024 0AB1: @getChatString 2 SampVersionID 3 ChatID 99 _Returned: Text 1@ PrefixText 2@ Color 3@ PrefixColor 4@ 0AC8...
Piece of code which allows you to save more numbers without storing them in external files. Edit: Tested and changed into simpler and actually working code alloc 0@ 512 //array pointer 1@ = 0 //buffer 0AB1: @IntArray_Write 3 arrayPointer 0@ index 0 val 123 0AB1: @IntArray_Write 3 arrayPointer 0@ index 1 val 9919 0AB1: @IntArray_Write 3 arrayPointer 0@ index 2 val 77 0AB1: @IntArray_Write 3 arrayPointer 0@ index 3 val 5 0AB1: @IntArray_Write 3 arrayPointer 0@ index 4 val 3661 0AB1: @IntArray_Write 3 arrayPointer 0@ index 5 val 91 0AB1: @IntArray_Write 3 arrayPointer 0@ index 6 val 7255 0AB1: @IntArray_Write 3 arrayPointer 0@ index 7 val 525 0AB1: @IntArray_Read arrayPointer 0@ index 0 _returned 1@ //do something with 1@ which becomes...
You all might not know that this Opcodes actually has a problem modifying the three rotations 0175: set_car 22@ Z_angle_to 315.0 // sets Z-angle to 315.0.... BUT ALSO SETS X-ANGLE AND Y-ANGLE TO 0.0 0731: set_car 34@ y_angle_to 73@ // sets Y-angle to 73@.... BUT ALSO SETS X-ANGLE AND Z-ANGLE TO 0.0 That is why I advise those who are dealing with changing the Car Rotations to use this snippet. This Snippet sets the Car Rotations in XYZ, the original source was posted by woksonal at blast.hk website. But I improved it to becoming more flexible when changing specific plane angle: // Format: // call @SetCarAngles 4 {CarHandle} 0@ {angleX} 1@ {angleY} 2@ {angleZ} 3@ // Usage: // call @SetCarAngles 4 {CarHandle} 15@ {angleX} -1 {angleY} -1...
I noticed that using these Opcodes gives inaccurate rotation values: // Objects: no opcode to get X and Y rotation values 0176: 13@ = object 0@ Z_angle // // Vehicles 077D: 1@ = car 0@ x_angle 06BE: 2@ = car 0@ y_angle 0174: 3@ = car 0@ Z_angle // Luckily, there are Quaternion Opcodes in cleo which gives accurate results: // objects 07C3: get_object 0@ quaternion_to 1@ 2@ 3@ 4@ 07C4: set_object 0@ quaternion_to 1@ 2@ 3@ 4@ // // vehicles 07C5: get_car 0@ quaternion_to 1@ 2@ 3@ 4@ 07C6: set_car 0@ quaternion_to 1@ 2@ 3@ 4@ // So a convertion between Quaternion and 3D-Angles is possible with:
This Snippet will instantly make your Camera Look on a specific 3D location. This Snippet actually has many uses like: Make our Camera Follow/Lock-on a certain Actor by feeding this snippet with its Position. Can be Used as an Aimbot, just feed this with a specified Camera XZ-Offsets for the Crosshair positions. Can be used for Debugging purposes like "Offset Visualizer" Tool? // 0AB1: @camatpos 5 _XYZ 0@ 1@ 2@ _withCamOffsetAngleX 3@ _andCamOffsetAngleZ 4@ :camatpos // ~~~~~~~~~~anti auto-vehicle cam movement if and TIMERA>=400 Actor.Driving($PLAYER_ACTOR) then 0A8C: write_memory 0xB70118 size 4 value 50.0 virtual_protect 0 // reset camera stabalizer timer, credit to Parazitas TIMERA = 0 end // ~~~~~~~~~~...
Computes the Vehicle's XYZ Rotation Velocity relative to its own X(Pitch), Y(Roll), and Z(Yaw) Axes. [/SPOILER] [/SPOILER] Computes the Vehicle's XYZ Rotation Velocity Relative to its own z(Roll) Axis. The Computation uses a Relative x(Pitch) Axis and Y(Roll) Axes pinned at 0.0 degrees. [/SPOILER] [/SPOILER] Computes the Vehicle's XYZ Rotation Velocity relative to the TrueNorth's Axis by NS, EW, and NW. [/SPOILER] [/SPOILER]
Based on this documentary, but this time I will demonstrate how we can register/Hook multiple new CMD and recover the parameters you've inputted in chat without using SAMPFUNCS Opcodes.
:get3DXYZInFrontOf{X,Y,Z,ZA,YA,Distance} {        Return:         PosX-InFrontOf         PosY-InFrontOf         PosZ-InFrontOf             Example: 0AB1: call_scm_func @get3DXYZInFrontOf 6 XYZ 1@ 2@ 3@ Z_Angle 4@ Y_Angle 5@  Distance 7.0 Return_XYZ_To 6@ 7@ 8@ } 3@ *= -1.0 02F6: 6@ = sine 3@ 006B: 6@ *= 5@ 005B: 0@ += 6@ 02F7: 6@ = cosine 3@ 006B: 6@ *= 5@ 005B: 1@ += 6@ 02F7: 6@ = cosine 4@ 0073: 5@ /= 6@ 02F6: 6@ = sine 4@ 006B: 5@ *= 6@ 005B: 2@ += 5@ 0AB2: ret 3 0@ 1@ 2@
With this snippet you can get digits from any text ! Explain.: {$CLEO} 0000: repeat wait 50 until 0AFA: is_samp_available 0AC8: 0@ = allocate_memory_size 260 0AD3: 0@ = format "aaa:12345678910" 0AC8: 1@ = allocate_memory_size 260 0AB1: call_scm_func @get_digits_to_print param_count 2 text 0@ memory_to_store_digits_as_text 1@ chatmsg 1@ -1 0A93: end_custom_thread :get_digits_to_print { 0@ = text 1@ = pointer to memory where digits will be stored as text } 0C17: 31@ = strlen 0@ for 30@ = 0 to 31@ 0085: 29@ = 0@ // copy pointer 005A: 29@ += 30@ // add offset (as the loop progresses it becomes pointers to first-last character) 0A8D: 28@ = read_memory 29@ size 1 virtual_protect 1 // 28@ is the...
With this snippet we can create samp dialog. Good luck... Explain with 0.3.7 .: {$CLEO .cs} 0000: wait 8500 WHILE TRUE WAIT 0 IF 0AB0: 49 {Key 1} THEN 0AC8: 0@ = allocate_memory_size 260 0AC8: 1@ = allocate_memory_size 260 0AC8: 2@ = allocate_memory_size 260 0AC8: 3@ = allocate_memory_size 260 0AD3: 0@ = format "This is Dialog caption" 0AD3: 1@ = format "DialogText %cDialogText" 0xA // 0xA - NEW LINE 0AD3: 2@ = format "Ok" 0AD3: 3@ = format "Close" 0AB1: @ShowDialog 6 id 1000 caption 0@ text 1@ button_1 2@ button_2 3@ style 2 wait 300 END END :ShowDialog IF 0AA2: 10@ = "samp.dll" THEN 0A8E: 11@ = 10@ + 0x21A0B8 // SAMP_DIALOG_INFO_OFFSET 0A8D: 12@ = readMem 11@ sz 4 vp 1...
IF 0ADC: test_cheat "RO" THEN 0A92: create_custom_thread "MyScriptName.cs" 0AD1: show_formatted_text_highpriority "Reloading..." time 9999 0A93: end_custom_thread END Example
:sampSendClickTextdraw { 0.3.7 - R1 0BCA: @sampSendClickTextdraw 1 TextDrawID 0@ } if 0AA2: 2@ = "samp.dll" then 0085: 3@ = 2@ 3@ += 0x21A0CC 0A8D: 3@ = readMem 3@ sz 4 vp 1 0A8E: 4@ = 3@ + 8 0A8C: writeMem 4@ sz 4 value 0@ vp 0 0A8E: 5@ = 2@ + 0x6CEA0 0AA6: call 5@ struct 3@ num_params 0 pop 0 end 0AB2: 0 :sampSendClickTextdraw { 0.3.7 - R2 0BCA: @sampSendClickTextdraw 1 TextDrawID 0@ } if 0AA2: 2@ = "samp.dll" then 0085: 3@ = 2@ 3@ += 0x21A0D4 0A8D: 3@ = readMem 3@ sz 4 vp 1 0A8E: 4@ = 3@ + 8 0A8C: writeMem 4@ sz 4 value 0@ vp 0 0A8E: 5@ = 2@ + 0x6CF40 0AA6: call 5@ struct 3@ num_params 0 pop 0 end 0AB2: 0 :sampSendClickTextdraw { 0.3.7 - R3...
const SAMP_CHAT_INFO_OFFSET = 0x212A6C SAMP_CHAT_INFO_OFFSET_R2 = 0x212AA4 FUNC_ADDTOCHATWND = 0x7A4F0 FUNC_ADDTOCHATWND_R2 = 0x61AB0 FUNC_SAY = 0x4CA0 FUNC_SAY_R2 = 0x4C30 end 0AF9(SFUNCS) Sends a message in chat //0AB1: @SAY 1 $text :SAY IF 0AA2: 1@ = "samp.dll" THEN     1@ += FUNC_SAY     0AA5: call 1@ num_param 1 pop 0 0@ END 0AB2: 0 0AF8(SFUNCS) Add a message to chat(not synched) //0AB1: @addMsgToChatWnd 2 $color $text :addMsgToChatWnd IF 0AA2: 2@ = "samp.dll" THEN     0085: 3@ = 2@     3@ += SAMP_CHAT_INFO_OFFSET     0A8D: 3@ = readMem 3@ sz 4 vp 1     0085: 4@ = 2@     4@ += FUNC_ADDTOCHATWND        0AA6: call 4@ struct 3@ num_params 5 pop 0 params 0 0@ 0 1@ 8 END 0AB2: 0 Simple example;
:RotationSpeedAngleZ { Status 1 = true Status 0 = false 0AB1: @RotationSpeedAngleZ 1 Status 1 } 0A96: 1@ = ped $PLAYER_ACTOR struct 0A8E: 2@ = 1@ + 0x560 // CPed +0x560 = [float] Rotation speed (Z angle) IF 0@ == 1 THEN 0A8C: writeMem 2@ sz 4 val 30.0 vp 1 ELSE 0A8C: writeMem 2@ sz 4 val 7.5 vp 1 END 0AB2: 0 Example
:SendLagRate { Status 1 = true Status 0 = false 0AB1: @SendLagRate 2 SampVersionID 0@ Status 1 } IF 0AA2: 10@ = "samp.dll" THEN IF 0@ == 1 // 0.3.7 R1 THEN IF 1@ == 1 THEN 0A8E: 11@ = 10@ + 0xEC0A8 0A8D: 12@ = readMem 11@ sz 4 vp 0 0A8C: writeMem 11@ sz 4 val 500 vp 0 0A8E: 11@ = 10@ + 0xEC0AC 0A8D: 13@ = readMem 11@ sz 4 vp 0 0A8C: writeMem 11@ sz 4 val 500 vp 0 0A8E: 11@ = 10@ + 0xEC0B0 0A8D: 14@ = readMem 11@ sz 4 vp 0 0A8C: writeMem 11@ sz 4 val 500 vp 0 ELSE 0A8E: 11@ = 10@ + 0xEC0A8 0A8C: writeMem 11@ sz 4 val 12@ vp 0...
Checks if there's any checkpoint active, use as condition(if) //call @is_cp_active 0 Checks if there's any race checkpoint active, use as condition(if) //call @is_racecp_active 0 Gets checkpoint position(XYZ) //call @get_cp_pos 0 X 1@ Y 2@ Z 3@ Gets racecheckpoint position(XYZ) //call @get_racecp_pos 0 X 1@ Y 2@ Z 3@
Top