-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is an example script for calling native function using Memory interface. I've tested on GTA Vice City version 1.0.
- Loading branch information
1 parent
a3a5fc6
commit 46c45f8
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/// <reference path=".config/vc.d.ts" /> | ||
|
||
const LEFTMOUSEBUTTON = 1; | ||
var player = new Player(0); | ||
|
||
while (true) { | ||
if (Pad.IsKeyDown(LEFTMOUSEBUTTON)) { | ||
if (player.isInAnyCar()) { | ||
//GET VEHICLE STRUCT USING Memory.GetVehiclePointer METHOD. PASS VEHICLE POINTER AS A PARAMETER USING player.storeCarIsInNoSave(). | ||
var vehicle = player.storeCarIsInNoSave(); | ||
var vehicleStruct = Memory.GetVehiclePointer(vehicle); | ||
|
||
//TO GET THE VEHICLE TYPE, WE NEED TO ADD AN OFFSET TO THE VEHICLE POINTER(OFFSET: "0x29c" (https://gtamods.com/wiki/Memory_Addresses_(VC) GO TO THIS ADDRESS AND LOOK AT THE END OF CVEHICLE TABLE.)). | ||
var vehicleType = Memory.Read(vehicleStruct + 0x29c, 4, false); | ||
//https://gtamods.com/wiki/Function_Memory_Addresses_(VC) YOU CAN FIND FUNCTION ADDRESSES FROM HERE. | ||
//MEMORY ADDRESS: 0x588530(for vehicle type = 0) | FUNCTION:Fix((void)) | DESCRIPTION: Completely fixes the car in spray shops. See this(https://gtamods.com/wiki/0A30#For_GTA_III_and_Vice_City) for a practical usage. | ||
// 0x609f00(for if vehicle type is different than 0) | ||
/* | ||
VEHICLE TYPES | ||
0 = general | ||
1 = boat | ||
2 = train (unused) | ||
3 = NPC police helicopter | ||
4 = NPC plane | ||
5 = bike | ||
*/ | ||
if (vehicleType == 0) { | ||
Memory.CallMethod(0x588530, vehicleStruct, 0, 0); | ||
} else { | ||
Memory.CallMethod(0x609f00, vehicleStruct, 0, 0); | ||
} | ||
vehicle.setHealth(1000); | ||
} | ||
} | ||
wait(10); | ||
} |