[SNIPPET] Sync Car with Packets

Wanna make a iTroll mod without using "put_actor_in_car"? Wanna make Car Teleport hacks so everyone can see it? Here you go:


Code:
const
PACKET_VEHICLE_SYNC = 219
BS_TYPE_BYTE = 0
BS_TYPE_ARRAY = 5
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;        
    0A97: 17@ = car 0@ struct  
    17@ += 0x14
    0A8D: 17@ = read_memory 17@ size 4 virtual_protect 0
    0AB1: call_scm_func @Quaternion_get 1 matrix_pointer 17@ Quat_x 18@ Quat_y 19@ Quat_z 20@ Quat_w 21@        
    0C0D: struct 31@ offset 8  size 4   = 18@
    0C0D: struct 31@ offset 12 size 4   = 19@
    0C0D: struct 31@ offset 16 size 4   = 20@
    0C0D: struct 31@ offset 20 size 4   = 21@ 
    0407: store_coords_to 24@ 23@ 22@ from_car 0@ with_offset 0.0 0.0 0.0
    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   //Snippet by OpcodeXe
    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
    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


:Quaternion_get 
0C0C: 1@ = struct 0@ offset 0 size 4
0C0C: 2@ = struct 0@ offset 4 size 4
0C0C: 3@ = struct 0@ offset 8 size 4
0C0C: 4@ = struct 0@ offset 16 size 4
0C0C: 5@ = struct 0@ offset 20 size 4
0C0C: 6@ = struct 0@ offset 24 size 4
0C0C: 7@ = struct 0@ offset 32 size 4
0C0C: 8@ = struct 0@ offset 36 size 4
0C0C: 9@ = struct 0@ offset 40 size 4
 
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           
0AB2: ret 4 15@ 16@ 17@ 18@
 

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
51
Location
LongForgotten <-> 0x32789
How does this work? I cant seem to understand it
This is what I tried as far as I know it puts u in the specified car by handle.
But my code dosent work
Code:
:pushdisnig
wait 0
var
17@ : Float
9@ : Float
end
0B35: samp 25@ = get_last_command_params 
if 
0AD4: 26@ = scan_string 25@ format "%D" 11@
then
    14@ = SAMP.GetSAMPPlayerIDByActorHandle($PLAYER_ACTOR)
    if
    not 11@ == 14@
    then
        if
        SAMP.IsPlayerConnected(11@)
        then
            27@ = SAMP.GetActorHandleByPlayerID(11@)
            if
            056D:   actor 27@ defined
            then
                if
                Actor.Driving(27@)
                then
                    28@ = Actor.CurrentCar(27@)
                    call @SYNC_VEHICLE 1 28@
                    9@ = 0.0
                    000B: 9@ += 7@
                    17@ = random(-15.0, 15.0)
                    if 17@ > 0
                    then
                        000B: 9@ += 17@
                    else
                        000E: 9@ -= 17@
                    end
                    Car.Angle(28@) = 9@
                    Car.SetSpeedInstantly(28@, 300.0)
                    0AF8: samp add_message_to_chat "{FFFFFF}[{FF0000}Pushed the specified target's car away!{FFFFFF}]" color 0x9000 
                else 0AF8: samp add_message_to_chat "{FFFFFF}[{FF0000}Specified ID is not driving{FFFFFF}]" color 0x9000 
                end
            else 0AF8: samp add_message_to_chat "{FFFFFF}[{FF0000}Specified ID is not streamed in{FFFFFF}]" color 0x9000 
            end
[SIZE=3][font=Monaco, Consolas, Courier, monospace]        else 0AF8: samp add_message_to_chat "{FFFFFF}[{FF0000}Specified ID is not connected{FFFFFF}]" color 0x9000 [/font][/SIZE]
[SIZE=3][font=Monaco, Consolas, Courier, monospace]        end[/font][/SIZE]
[SIZE=3][font=Monaco, Consolas, Courier, monospace]    else[/font][/SIZE]
[SIZE=3][font=Monaco, Consolas, Courier, monospace]        28@ = Actor.CurrentCar($PLAYER_ACTOR)[/font][/SIZE]
[SIZE=3][font=Monaco, Consolas, Courier, monospace]        9@ = 0.0[/font][/SIZE]
[SIZE=3][font=Monaco, Consolas, Courier, monospace]        000B: 9@ += 7@[/font][/SIZE]
[SIZE=3][font=Monaco, Consolas, Courier, monospace]        17@ = random(-15.0, 15.0)[/font][/SIZE]
[SIZE=3][font=Monaco, Consolas, Courier, monospace]        if 17@ > 0[/font][/SIZE]
[SIZE=3][font=Monaco, Consolas, Courier, monospace]        then[/font][/SIZE]
[SIZE=3][font=Monaco, Consolas, Courier, monospace]            000B: 9@ += 17@[/font][/SIZE]
[SIZE=3][font=Monaco, Consolas, Courier, monospace]        else[/font][/SIZE]
[SIZE=3][font=Monaco, Consolas, Courier, monospace]            000E: 9@ -= 17@[/font][/SIZE]
[SIZE=3][font=Monaco, Consolas, Courier, monospace]        end[/font][/SIZE]
[SIZE=3][font=Monaco, Consolas, Courier, monospace]        Car.Angle(28@) = 9@[/font][/SIZE]
[SIZE=3][font=Monaco, Consolas, Courier, monospace]        Car.SetSpeedInstantly(28@, 300.0)[/font][/SIZE]
[SIZE=3][font=Monaco, Consolas, Courier, monospace]        0AF8: samp add_message_to_chat "{FFFFFF}[{FF0000}Pushed your car away!{FFFFFF}]" color 0x9000 [/font][/SIZE]
[SIZE=3][font=Monaco, Consolas, Courier, monospace]    end[/font][/SIZE]
[SIZE=3][font=Monaco, Consolas, Courier, monospace]else 0AF8: samp add_message_to_chat "{FFFFFF}[{FF0000}USAGE: /.push [TargetId]{FFFFFF}]" color 0x9000 [/font][/SIZE]
[SIZE=3][font=Monaco, Consolas, Courier, monospace]end[/font][/SIZE]
SAMP.CmdRet()
This dosent sync, How will I use my code to push the car away without putting car. im confused
 

4changesLeft

Well-known member
Joined
Apr 10, 2015
Messages
365
Reaction score
3
You are using it wrong, first you put the action, for example car_angle and then you sync it.
 
Top