CLEO Help Sync car with packets snippet

CLEO related
Status
Not open for further replies.

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
I was trying to use this snippet but I encountered a problem, could you give me some advice on what to change to make it work?
That's the code I used in order to deflate 2nd tyre in a specific car:

Code:
{$CLEO .cs}
0000: NOP

0B34: samp register_client_command "abc" to_label @start
29@ = 0

:First
wait 0
if 29@ == 1
jf @First

     if 0AFF: samp 0@ = car_handle_by_samp_vehicle_id 5@
     then
        0AB1: @SYNC_VEHICLE 1 HANDLE 0@
        04FE: deflate_tire 2 on_car 0@                        
     end     
29@ = 0
jump @First




:start
wait 0 
   SAMP.IsCommandTyped(31@)
if 
0AD4: 30@ = scan_string 31@ format "%d" 5@ 
else_jump @First
29@ = 1    // = 1 make it active
SAMP.CmdRet
goto @First 

     CONST
PACKET_VEHICLE_SYNC = 219
BS_TYPE_ARRAY = 5
BS_TYPE_BYTE = 0
END

//0AB1: @SYNC_VEHICLE 1 HANDLE 0@
:SYNC_VEHICLE
IF
0B2C: 1@ = get_vehicle_id_by_car_handle 0@
THEN  
    0AC8: 31@ = allocate_memory_size 63 // struct stInCarData ( size = 63 )
    0C0D: struct 31@ offset 0 size 2 = 1@ // sVehicleID;
    0C0D: struct 31@ offset 2 size 2 = 0 // sLeftRightKeys; 
    0C0D: struct 31@ offset 4 size 2 = 0 // sUpDownKeys;
    0C0D: struct 31@ offset 6 size 2 = 0 // sKeys;        
    0AB1: @GetCarQuat 1 car_handle 0@ result 25@ 26@ 27@ 28@
//    fQuaternion[4]
    0C0D: struct 31@ offset 8  size 4   = 25@
    0C0D: struct 31@ offset 12 size 4   = 26@
    0C0D: struct 31@ offset 16 size 4   = 27@
    0C0D: struct 31@ offset 20 size 4   = 28@    
    0407: store_coords_to 24@ 23@ 22@ from_car 0@ with_offset 0.0 0.0 0.0
    //fPosition[3]
    0C0D: struct 31@ offset 24 size 4   = 24@
    0C0D: struct 31@ offset 28 size 4   = 23@
    0C0D: struct 31@ offset 32 size 4   = 22@  
    0A97: 22@ = car 0@ struct
    22@ += 68
    0A8D: 21@ = read_memory 22@ size 4 virtual_protect 0
    22@ += 0x4
    0A8D: 20@ = read_memory 22@ size 4 virtual_protect 0
    22@ += 0x4
    0A8D: 19@ = read_memory 22@ size 4 virtual_protect 0
    // float fMoveSpeed[3];
    0C0D: struct 31@ offset 36  size 4   = 21@
    0C0D: struct 31@ offset 40  size 4   = 20@
    0C0D: struct 31@ offset 44  size 4   = 19@    
    0227: 18@ = car 0@ health
    0093: 17@ = integer 18@ to_float    
    0C0D: struct 31@ offset 48  size 4   = 17@  // car hp
    0226: 17@ = actor $PLAYER_ACTOR health
    0C0D: struct 31@ offset 52  size 1   = 17@   // PLAYER
    04DD: 16@ = actor $PLAYER_ACTOR armour
    0C0D: struct 31@ offset 53  size 1   = 16@   // ARMOUR
    0C0D: struct 31@ offset 54  size 1   = 0   // weapon    
    0C0D: struct 31@ offset 55  size 1   = 0   // siren
    0C0D: struct 31@ offset 56  size 1   = 0   
    0C0D: struct 31@ offset 57  size 2   = 0   
    0C0D: struct 31@ offset 59  size 4   = 0.0 // train speed    
    0B3D: raknet 29@ = new_bit_stream    
    0B40: raknet bit_stream 29@ write PACKET_VEHICLE_SYNC type BS_TYPE_BYTE size 1
    0B40: raknet bit_stream 29@ write 31@ type BS_TYPE_ARRAY size 63
    0B8B: raknet send bit_stream 29@
    0B3E: raknet delete_bit_stream 29@
    0AC9: free_allocated_memory 31@

