mirror of
https://github.com/iDisaster/GTAConnected.git
synced 2026-03-16 05:11:49 +00:00
Add self options and fix network player list
Self Options (new): - Invincible toggle (setCharInvincible + setCharProofs) - Super Run toggle (setCharMoveAnimSpeedMultiplier at 3x) - No Ragdoll toggle (setPedCanRagdoll + switchPedToAnimated) Network Options (fixed): - Auto-refresh player list when entering network menu - Show player count in menu header - Direct teleport to player action (no submenu) - Server now sends target position directly for teleport - Added debug logging for player list retrieval - Show helpful message when no players found
This commit is contained in:
@@ -75,8 +75,13 @@ const menuData = {
|
|||||||
{ label: "Max Health & Armor", action: "self_max" },
|
{ label: "Max Health & Armor", action: "self_max" },
|
||||||
{ label: "Give All Weapons", action: "self_weapons" },
|
{ label: "Give All Weapons", action: "self_weapons" },
|
||||||
{ label: "Clear Wanted Level", action: "self_wanted" },
|
{ label: "Clear Wanted Level", action: "self_wanted" },
|
||||||
|
{ label: "--- Toggles ---", action: "none" },
|
||||||
{ label: "God Mode", action: "toggle", target: "godMode", state: false },
|
{ label: "God Mode", action: "toggle", target: "godMode", state: false },
|
||||||
|
{ label: "Invincible", action: "toggle", target: "invincible", state: false },
|
||||||
|
{ label: "Super Run", action: "toggle", target: "superRun", state: false },
|
||||||
|
{ label: "No Ragdoll", action: "toggle", target: "noRagdoll", state: false },
|
||||||
{ label: "Never Wanted", action: "toggle", target: "neverWanted", state: false },
|
{ label: "Never Wanted", action: "toggle", target: "neverWanted", state: false },
|
||||||
|
{ label: "--- Actions ---", action: "none" },
|
||||||
{ label: "Respawn", action: "self_respawn" },
|
{ label: "Respawn", action: "self_respawn" },
|
||||||
{ label: "Suicide", action: "self_suicide" },
|
{ label: "Suicide", action: "self_suicide" },
|
||||||
{ label: "Change Skin", action: "submenu", target: "skins" }
|
{ label: "Change Skin", action: "submenu", target: "skins" }
|
||||||
@@ -312,6 +317,9 @@ const menuData = {
|
|||||||
// Toggle states
|
// Toggle states
|
||||||
let toggleStates = {
|
let toggleStates = {
|
||||||
godMode: false,
|
godMode: false,
|
||||||
|
invincible: false,
|
||||||
|
superRun: false,
|
||||||
|
noRagdoll: false,
|
||||||
neverWanted: false,
|
neverWanted: false,
|
||||||
vehGodMode: false,
|
vehGodMode: false,
|
||||||
driveOnWater: false,
|
driveOnWater: false,
|
||||||
@@ -465,19 +473,29 @@ function getCurrentMenuItems() {
|
|||||||
function getNetworkMenuItems() {
|
function getNetworkMenuItems() {
|
||||||
let items = [
|
let items = [
|
||||||
{ label: "Refresh Player List", action: "refresh_players" },
|
{ label: "Refresh Player List", action: "refresh_players" },
|
||||||
{ label: "--- Players ---", action: "none" }
|
{ label: "--- Players (" + playerList.length + ") ---", action: "none" }
|
||||||
];
|
];
|
||||||
for (let i = 0; i < playerList.length; i++) {
|
for (let i = 0; i < playerList.length; i++) {
|
||||||
items.push({
|
items.push({
|
||||||
label: playerList[i].name,
|
label: playerList[i].name + " [ID: " + playerList[i].id + "]",
|
||||||
action: "submenu",
|
action: "teleport_to_player_direct",
|
||||||
target: "player_options",
|
|
||||||
playerData: playerList[i]
|
playerData: playerList[i]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (playerList.length === 0) {
|
||||||
|
items.push({ label: "(No players found)", action: "none" });
|
||||||
|
items.push({ label: "(Click Refresh above)", action: "none" });
|
||||||
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Refresh player list function
|
||||||
|
function refreshPlayerList() {
|
||||||
|
// Request player list from server
|
||||||
|
triggerNetworkEvent("ModMenu:GetPlayers");
|
||||||
|
showNotification("Refreshing players...");
|
||||||
|
}
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// ACTION HANDLING
|
// ACTION HANDLING
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -499,6 +517,11 @@ function selectItem() {
|
|||||||
currentMenu = item.target;
|
currentMenu = item.target;
|
||||||
selectedIndex = 0;
|
selectedIndex = 0;
|
||||||
scrollOffset = 0;
|
scrollOffset = 0;
|
||||||
|
|
||||||
|
// Auto-refresh player list when entering network menu
|
||||||
|
if (item.target === "network") {
|
||||||
|
refreshPlayerList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -616,8 +639,7 @@ function selectItem() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "refresh_players":
|
case "refresh_players":
|
||||||
triggerNetworkEvent("ModMenu:GetPlayers");
|
refreshPlayerList();
|
||||||
showNotification("Refreshing...");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "teleport_to_player":
|
case "teleport_to_player":
|
||||||
@@ -627,6 +649,13 @@ function selectItem() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "teleport_to_player_direct":
|
||||||
|
if (item.playerData) {
|
||||||
|
triggerNetworkEvent("ModMenu:TeleportToPlayer", item.playerData.id);
|
||||||
|
showNotification("Teleporting to " + item.playerData.name);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case "fun_launch":
|
case "fun_launch":
|
||||||
triggerNetworkEvent("ModMenu:Fun", "launch");
|
triggerNetworkEvent("ModMenu:Fun", "launch");
|
||||||
showNotification("LAUNCH!");
|
showNotification("LAUNCH!");
|
||||||
@@ -1124,8 +1153,11 @@ addEventHandler("OnDrawnHUD", function(event) {
|
|||||||
// TOGGLE EFFECTS
|
// TOGGLE EFFECTS
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
// Track last god mode state to only call native when changed
|
// Track last toggle states to only call native when changed
|
||||||
let lastGodMode = false;
|
let lastGodMode = false;
|
||||||
|
let lastInvincible = false;
|
||||||
|
let lastSuperRun = false;
|
||||||
|
let lastNoRagdoll = false;
|
||||||
let lastVehGodMode = false;
|
let lastVehGodMode = false;
|
||||||
let lastDriftMode = false;
|
let lastDriftMode = false;
|
||||||
let processCounter = 0;
|
let processCounter = 0;
|
||||||
@@ -1134,7 +1166,7 @@ addEventHandler("OnProcess", function(event) {
|
|||||||
if (!localPlayer) return;
|
if (!localPlayer) return;
|
||||||
processCounter++;
|
processCounter++;
|
||||||
|
|
||||||
// Player god mode - use invincibility native
|
// Player god mode - use invincibility native + health
|
||||||
if (toggleStates.godMode !== lastGodMode) {
|
if (toggleStates.godMode !== lastGodMode) {
|
||||||
try {
|
try {
|
||||||
natives.setCharInvincible(localPlayer, toggleStates.godMode);
|
natives.setCharInvincible(localPlayer, toggleStates.godMode);
|
||||||
@@ -1148,6 +1180,45 @@ addEventHandler("OnProcess", function(event) {
|
|||||||
if (localPlayer.armour < 100) localPlayer.armour = 100;
|
if (localPlayer.armour < 100) localPlayer.armour = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Invincible toggle - separate from god mode, just invincibility
|
||||||
|
if (toggleStates.invincible !== lastInvincible) {
|
||||||
|
try {
|
||||||
|
natives.setCharInvincible(localPlayer, toggleStates.invincible);
|
||||||
|
natives.setCharProofs(localPlayer, toggleStates.invincible, toggleStates.invincible, toggleStates.invincible, toggleStates.invincible, toggleStates.invincible);
|
||||||
|
} catch(e) {}
|
||||||
|
lastInvincible = toggleStates.invincible;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Super Run - increase movement speed
|
||||||
|
if (toggleStates.superRun !== lastSuperRun) {
|
||||||
|
try {
|
||||||
|
if (toggleStates.superRun) {
|
||||||
|
natives.setCharMoveAnimSpeedMultiplier(localPlayer, 3.0);
|
||||||
|
} else {
|
||||||
|
natives.setCharMoveAnimSpeedMultiplier(localPlayer, 1.0);
|
||||||
|
}
|
||||||
|
} catch(e) {}
|
||||||
|
lastSuperRun = toggleStates.superRun;
|
||||||
|
}
|
||||||
|
|
||||||
|
// No Ragdoll - prevent ragdoll
|
||||||
|
if (toggleStates.noRagdoll !== lastNoRagdoll) {
|
||||||
|
try {
|
||||||
|
natives.setPedCanRagdoll(localPlayer, !toggleStates.noRagdoll);
|
||||||
|
} catch(e) {}
|
||||||
|
lastNoRagdoll = toggleStates.noRagdoll;
|
||||||
|
}
|
||||||
|
// Keep preventing ragdoll every frame
|
||||||
|
if (toggleStates.noRagdoll) {
|
||||||
|
try {
|
||||||
|
natives.setPedCanRagdoll(localPlayer, false);
|
||||||
|
// Cancel any active ragdoll
|
||||||
|
if (natives.isPedRagdoll(localPlayer)) {
|
||||||
|
natives.switchPedToAnimated(localPlayer, true);
|
||||||
|
}
|
||||||
|
} catch(e) {}
|
||||||
|
}
|
||||||
|
|
||||||
// Never wanted - clear wanted level
|
// Never wanted - clear wanted level
|
||||||
if (toggleStates.neverWanted) {
|
if (toggleStates.neverWanted) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -139,9 +139,15 @@ addNetworkHandler("ModMenu:TeleportToPlayer", function(client, targetId) {
|
|||||||
let clients = getClients();
|
let clients = getClients();
|
||||||
for (let i = 0; i < clients.length; i++) {
|
for (let i = 0; i < clients.length; i++) {
|
||||||
if (clients[i].index == targetId) {
|
if (clients[i].index == targetId) {
|
||||||
triggerNetworkEvent("ModMenu:Notification", client, "Teleporting to: " + clients[i].name);
|
// Get target player's position from server
|
||||||
// Client will handle the actual teleport
|
if (clients[i].player) {
|
||||||
triggerNetworkEvent("ModMenu:ExecuteTeleportToPlayer", client, targetId);
|
let targetPos = clients[i].player.position;
|
||||||
|
triggerNetworkEvent("ModMenu:Notification", client, "Teleporting to: " + clients[i].name);
|
||||||
|
// Send position directly to client
|
||||||
|
triggerNetworkEvent("ModMenu:ExecuteTeleport", client, targetPos.x + 2, targetPos.y, targetPos.z);
|
||||||
|
} else {
|
||||||
|
triggerNetworkEvent("ModMenu:Notification", client, "Player not spawned!");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -156,13 +162,24 @@ addNetworkHandler("ModMenu:GetPlayers", function(client) {
|
|||||||
let clients = getClients();
|
let clients = getClients();
|
||||||
let playerList = [];
|
let playerList = [];
|
||||||
|
|
||||||
|
console.log("[ModMenu] Getting players, found " + clients.length + " clients");
|
||||||
|
|
||||||
for (let i = 0; i < clients.length; i++) {
|
for (let i = 0; i < clients.length; i++) {
|
||||||
playerList.push({
|
let c = clients[i];
|
||||||
id: clients[i].index,
|
// Skip the requesting player (optional - include self for testing)
|
||||||
name: clients[i].name
|
// if (c.index === client.index) continue;
|
||||||
});
|
|
||||||
|
// Only add players with valid data
|
||||||
|
if (c && c.name) {
|
||||||
|
playerList.push({
|
||||||
|
id: c.index,
|
||||||
|
name: c.name || ("Player " + c.index)
|
||||||
|
});
|
||||||
|
console.log("[ModMenu] Added player: " + c.name + " (ID: " + c.index + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("[ModMenu] Sending " + playerList.length + " players to " + client.name);
|
||||||
triggerNetworkEvent("ModMenu:PlayerList", client, playerList);
|
triggerNetworkEvent("ModMenu:PlayerList", client, playerList);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user