mirror of
https://github.com/iDisaster/GTAConnected.git
synced 2026-03-09 01:45:22 +00:00
Merge pull request #7 from iDisaster/claude/enhance-gta-server-9Dezg
Fix vehicle model hashes and improve vehicle spawning
This commit is contained in:
@@ -262,7 +262,9 @@ const menuData = {
|
|||||||
{ label: "Patriot", action: "spawn_vehicle", value: "patriot" },
|
{ label: "Patriot", action: "spawn_vehicle", value: "patriot" },
|
||||||
{ label: "Cavalcade", action: "spawn_vehicle", value: "cavalcade" },
|
{ label: "Cavalcade", action: "spawn_vehicle", value: "cavalcade" },
|
||||||
{ label: "Huntley", action: "spawn_vehicle", value: "huntley" },
|
{ label: "Huntley", action: "spawn_vehicle", value: "huntley" },
|
||||||
{ label: "Landstalker", action: "spawn_vehicle", value: "landstalker" }
|
{ label: "Landstalker", action: "spawn_vehicle", value: "landstalker" },
|
||||||
|
{ label: "Rancher", action: "spawn_vehicle", value: "rancher" },
|
||||||
|
{ label: "Bobcat", action: "spawn_vehicle", value: "bobcat" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -270,9 +272,10 @@ const menuData = {
|
|||||||
title: "MOTORCYCLES",
|
title: "MOTORCYCLES",
|
||||||
items: [
|
items: [
|
||||||
{ label: "NRG 900", action: "spawn_vehicle", value: "nrg900" },
|
{ label: "NRG 900", action: "spawn_vehicle", value: "nrg900" },
|
||||||
{ label: "PCJ 600", action: "spawn_vehicle", value: "pcj600" },
|
{ label: "PCJ 600", action: "spawn_vehicle", value: "pcj" },
|
||||||
{ label: "Sanchez", action: "spawn_vehicle", value: "sanchez" },
|
{ label: "Sanchez", action: "spawn_vehicle", value: "sanchez" },
|
||||||
{ label: "Faggio", action: "spawn_vehicle", value: "faggio" }
|
{ label: "Faggio", action: "spawn_vehicle", value: "faggio" },
|
||||||
|
{ label: "Freeway", action: "spawn_vehicle", value: "freeway" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -280,9 +283,13 @@ const menuData = {
|
|||||||
title: "EMERGENCY",
|
title: "EMERGENCY",
|
||||||
items: [
|
items: [
|
||||||
{ label: "Police Cruiser", action: "spawn_vehicle", value: "police" },
|
{ label: "Police Cruiser", action: "spawn_vehicle", value: "police" },
|
||||||
|
{ label: "Police Cruiser 2", action: "spawn_vehicle", value: "police2" },
|
||||||
{ label: "FBI Car", action: "spawn_vehicle", value: "fbi" },
|
{ label: "FBI Car", action: "spawn_vehicle", value: "fbi" },
|
||||||
|
{ label: "NOOSE Cruiser", action: "spawn_vehicle", value: "noose" },
|
||||||
{ label: "Ambulance", action: "spawn_vehicle", value: "ambulance" },
|
{ label: "Ambulance", action: "spawn_vehicle", value: "ambulance" },
|
||||||
{ label: "Fire Truck", action: "spawn_vehicle", value: "firetruk" }
|
{ label: "Fire Truck", action: "spawn_vehicle", value: "firetruk" },
|
||||||
|
{ label: "Taxi", action: "spawn_vehicle", value: "taxi" },
|
||||||
|
{ label: "Stretch Limo", action: "spawn_vehicle", value: "stretch" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -291,7 +298,8 @@ const menuData = {
|
|||||||
items: [
|
items: [
|
||||||
{ label: "Annihilator", action: "spawn_vehicle", value: "annihilator" },
|
{ label: "Annihilator", action: "spawn_vehicle", value: "annihilator" },
|
||||||
{ label: "Maverick", action: "spawn_vehicle", value: "maverick" },
|
{ label: "Maverick", action: "spawn_vehicle", value: "maverick" },
|
||||||
{ label: "Police Maverick", action: "spawn_vehicle", value: "polmav" }
|
{ label: "Police Maverick", action: "spawn_vehicle", value: "polmav" },
|
||||||
|
{ label: "Tour Maverick", action: "spawn_vehicle", value: "tourmav" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -1441,8 +1449,8 @@ const vehicleModels = [
|
|||||||
const vehicleHashes = {
|
const vehicleHashes = {
|
||||||
// Sports Cars
|
// Sports Cars
|
||||||
"infernus": 0x18F25AC7,
|
"infernus": 0x18F25AC7,
|
||||||
"turismo": 0x185484E1,
|
"turismo": 0x8EF34547, // Fixed hash
|
||||||
"comet": 0x067BC037,
|
"comet": 0x3F637729, // Fixed hash
|
||||||
"banshee": 0xC1E908D2,
|
"banshee": 0xC1E908D2,
|
||||||
"sultan": 0x39DA2754,
|
"sultan": 0x39DA2754,
|
||||||
"coquette": 0x108773431,
|
"coquette": 0x108773431,
|
||||||
@@ -1575,6 +1583,8 @@ addNetworkHandler("ModMenu:ExecuteSpawnVehicle", function(vehicleName) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("[ModMenu] Spawning vehicle: " + vehicleName + " (hash: " + modelHash + ")");
|
||||||
|
|
||||||
// Request the model first
|
// Request the model first
|
||||||
natives.requestModel(modelHash);
|
natives.requestModel(modelHash);
|
||||||
|
|
||||||
@@ -1587,29 +1597,36 @@ addNetworkHandler("ModMenu:ExecuteSpawnVehicle", function(vehicleName) {
|
|||||||
|
|
||||||
let pos = localPlayer.position;
|
let pos = localPlayer.position;
|
||||||
let heading = localPlayer.heading || 0;
|
let heading = localPlayer.heading || 0;
|
||||||
let spawnPos = new Vec3(pos.x, pos.y, pos.z + 1);
|
|
||||||
|
|
||||||
// Create the car
|
// Spawn position in front of player
|
||||||
let vehicle = natives.createCar(modelHash, spawnPos, true);
|
let spawnX = pos.x + Math.sin(-heading) * 5;
|
||||||
|
let spawnY = pos.y + Math.cos(-heading) * 5;
|
||||||
|
let spawnZ = pos.z + 0.5;
|
||||||
|
|
||||||
|
// Create the car using x, y, z coordinates
|
||||||
|
// GTA IV native: CREATE_CAR(hash, x, y, z, outVehicle, bool)
|
||||||
|
let vehicle = natives.createCar(modelHash, spawnX, spawnY, spawnZ, true);
|
||||||
|
|
||||||
if (vehicle) {
|
if (vehicle) {
|
||||||
|
// Set vehicle heading to match player
|
||||||
natives.setCarHeading(vehicle, heading);
|
natives.setCarHeading(vehicle, heading);
|
||||||
// Warp player into the vehicle
|
// Warp player into the vehicle
|
||||||
natives.warpCharIntoCar(localPlayer, vehicle);
|
natives.warpCharIntoCar(localPlayer, vehicle);
|
||||||
showNotification("Spawned: " + vehicleName);
|
showNotification("Spawned: " + vehicleName);
|
||||||
|
console.log("[ModMenu] Vehicle spawned successfully");
|
||||||
} else {
|
} else {
|
||||||
showNotification("Failed to create vehicle");
|
showNotification("Failed to create vehicle");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark model as no longer needed
|
// Mark model as no longer needed
|
||||||
natives.markModelAsNoLongerNeeded(modelHash);
|
natives.markModelAsNoLongerNeeded(modelHash);
|
||||||
} else if (attempts > 50) {
|
} else if (attempts > 100) {
|
||||||
clearInterval(spawnInterval);
|
clearInterval(spawnInterval);
|
||||||
showNotification("Model load timeout for: " + vehicleName);
|
showNotification("Model load timeout for: " + vehicleName);
|
||||||
}
|
}
|
||||||
}, 100);
|
}, 50); // Check every 50ms instead of 100ms
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log("[ModMenu] Vehicle error: " + e);
|
console.log("[ModMenu] Vehicle spawn error: " + e);
|
||||||
showNotification("Error: " + e);
|
showNotification("Error: " + e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user