END
0AB2: 0
:GetCarQuat // 0AB1: @GetCarQuat 1 car_handle 0@ result 1@ 2@ 3@ 4@
1@ = 0.0
2@ = 0.0
3@ = 0.0
4@ = 0.0
call @GetCarMatrixPtr 1 car_handle 0@ result 1@
if 1@ <> 0
then call @MatrixToQuat 1 matrix_ptr 0@ result 1@ 2@ 3@ 4@
end
ret 4 1@ 2@ 3@ 4@

:GetCarMatrixPtr // call @GetCarMatrixPtr 1 car_handle 0@ result 1@
if 856E: not car_defined 0@
then ret 1 0
end
0A97: 1@ = car 0@ struct
1@ += 0x14
0A8D: 1@ = read_memory 1@ size 4 virtual_protect 0
ret 1 1@

:MatrixToQuat // call @MatrixToQuat 1 matrix_ptr 0@ result 1@ 2@ 3@ 4@ // by alfazlo
0C0E: 1@ = array 0@ element 0 // right
0C0E: 2@ = array 0@ element 1
0C0E: 3@ = array 0@ element 2
0C0E: 4@ = array 0@ element 4 // up
0C0E: 5@ = array 0@ element 5
0C0E: 6@ = array 0@ element 6
0C0E: 7@ = array 0@ element 8 // front
0C0E: 8@ = array 0@ element 9
0C0E: 9@ = array 0@ element 10
 
005B: 10@ = 1@
005B: 10@ += 5@
005B: 10@ += 9@
 
if 0021: 10@ > 0.0
then
    0007: 0@ = 0.5
    000B: 10@ += 1.0
    01FB: sqrt 10@ store_to 10@
    0073: 0@ /= 10@  //s
    0007: 15@ = 0.25
    0073: 15@ /= 0@ //w
    005B: 16@ = 8@  //x
    0063: 16@ -= 6@
    006B: 16@ *= 0@
    005B: 17@ = 3@  //y
    0063: 17@ -= 7@
    006B: 17@ *= 0@
    005B: 18@ = 4@  //z
    0063: 18@ -= 2@
    006B: 18@ *= 0@
else if and
    0025: 1@ > 5@
    0025: 1@ > 9@
then
    0007: 0@ = 2.0
    0007: 10@ = 1.0
    005B: 10@ += 1@
    0063: 10@ -= 5@
    0063: 10@ -= 9@
    01FB: sqrt 10@ store_to 10@
    006B: 0@ *= 10@ //s
    005B: 15@ = 8@ //w
    0063: 15@ -= 6@
    0073: 15@ /= 0@
    0007: 16@ = 0.25 //x
    006B: 16@ *= 0@
    005B: 17@ = 2@
    005B: 17@ += 4@
    0073: 17@ /= 0@
    005B: 18@ = 3@
    005B: 18@ += 7@
    0073: 18@ /= 0@
else if 0025: 5@ > 9@
then
    0007: 0@ = 2.0
    0007: 10@ = 1.0
    005B: 10@ += 5@
    0063: 10@ -= 1@
    0063: 10@ -= 9@
    01FB: sqrt 10@ store_to 10@
    006B: 0@ *= 10@ //s
    005B: 15@ = 3@ //w
    0063: 15@ -= 7@
    0073: 15@ /= 0@
    005B: 16@ = 2@ //x
    005B: 16@ += 4@
    0073: 16@ /= 0@
    0007: 17@ = 0.25 //y
    006B: 17@ *= 0@
    005B: 18@ = 6@  //z
    005B: 18@ += 8@
    0073: 18@ /= 0@
else
    0007: 0@ = 2.0
    0007: 10@ = 1.0
    005B: 10@ += 9@
    0063: 10@ -= 1@
    0063: 10@ -= 5@
    01FB: sqrt 10@ store_to 10@
    006B: 0@ *= 10@ //s
    005B: 15@ = 4@ //w
    0063: 15@ -= 2@
    0073: 15@ /= 0@
    005B: 16@ = 3@ //x
    005B: 16@ += 7@
    0073: 16@ /= 0@
    005B: 17@ = 6@  //y
    005B: 17@ += 8@
    0073: 17@ /= 0@
    0007: 18@ = 0.25 //z
    006B: 18@ *= 0@
