Comments (5)
some ideas:
addEventListener("onMount", () => { log("script has been reloaded") })
addEventListener("onUnMount", () => { log("script is about to be unloaded") })
from cleo-redux.
as I mentioned on Discord you can iterate pool using existing Memory command (not in DE for now).
Example script creating blips over police cars in GTA 3 1.0
/// <reference path=".config/gta3.d.ts" />
// wrapper over CPool class providing common interface for storing dynamically created entities (ped, vehicles, objects, etc)
function Pool(addr, entitySize) {
this.addr = addr;
this.entities = Memory.ReadU32(addr + 0, false);
this.flags = Memory.ReadU32(addr + 4, false);
this.size = Memory.ReadI32(addr + 8, false);
this.entitySize = entitySize;
}
Pool.prototype = {
getFlag: function (index) {
return Memory.ReadU8(this.flags + index, false);
},
getIndex: function (struct) {
return (struct - this.entities) / this.entitySize;
},
isFree: function (index) {
return this.getFlag(index) & 0x80;
},
getHandle: function (struct) {
var index = this.getIndex(struct);
return (index << 8) + this.getFlag(index);
},
getEntity: function (index) {
return this.entities + index * this.entitySize;
},
getEntities: function () {
var result = [];
for (var i = 0; i < this.size; i++) {
if (!this.isFree(i)) {
result.push(this.getEntity(i));
}
}
return result;
},
};
var BLIPS = 0x006ed5e0;
var MI_POLICE = 116;
function findThisEntityBlip(handle) {
var COUNT = 32;
var SIZE = 0x30;
for (var i = 0; i < COUNT; i++) {
var inUse = Memory.ReadU8(BLIPS + i * SIZE + 0x23, false);
if (inUse) {
var h = Memory.ReadU32(BLIPS + i * SIZE + 0x8, false);
if (handle == h) {
var blipIndex = Memory.ReadU16(BLIPS + i * SIZE + 0x20, false);
/// blipArrId | (CRadar::ms_RadarTrace[_index].m_nBlipIndex << 16);
return i | (blipIndex << 16);
// return blipIndex;
}
}
}
}
if (GAME !== "gta3") {
log("Sorry, this script is for GTA III only");
} else {
// create a function to get the vehicle pool address
var GetVehiclePool = Memory.Fn.CdeclU32(0x00545300);
// create a wrapper over the vehicle pool object
var vehPool = new Pool(GetVehiclePool(), 0x5a8);
while (true) {
wait(500);
// iterate over all created vehicles
vehPool.getEntities().forEach(function (vehicle) {
// create a new instance of a script vehicle
var handle = vehPool.getHandle(vehicle);
var v = new Car(handle);
// v now can be used with script commands defined for Vehicle class
// check that v is a police car with a driver and it has no blip yet
if (
!Car.IsDead(v) &&
v.getModel() === MI_POLICE &&
!Char.IsDead(v.getDriver()) &&
!findThisEntityBlip(handle)
) {
Blip.AddForCarOld(v, 2, 2);
}
});
}
}```
from cleo-redux.
Idea to create callbacks/hooks was briefly discussed here
#1 (reply in thread)
from cleo-redux.
WIP
addEventListener("OnVehicleCreate", ({ data }) => {
let { address } = data;
let handle = vehPool.getHandle(address);
let c = new Car(handle);
if (c.isModel(POLICE_MI)) {
Blip.AddForCarOld(c, 2, BlipDisplay.BlipOnly);
}
});
https://media.discordapp.net/attachments/914958450667175977/1053787400855359508/image.png
from cleo-redux.
Pools are available in scm.ts library
https://github.com/x87/scm.ts
Events are supported since 1.0.6
https://re.cleo.li/docs/en/events.html
from cleo-redux.
Related Issues (20)
- CLEO commands with multiple outputs don't work correctly HOT 2
- [Bully] `Clothing.BuildPlayer()` crashes the game HOT 1
- support "long strings" in III and VC if CLEO library is present HOT 1
- GTA 3 Definitive Edition car spawning freeze HOT 4
- GTA VC Definitive Edition CRASHES
- For Installer (UAL Filename) HOT 8
- Is it possible to restore the original music using CLEO Redux in San Andreas Definitive Edition
- [STEAM] GTA Trilogy - Error Cleo Redux is and Ultimate ASI Loader HOT 2
- [Classic: San Andreas] - Events.cleo Plugin Conflict with VehFuncs HOT 14
- Incompatible with new GTA Vice City DE patch 1.0.17.39540 HOT 2
- [RGL] 1.1.2 Crashes San Andreas Definitive Edition when loading a Save. HOT 8
- CLEO Redux doesn't work for ReVC OpenGL x64 build and Re3 OpenGL x64 build HOT 1
- Raknet HOT 1
- Heli.Create should return type Heli HOT 3
- Type "label" in opcodes input HOT 1
- stack trace is wrong in typescript files
- fxt support in VC: DE HOT 1
- conversion error in Memory.Fn.ThiscallU8 HOT 2
- Fx.DrawCorona bug HOT 4
- Text operations bug in 1.2.1 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cleo-redux.