end
end
end           
ret 4 15@ 16@ 17@ 18@


That's the outcome:
2Up8gez.jpg

The game doesn't stop/crash but the tyre remains normal
There are also chatlog lines confirming that the actor has entered the car
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
TH3RM4L link said:
So you niggered and shared a snippet which doesn't even work :dont_care:
Nope. I made it and 0x688 explained what does what.
And now i can do my own sampfuncs shit  :urtheman:.

I also made the pessanger sync shit now for trolling P:

0AB1: @PACKET_PASSENGER_SYNC 1 CAR_HANDLE 0@
:pACKET_PASSENGER_SYNC
IF
0B2C: samp 30@ = get_vehicle_id_by_car_handle 0@
THEN
    0AC8: 31@ = allocate_memory_size 24
    0C0D: struct 31@ offset 0 size 2  = 30@
    0C0D: struct 31@ offset 2 size 1  = 1
    0C0D: struct 31@ offset 3 size 1  = 0
    0C0D: struct 31@ offset 4 size 1  = 50
    0C0D: struct 31@ offset 5 size 1  = 0
    0C0D: struct 31@ offset 6 size 2  = 0
    0C0D: struct 31@ offset 8 size 2  = 0                                                             
    0C0D: struct 31@ offset 10 size 2 = 0 
    0B3D: raknet 29@ = new_bit_stream
    0B40: raknet bit_stream 29@ write 216 type 0 size 1
    0B40: raknet bit_stream 29@ write 31@ type 5 size 63
    0B8B: raknet send bit_stream 29@
    0B3E: raknet delete_bit_stream 29@
    0AC9: free_allocated_memory 31@       
END
0AB2: 0
 

ThermaL

Expert
Joined
Oct 23, 2013
Messages
1,593
Reaction score
3
Opcode.eXe link said:
Nope. I made it and 0x688 explained what does what.
And now i can do my own sampfuncs shit  :urtheman:.

I also made the pessanger sync shit now for trolling P:

0AB1: @PACKET_PASSENGER_SYNC 1 CAR_HANDLE 0@
:pACKET_PASSENGER_SYNC
IF
0B2C: samp 30@ = get_vehicle_id_by_car_handle 0@
THEN
    0AC8: 31@ = allocate_memory_size 24
    0C0D: struct 31@ offset 0 size 2  = 30@
    0C0D: struct 31@ offset 2 size 1  = 1
    0C0D: struct 31@ offset 3 size 1  = 0
    0C0D: struct 31@ offset 4 size 1  = 50
    0C0D: struct 31@ offset 5 size 1  = 0
    0C0D: struct 31@ offset 6 size 2  = 0
    0C0D: struct 31@ offset 8 size 2  = 0                                                             
    0C0D: struct 31@ offset 10 size 2 = 0 
    0B3D: raknet 29@ = new_bit_stream
    0B40: raknet bit_stream 29@ write 216 type 0 size 1
    0B40: raknet bit_stream 29@ write 31@ type 5 size 63
    0B8B: raknet send bit_stream 29@
    0B3E: raknet delete_bit_stream 29@
    0AC9: free_allocated_memory 31@       
END
0AB2: 0
Passenger sync + driver sync = trolling onfoot :forever_hurra:
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
271
Opcode.eXe link said:
:urtheman:
I know why. The function to get the car quaternium is fucked^^

Code:
:Quaternion_get
{
0A96: @ = actor $PLAYER_ACTOR struct
0A97: @ = car @ struct
0A98: @ = object @ struct
0C0C: @ = struct @ offset 20 size 4 //matrix pointer
0AB1: call_scm_func @Quaternion_get 1 matrix_pointer @ Quat_x @ Quat_y @ Quat_z @ Quat_w @
}
0AC8: 1@ = allocate_memory_size 16
0AA6: call_method 0x59C3E0 struct 1@ num_params 1 pop 0 0@
0C0C: 10@ = struct 1@ offset 12 size 4
0C0C: 11@ = struct 1@ offset 0 size 4
0C0C: 12@ = struct 1@ offset 4 size 4
0C0C: 13@ = struct 1@ offset 8 size 4
0AC9: free_allocated_memory 1@          
ret 4 10@ 11@ 12@ 13@
 
Status
Not open for further replies.
Top