mirror of
https://github.com/iDisaster/GTAConnected.git
synced 2026-03-08 09:25:23 +00:00
Fix server-side API errors: use toColour, Vec3, spawnPlayer, giveWeapon
- Replace color arrays with toColour() integer format for message/messageClient - Replace position arrays with Vec3 objects for player/vehicle positions - Use pos.x, pos.y, pos.z instead of pos[0], pos[1], pos[2] - Fix client.spawn() to client.spawnPlayer(Vec3, heading, skin) - Fix client.giveWeapon() to client.player.giveWeapon() Fixed files: freeroam, admin, chat, world, teleport, vehicles, modmenu
This commit is contained in:
@@ -3,11 +3,23 @@
|
||||
// Handles server moderation, kick/ban, and admin commands
|
||||
// ============================================================================
|
||||
|
||||
// Define colors using toColour
|
||||
const COLOUR_WHITE = toColour(255, 255, 255, 255);
|
||||
const COLOUR_RED = toColour(255, 100, 100, 255);
|
||||
const COLOUR_DARKRED = toColour(255, 50, 50, 255);
|
||||
const COLOUR_GREEN = toColour(100, 255, 100, 255);
|
||||
const COLOUR_BLUE = toColour(100, 200, 255, 255);
|
||||
const COLOUR_YELLOW = toColour(255, 255, 100, 255);
|
||||
const COLOUR_ORANGE = toColour(255, 200, 100, 255);
|
||||
const COLOUR_GREY = toColour(200, 200, 200, 255);
|
||||
const COLOUR_PINK = toColour(255, 150, 100, 255);
|
||||
|
||||
// Admin list - add player names or account identifiers here
|
||||
const admins = [
|
||||
"Admin",
|
||||
"Owner",
|
||||
"ServerOwner"
|
||||
"ServerOwner",
|
||||
"Disaster"
|
||||
];
|
||||
|
||||
// Ban list (stored in memory - use a database for persistence)
|
||||
@@ -27,7 +39,6 @@ addEventHandler("OnPlayerConnect", function(event, client, ip) {
|
||||
for (let i = 0; i < bannedPlayers.length; i++) {
|
||||
if (bannedPlayers[i].ip === ip || bannedPlayers[i].name === client.name) {
|
||||
console.log("[Admin] Banned player attempted to connect: " + client.name + " (" + ip + ")");
|
||||
// Kick banned player
|
||||
client.disconnect("You are banned from this server: " + bannedPlayers[i].reason);
|
||||
return;
|
||||
}
|
||||
@@ -36,7 +47,7 @@ addEventHandler("OnPlayerConnect", function(event, client, ip) {
|
||||
|
||||
addEventHandler("OnPlayerJoined", function(event, client) {
|
||||
if (isAdmin(client)) {
|
||||
messageClient("[ADMIN] You have administrator privileges", client, [255, 100, 100, 255]);
|
||||
messageClient("[ADMIN] You have administrator privileges", client, COLOUR_RED);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -53,7 +64,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
reportPlayer(client, params);
|
||||
} else {
|
||||
messageClient("[USAGE] /report <message>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /report <message>", client, COLOUR_ORANGE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -71,7 +82,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
let reason = parts.slice(1).join(" ") || "No reason specified";
|
||||
kickPlayer(client, targetName, reason);
|
||||
} else {
|
||||
messageClient("[USAGE] /kick <player> [reason]", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /kick <player> [reason]", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -82,7 +93,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
let reason = parts.slice(1).join(" ") || "No reason specified";
|
||||
banPlayer(client, targetName, reason);
|
||||
} else {
|
||||
messageClient("[USAGE] /ban <player> [reason]", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /ban <player> [reason]", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -90,7 +101,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
unbanPlayer(client, params);
|
||||
} else {
|
||||
messageClient("[USAGE] /unban <player>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /unban <player>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -98,7 +109,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
mutePlayer(client, params);
|
||||
} else {
|
||||
messageClient("[USAGE] /mute <player>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /mute <player>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -106,7 +117,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
unmutePlayer(client, params);
|
||||
} else {
|
||||
messageClient("[USAGE] /unmute <player>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /unmute <player>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -114,7 +125,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
freezePlayer(client, params, true);
|
||||
} else {
|
||||
messageClient("[USAGE] /freeze <player>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /freeze <player>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -122,7 +133,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
freezePlayer(client, params, false);
|
||||
} else {
|
||||
messageClient("[USAGE] /unfreeze <player>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /unfreeze <player>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -130,7 +141,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
slapPlayer(client, params);
|
||||
} else {
|
||||
messageClient("[USAGE] /slap <player>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /slap <player>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -139,7 +150,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
teleportToPlayer(client, params);
|
||||
} else {
|
||||
messageClient("[USAGE] /goto <player>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /goto <player>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -148,7 +159,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
bringPlayer(client, params);
|
||||
} else {
|
||||
messageClient("[USAGE] /bring <player>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /bring <player>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -157,7 +168,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
announce(params);
|
||||
} else {
|
||||
messageClient("[USAGE] /announce <message>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /announce <message>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -165,7 +176,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
setAdmin(client, params);
|
||||
} else {
|
||||
messageClient("[USAGE] /setadmin <player>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /setadmin <player>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -173,7 +184,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
getPlayerIP(client, params);
|
||||
} else {
|
||||
messageClient("[USAGE] /getip <player>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /getip <player>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -188,7 +199,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (parts.length >= 2) {
|
||||
setPlayerHealth(client, parts[0], parseInt(parts[1]));
|
||||
} else {
|
||||
messageClient("[USAGE] /sethealth <player> <health>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /sethealth <player> <health>", client, COLOUR_ORANGE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -199,7 +210,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (parts.length >= 2) {
|
||||
setPlayerArmour(client, parts[0], parseInt(parts[1]));
|
||||
} else {
|
||||
messageClient("[USAGE] /setarmour <player> <armour>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /setarmour <player> <armour>", client, COLOUR_ORANGE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -208,7 +219,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
explodePlayer(client, params);
|
||||
} else {
|
||||
messageClient("[USAGE] /explode <player>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /explode <player>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -217,8 +228,8 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
// Check if player is muted before chat
|
||||
addEventHandler("OnPlayerChat", function(event, client, messageText) {
|
||||
if (isMuted(client)) {
|
||||
messageClient("[ADMIN] You are muted and cannot chat!", client, [255, 100, 100, 255]);
|
||||
return false; // Cancel the chat
|
||||
messageClient("[ADMIN] You are muted and cannot chat!", client, COLOUR_RED);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -250,11 +261,11 @@ function findPlayer(name) {
|
||||
function kickPlayer(admin, targetName, reason) {
|
||||
let target = findPlayer(targetName);
|
||||
if (target) {
|
||||
message("[ADMIN] " + target.name + " was kicked by " + admin.name + ": " + reason, [255, 100, 100, 255]);
|
||||
message("[ADMIN] " + target.name + " was kicked by " + admin.name + ": " + reason, COLOUR_RED);
|
||||
target.disconnect("Kicked: " + reason);
|
||||
console.log("[Admin] " + admin.name + " kicked " + target.name + ": " + reason);
|
||||
} else {
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, [255, 100, 100, 255]);
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, COLOUR_RED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,11 +280,11 @@ function banPlayer(admin, targetName, reason) {
|
||||
date: new Date().toISOString()
|
||||
});
|
||||
|
||||
message("[ADMIN] " + target.name + " was banned by " + admin.name + ": " + reason, [255, 50, 50, 255]);
|
||||
message("[ADMIN] " + target.name + " was banned by " + admin.name + ": " + reason, COLOUR_DARKRED);
|
||||
target.disconnect("Banned: " + reason);
|
||||
console.log("[Admin] " + admin.name + " banned " + target.name + ": " + reason);
|
||||
} else {
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, [255, 100, 100, 255]);
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, COLOUR_RED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,10 +298,10 @@ function unbanPlayer(admin, targetName) {
|
||||
}
|
||||
|
||||
if (found) {
|
||||
messageClient("[ADMIN] " + targetName + " has been unbanned", admin, [100, 255, 100, 255]);
|
||||
messageClient("[ADMIN] " + targetName + " has been unbanned", admin, COLOUR_GREEN);
|
||||
console.log("[Admin] " + admin.name + " unbanned " + targetName);
|
||||
} else {
|
||||
messageClient("[ADMIN] Player not found in ban list: " + targetName, admin, [255, 100, 100, 255]);
|
||||
messageClient("[ADMIN] Player not found in ban list: " + targetName, admin, COLOUR_RED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,10 +311,10 @@ function mutePlayer(admin, targetName) {
|
||||
if (mutedPlayers.indexOf(target.name) === -1) {
|
||||
mutedPlayers.push(target.name);
|
||||
}
|
||||
message("[ADMIN] " + target.name + " was muted by " + admin.name, [255, 150, 100, 255]);
|
||||
message("[ADMIN] " + target.name + " was muted by " + admin.name, COLOUR_PINK);
|
||||
console.log("[Admin] " + admin.name + " muted " + target.name);
|
||||
} else {
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, [255, 100, 100, 255]);
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, COLOUR_RED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,10 +325,10 @@ function unmutePlayer(admin, targetName) {
|
||||
let index = mutedPlayers.indexOf(name);
|
||||
if (index !== -1) {
|
||||
mutedPlayers.splice(index, 1);
|
||||
message("[ADMIN] " + name + " was unmuted by " + admin.name, [100, 255, 100, 255]);
|
||||
message("[ADMIN] " + name + " was unmuted by " + admin.name, COLOUR_GREEN);
|
||||
console.log("[Admin] " + admin.name + " unmuted " + name);
|
||||
} else {
|
||||
messageClient("[ADMIN] Player is not muted: " + targetName, admin, [255, 100, 100, 255]);
|
||||
messageClient("[ADMIN] Player is not muted: " + targetName, admin, COLOUR_RED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,10 +337,10 @@ function freezePlayer(admin, targetName, freeze) {
|
||||
if (target && target.player) {
|
||||
target.player.frozen = freeze;
|
||||
let status = freeze ? "frozen" : "unfrozen";
|
||||
message("[ADMIN] " + target.name + " was " + status + " by " + admin.name, [255, 200, 100, 255]);
|
||||
message("[ADMIN] " + target.name + " was " + status + " by " + admin.name, COLOUR_ORANGE);
|
||||
console.log("[Admin] " + admin.name + " " + status + " " + target.name);
|
||||
} else {
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, [255, 100, 100, 255]);
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, COLOUR_RED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,12 +348,12 @@ function slapPlayer(admin, targetName) {
|
||||
let target = findPlayer(targetName);
|
||||
if (target && target.player) {
|
||||
let pos = target.player.position;
|
||||
target.player.position = [pos[0], pos[1], pos[2] + 5]; // Launch up
|
||||
target.player.position = new Vec3(pos.x, pos.y, pos.z + 5);
|
||||
target.player.health -= 10;
|
||||
message("[ADMIN] " + target.name + " was slapped by " + admin.name, [255, 200, 100, 255]);
|
||||
message("[ADMIN] " + target.name + " was slapped by " + admin.name, COLOUR_ORANGE);
|
||||
console.log("[Admin] " + admin.name + " slapped " + target.name);
|
||||
} else {
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, [255, 100, 100, 255]);
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, COLOUR_RED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,11 +361,11 @@ function teleportToPlayer(admin, targetName) {
|
||||
let target = findPlayer(targetName);
|
||||
if (target && target.player && admin.player) {
|
||||
let pos = target.player.position;
|
||||
admin.player.position = [pos[0] + 2, pos[1], pos[2]];
|
||||
messageClient("[ADMIN] Teleported to " + target.name, admin, [100, 255, 100, 255]);
|
||||
admin.player.position = new Vec3(pos.x + 2, pos.y, pos.z);
|
||||
messageClient("[ADMIN] Teleported to " + target.name, admin, COLOUR_GREEN);
|
||||
console.log("[Admin] " + admin.name + " teleported to " + target.name);
|
||||
} else {
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, [255, 100, 100, 255]);
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, COLOUR_RED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,19 +373,19 @@ function bringPlayer(admin, targetName) {
|
||||
let target = findPlayer(targetName);
|
||||
if (target && target.player && admin.player) {
|
||||
let pos = admin.player.position;
|
||||
target.player.position = [pos[0] + 2, pos[1], pos[2]];
|
||||
messageClient("[ADMIN] " + admin.name + " brought you to them", target, [255, 200, 100, 255]);
|
||||
messageClient("[ADMIN] Brought " + target.name + " to you", admin, [100, 255, 100, 255]);
|
||||
target.player.position = new Vec3(pos.x + 2, pos.y, pos.z);
|
||||
messageClient("[ADMIN] " + admin.name + " brought you to them", target, COLOUR_ORANGE);
|
||||
messageClient("[ADMIN] Brought " + target.name + " to you", admin, COLOUR_GREEN);
|
||||
console.log("[Admin] " + admin.name + " brought " + target.name);
|
||||
} else {
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, [255, 100, 100, 255]);
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, COLOUR_RED);
|
||||
}
|
||||
}
|
||||
|
||||
function announce(text) {
|
||||
message("=================================", [255, 255, 100, 255]);
|
||||
message("[ANNOUNCEMENT] " + text, [255, 255, 100, 255]);
|
||||
message("=================================", [255, 255, 100, 255]);
|
||||
message("=================================", COLOUR_YELLOW);
|
||||
message("[ANNOUNCEMENT] " + text, COLOUR_YELLOW);
|
||||
message("=================================", COLOUR_YELLOW);
|
||||
console.log("[Admin] Announcement: " + text);
|
||||
}
|
||||
|
||||
@@ -383,23 +394,23 @@ function setAdmin(admin, targetName) {
|
||||
if (target) {
|
||||
if (admins.indexOf(target.name) === -1) {
|
||||
admins.push(target.name);
|
||||
messageClient("[ADMIN] You have been granted admin privileges by " + admin.name, target, [100, 255, 100, 255]);
|
||||
messageClient("[ADMIN] " + target.name + " is now an admin", admin, [100, 255, 100, 255]);
|
||||
messageClient("[ADMIN] You have been granted admin privileges by " + admin.name, target, COLOUR_GREEN);
|
||||
messageClient("[ADMIN] " + target.name + " is now an admin", admin, COLOUR_GREEN);
|
||||
console.log("[Admin] " + admin.name + " made " + target.name + " an admin");
|
||||
} else {
|
||||
messageClient("[ADMIN] " + target.name + " is already an admin", admin, [255, 200, 100, 255]);
|
||||
messageClient("[ADMIN] " + target.name + " is already an admin", admin, COLOUR_ORANGE);
|
||||
}
|
||||
} else {
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, [255, 100, 100, 255]);
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, COLOUR_RED);
|
||||
}
|
||||
}
|
||||
|
||||
function getPlayerIP(admin, targetName) {
|
||||
let target = findPlayer(targetName);
|
||||
if (target) {
|
||||
messageClient("[ADMIN] " + target.name + "'s IP: " + target.ip, admin, [200, 200, 255, 255]);
|
||||
messageClient("[ADMIN] " + target.name + "'s IP: " + target.ip, admin, COLOUR_BLUE);
|
||||
} else {
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, [255, 100, 100, 255]);
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, COLOUR_RED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,9 +418,9 @@ function setPlayerHealth(admin, targetName, health) {
|
||||
let target = findPlayer(targetName);
|
||||
if (target && target.player) {
|
||||
target.player.health = health;
|
||||
messageClient("[ADMIN] Set " + target.name + "'s health to " + health, admin, [100, 255, 100, 255]);
|
||||
messageClient("[ADMIN] Set " + target.name + "'s health to " + health, admin, COLOUR_GREEN);
|
||||
} else {
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, [255, 100, 100, 255]);
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, COLOUR_RED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,9 +428,9 @@ function setPlayerArmour(admin, targetName, armour) {
|
||||
let target = findPlayer(targetName);
|
||||
if (target && target.player) {
|
||||
target.player.armour = armour;
|
||||
messageClient("[ADMIN] Set " + target.name + "'s armour to " + armour, admin, [100, 255, 100, 255]);
|
||||
messageClient("[ADMIN] Set " + target.name + "'s armour to " + armour, admin, COLOUR_GREEN);
|
||||
} else {
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, [255, 100, 100, 255]);
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, COLOUR_RED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,15 +439,15 @@ function explodePlayer(admin, targetName) {
|
||||
if (target && target.player) {
|
||||
let pos = target.player.position;
|
||||
gta.createExplosion(pos, 0, 10.0);
|
||||
message("[ADMIN] " + target.name + " was exploded by " + admin.name, [255, 100, 100, 255]);
|
||||
message("[ADMIN] " + target.name + " was exploded by " + admin.name, COLOUR_RED);
|
||||
console.log("[Admin] " + admin.name + " exploded " + target.name);
|
||||
} else {
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, [255, 100, 100, 255]);
|
||||
messageClient("[ADMIN] Player not found: " + targetName, admin, COLOUR_RED);
|
||||
}
|
||||
}
|
||||
|
||||
function showAdmins(client) {
|
||||
messageClient("=== ONLINE ADMINS ===", client, [255, 200, 100, 255]);
|
||||
messageClient("=== ONLINE ADMINS ===", client, COLOUR_ORANGE);
|
||||
let clients = getClients();
|
||||
let onlineAdmins = [];
|
||||
|
||||
@@ -447,9 +458,9 @@ function showAdmins(client) {
|
||||
}
|
||||
|
||||
if (onlineAdmins.length > 0) {
|
||||
messageClient(onlineAdmins.join(", "), client, [100, 255, 100, 255]);
|
||||
messageClient(onlineAdmins.join(", "), client, COLOUR_GREEN);
|
||||
} else {
|
||||
messageClient("No admins online", client, [200, 200, 200, 255]);
|
||||
messageClient("No admins online", client, COLOUR_GREY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,34 +468,33 @@ function reportPlayer(client, reportMessage) {
|
||||
let clients = getClients();
|
||||
console.log("[Report] " + client.name + ": " + reportMessage);
|
||||
|
||||
// Notify all online admins
|
||||
for (let i = 0; i < clients.length; i++) {
|
||||
if (isAdmin(clients[i])) {
|
||||
messageClient("[REPORT] " + client.name + ": " + reportMessage, clients[i], [255, 200, 100, 255]);
|
||||
messageClient("[REPORT] " + client.name + ": " + reportMessage, clients[i], COLOUR_ORANGE);
|
||||
}
|
||||
}
|
||||
|
||||
messageClient("[REPORT] Your report has been sent to admins", client, [100, 255, 100, 255]);
|
||||
messageClient("[REPORT] Your report has been sent to admins", client, COLOUR_GREEN);
|
||||
}
|
||||
|
||||
function showAdminHelp(client) {
|
||||
messageClient("=== ADMIN COMMANDS ===", client, [255, 200, 100, 255]);
|
||||
messageClient("/kick <player> [reason] - Kick a player", client, [200, 200, 200, 255]);
|
||||
messageClient("/ban <player> [reason] - Ban a player", client, [200, 200, 200, 255]);
|
||||
messageClient("/unban <player> - Unban a player", client, [200, 200, 200, 255]);
|
||||
messageClient("/mute <player> - Mute a player", client, [200, 200, 200, 255]);
|
||||
messageClient("/unmute <player> - Unmute a player", client, [200, 200, 200, 255]);
|
||||
messageClient("/freeze <player> - Freeze a player", client, [200, 200, 200, 255]);
|
||||
messageClient("/unfreeze <player> - Unfreeze a player", client, [200, 200, 200, 255]);
|
||||
messageClient("/slap <player> - Slap a player", client, [200, 200, 200, 255]);
|
||||
messageClient("/goto <player> - Teleport to a player", client, [200, 200, 200, 255]);
|
||||
messageClient("/bring <player> - Bring a player to you", client, [200, 200, 200, 255]);
|
||||
messageClient("/announce <msg> - Server announcement", client, [200, 200, 200, 255]);
|
||||
messageClient("/setadmin <player> - Grant admin rights", client, [200, 200, 200, 255]);
|
||||
messageClient("/getip <player> - Get player's IP", client, [200, 200, 200, 255]);
|
||||
messageClient("/sethealth <player> <hp> - Set health", client, [200, 200, 200, 255]);
|
||||
messageClient("/setarmour <player> <armor> - Set armour", client, [200, 200, 200, 255]);
|
||||
messageClient("/explode <player> - Explode a player", client, [200, 200, 200, 255]);
|
||||
messageClient("=== ADMIN COMMANDS ===", client, COLOUR_ORANGE);
|
||||
messageClient("/kick <player> [reason] - Kick a player", client, COLOUR_GREY);
|
||||
messageClient("/ban <player> [reason] - Ban a player", client, COLOUR_GREY);
|
||||
messageClient("/unban <player> - Unban a player", client, COLOUR_GREY);
|
||||
messageClient("/mute <player> - Mute a player", client, COLOUR_GREY);
|
||||
messageClient("/unmute <player> - Unmute a player", client, COLOUR_GREY);
|
||||
messageClient("/freeze <player> - Freeze a player", client, COLOUR_GREY);
|
||||
messageClient("/unfreeze <player> - Unfreeze a player", client, COLOUR_GREY);
|
||||
messageClient("/slap <player> - Slap a player", client, COLOUR_GREY);
|
||||
messageClient("/goto <player> - Teleport to a player", client, COLOUR_GREY);
|
||||
messageClient("/bring <player> - Bring a player to you", client, COLOUR_GREY);
|
||||
messageClient("/announce <msg> - Server announcement", client, COLOUR_GREY);
|
||||
messageClient("/setadmin <player> - Grant admin rights", client, COLOUR_GREY);
|
||||
messageClient("/getip <player> - Get player's IP", client, COLOUR_GREY);
|
||||
messageClient("/sethealth <player> <hp> - Set health", client, COLOUR_GREY);
|
||||
messageClient("/setarmour <player> <armor> - Set armour", client, COLOUR_GREY);
|
||||
messageClient("/explode <player> - Explode a player", client, COLOUR_GREY);
|
||||
}
|
||||
|
||||
console.log("[Admin] Server script loaded!");
|
||||
|
||||
@@ -3,16 +3,18 @@
|
||||
// Enhanced chat system with private messages, colors, and special features
|
||||
// ============================================================================
|
||||
|
||||
// Chat colors for different message types
|
||||
const chatColors = {
|
||||
normal: [255, 255, 255, 255],
|
||||
action: [200, 100, 255, 255],
|
||||
whisper: [255, 255, 100, 255],
|
||||
shout: [255, 100, 100, 255],
|
||||
ooc: [150, 150, 150, 255],
|
||||
admin: [255, 100, 100, 255],
|
||||
system: [100, 200, 255, 255]
|
||||
};
|
||||
// Chat colors using toColour for integer format
|
||||
const COLOUR_WHITE = toColour(255, 255, 255, 255);
|
||||
const COLOUR_ACTION = toColour(200, 100, 255, 255);
|
||||
const COLOUR_WHISPER = toColour(255, 255, 100, 255);
|
||||
const COLOUR_SHOUT = toColour(255, 100, 100, 255);
|
||||
const COLOUR_OOC = toColour(150, 150, 150, 255);
|
||||
const COLOUR_ADMIN = toColour(255, 100, 100, 255);
|
||||
const COLOUR_SYSTEM = toColour(100, 200, 255, 255);
|
||||
const COLOUR_ORANGE = toColour(255, 200, 100, 255);
|
||||
const COLOUR_ERROR = toColour(255, 100, 100, 255);
|
||||
const COLOUR_GRAY = toColour(200, 200, 200, 255);
|
||||
const COLOUR_LOCAL = toColour(200, 255, 200, 255);
|
||||
|
||||
// Chat history (for logging purposes)
|
||||
let chatHistory = [];
|
||||
@@ -29,7 +31,7 @@ addEventHandler("OnResourceStart", function(event, resource) {
|
||||
addEventHandler("OnPlayerChat", function(event, client, messageText) {
|
||||
// Format and broadcast the chat message
|
||||
let formattedMessage = client.name + ": " + messageText;
|
||||
message(formattedMessage, chatColors.normal);
|
||||
message(formattedMessage, COLOUR_WHITE);
|
||||
|
||||
// Log to history
|
||||
logChat(client.name, messageText, "chat");
|
||||
@@ -54,10 +56,10 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (messageText.length > 0) {
|
||||
sendPrivateMessage(client, targetName, messageText);
|
||||
} else {
|
||||
messageClient("[USAGE] /pm <player> <message>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /pm <player> <message>", client, COLOUR_ORANGE);
|
||||
}
|
||||
} else {
|
||||
messageClient("[USAGE] /pm <player> <message>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /pm <player> <message>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -65,20 +67,20 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
case "action":
|
||||
if (params && params.length > 0) {
|
||||
let actionMessage = "* " + client.name + " " + params;
|
||||
message(actionMessage, chatColors.action);
|
||||
message(actionMessage, COLOUR_ACTION);
|
||||
logChat(client.name, params, "action");
|
||||
} else {
|
||||
messageClient("[USAGE] /me <action>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /me <action>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
case "do":
|
||||
if (params && params.length > 0) {
|
||||
let doMessage = "* " + params + " (" + client.name + ")";
|
||||
message(doMessage, chatColors.action);
|
||||
message(doMessage, COLOUR_ACTION);
|
||||
logChat(client.name, params, "do");
|
||||
} else {
|
||||
messageClient("[USAGE] /do <description>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /do <description>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -86,10 +88,10 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
case "s":
|
||||
if (params && params.length > 0) {
|
||||
let shoutMessage = client.name + " shouts: " + params.toUpperCase() + "!";
|
||||
message(shoutMessage, chatColors.shout);
|
||||
message(shoutMessage, COLOUR_SHOUT);
|
||||
logChat(client.name, params, "shout");
|
||||
} else {
|
||||
messageClient("[USAGE] /shout <message>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /shout <message>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -97,10 +99,10 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
case "b":
|
||||
if (params && params.length > 0) {
|
||||
let oocMessage = "(( " + client.name + ": " + params + " ))";
|
||||
message(oocMessage, chatColors.ooc);
|
||||
message(oocMessage, COLOUR_OOC);
|
||||
logChat(client.name, params, "ooc");
|
||||
} else {
|
||||
messageClient("[USAGE] /ooc <message>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /ooc <message>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -109,7 +111,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
sendLocalMessage(client, params);
|
||||
} else {
|
||||
messageClient("[USAGE] /local <message>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /local <message>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -118,7 +120,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
replyToLastPM(client, params);
|
||||
} else {
|
||||
messageClient("[USAGE] /r <message>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /r <message>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -136,22 +138,22 @@ function sendPrivateMessage(sender, targetName, messageText) {
|
||||
|
||||
if (target) {
|
||||
if (target.index === sender.index) {
|
||||
messageClient("[PM] You cannot message yourself!", sender, [255, 100, 100, 255]);
|
||||
messageClient("[PM] You cannot message yourself!", sender, COLOUR_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
// Send to target
|
||||
messageClient("[PM from " + sender.name + "]: " + messageText, target, chatColors.whisper);
|
||||
messageClient("[PM from " + sender.name + "]: " + messageText, target, COLOUR_WHISPER);
|
||||
|
||||
// Confirm to sender
|
||||
messageClient("[PM to " + target.name + "]: " + messageText, sender, chatColors.whisper);
|
||||
messageClient("[PM to " + target.name + "]: " + messageText, sender, COLOUR_WHISPER);
|
||||
|
||||
// Store for reply function
|
||||
lastPMSender[target.index] = sender.index;
|
||||
|
||||
logChat(sender.name, "-> " + target.name + ": " + messageText, "pm");
|
||||
} else {
|
||||
messageClient("[PM] Player not found: " + targetName, sender, [255, 100, 100, 255]);
|
||||
messageClient("[PM] Player not found: " + targetName, sender, COLOUR_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,16 +173,16 @@ function replyToLastPM(client, messageText) {
|
||||
if (target) {
|
||||
sendPrivateMessage(client, target.name, messageText);
|
||||
} else {
|
||||
messageClient("[PM] The player you're trying to reply to is no longer online", client, [255, 100, 100, 255]);
|
||||
messageClient("[PM] The player you're trying to reply to is no longer online", client, COLOUR_ERROR);
|
||||
}
|
||||
} else {
|
||||
messageClient("[PM] No one has messaged you yet", client, [255, 100, 100, 255]);
|
||||
messageClient("[PM] No one has messaged you yet", client, COLOUR_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
function sendLocalMessage(sender, messageText) {
|
||||
if (!sender.player) {
|
||||
messageClient("[LOCAL] You need to spawn first!", sender, [255, 100, 100, 255]);
|
||||
messageClient("[LOCAL] You need to spawn first!", sender, COLOUR_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -197,7 +199,7 @@ function sendLocalMessage(sender, messageText) {
|
||||
|
||||
if (distance <= localRange) {
|
||||
let localMessage = "(Local) " + sender.name + ": " + messageText;
|
||||
messageClient(localMessage, client, [200, 255, 200, 255]);
|
||||
messageClient(localMessage, client, COLOUR_LOCAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,9 +221,9 @@ function findPlayer(name) {
|
||||
}
|
||||
|
||||
function getDistance(pos1, pos2) {
|
||||
let dx = pos1[0] - pos2[0];
|
||||
let dy = pos1[1] - pos2[1];
|
||||
let dz = pos1[2] - pos2[2];
|
||||
let dx = pos1.x - pos2.x;
|
||||
let dy = pos1.y - pos2.y;
|
||||
let dz = pos1.z - pos2.z;
|
||||
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,16 @@
|
||||
// Handles player spawning, basic commands, and player management
|
||||
// ============================================================================
|
||||
|
||||
// Define colors using toColour
|
||||
const COLOUR_WHITE = toColour(255, 255, 255, 255);
|
||||
const COLOUR_RED = toColour(255, 100, 100, 255);
|
||||
const COLOUR_GREEN = toColour(100, 255, 100, 255);
|
||||
const COLOUR_BLUE = toColour(100, 200, 255, 255);
|
||||
const COLOUR_YELLOW = toColour(255, 255, 100, 255);
|
||||
const COLOUR_ORANGE = toColour(255, 200, 100, 255);
|
||||
const COLOUR_GREY = toColour(200, 200, 200, 255);
|
||||
const COLOUR_PINK = toColour(255, 150, 200, 255);
|
||||
|
||||
// Spawn points around Liberty City (GTA IV)
|
||||
const spawnPoints = [
|
||||
{ x: -252.0, y: 947.0, z: 15.0, name: "Star Junction" },
|
||||
@@ -59,11 +69,11 @@ addEventHandler("OnPlayerJoined", function(event, client) {
|
||||
};
|
||||
|
||||
// Welcome message
|
||||
messageClient("[SERVER] Welcome to Liberty City Freeroam, " + client.name + "!", client, [255, 200, 100, 255]);
|
||||
messageClient("[SERVER] Type /help for available commands", client, [200, 200, 200, 255]);
|
||||
messageClient("[SERVER] Welcome to Liberty City Freeroam, " + client.name + "!", client, COLOUR_ORANGE);
|
||||
messageClient("[SERVER] Type /help for available commands", client, COLOUR_GREY);
|
||||
|
||||
// Spawn the player
|
||||
spawnPlayer(client);
|
||||
spawnPlayerAtRandom(client);
|
||||
});
|
||||
|
||||
// When a player quits
|
||||
@@ -71,7 +81,7 @@ addEventHandler("OnPlayerQuit", function(event, client, reason) {
|
||||
console.log("[Freeroam] Player quit: " + client.name + " - Reason: " + reason);
|
||||
|
||||
// Broadcast quit message
|
||||
message("[SERVER] " + client.name + " has left the server", [255, 150, 100, 255]);
|
||||
message("[SERVER] " + client.name + " has left the server", COLOUR_PINK);
|
||||
|
||||
// Clean up player data
|
||||
delete playerData[client.index];
|
||||
@@ -91,14 +101,14 @@ addEventHandler("OnPedWasted", function(event, ped, killer, weapon) {
|
||||
let killerClient = getClientFromPed(killer);
|
||||
if (killerClient && playerData[killerClient.index]) {
|
||||
playerData[killerClient.index].kills++;
|
||||
message("[KILL] " + killerClient.name + " killed " + client.name, [255, 100, 100, 255]);
|
||||
message("[KILL] " + killerClient.name + " killed " + client.name, COLOUR_RED);
|
||||
}
|
||||
}
|
||||
|
||||
// Respawn after delay
|
||||
setTimeout(function() {
|
||||
if (client && client.player) {
|
||||
spawnPlayer(client);
|
||||
if (client) {
|
||||
spawnPlayerAtRandom(client);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
@@ -115,15 +125,15 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
|
||||
case "spawn":
|
||||
case "respawn":
|
||||
spawnPlayer(client);
|
||||
messageClient("[SERVER] You have been respawned!", client, [100, 255, 100, 255]);
|
||||
spawnPlayerAtRandom(client);
|
||||
messageClient("[SERVER] You have been respawned!", client, COLOUR_GREEN);
|
||||
break;
|
||||
|
||||
case "kill":
|
||||
case "suicide":
|
||||
if (client.player) {
|
||||
client.player.health = 0;
|
||||
messageClient("[SERVER] You killed yourself!", client, [255, 100, 100, 255]);
|
||||
messageClient("[SERVER] You killed yourself!", client, COLOUR_RED);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -131,7 +141,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
case "position":
|
||||
if (client.player) {
|
||||
let pos = client.player.position;
|
||||
messageClient("[POS] X: " + pos[0].toFixed(2) + " Y: " + pos[1].toFixed(2) + " Z: " + pos[2].toFixed(2), client, [200, 200, 255, 255]);
|
||||
messageClient("[POS] X: " + pos.x.toFixed(2) + " Y: " + pos.y.toFixed(2) + " Z: " + pos.z.toFixed(2), client, COLOUR_BLUE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -147,7 +157,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
case "heal":
|
||||
if (client.player) {
|
||||
client.player.health = 100;
|
||||
messageClient("[SERVER] You have been healed!", client, [100, 255, 100, 255]);
|
||||
messageClient("[SERVER] You have been healed!", client, COLOUR_GREEN);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -155,7 +165,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
case "armor":
|
||||
if (client.player) {
|
||||
client.player.armour = 100;
|
||||
messageClient("[SERVER] You have been given armour!", client, [100, 200, 255, 255]);
|
||||
messageClient("[SERVER] You have been given armour!", client, COLOUR_BLUE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -165,28 +175,28 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (!isNaN(skinId)) {
|
||||
if (client.player) {
|
||||
client.player.modelIndex = skinId;
|
||||
messageClient("[SERVER] Skin changed to: " + skinId, client, [200, 200, 255, 255]);
|
||||
messageClient("[SERVER] Skin changed to: " + skinId, client, COLOUR_BLUE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messageClient("[USAGE] /skin <skin_id>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /skin <skin_id>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
case "weapons":
|
||||
case "giveweapons":
|
||||
giveWeapons(client);
|
||||
messageClient("[SERVER] You have been given weapons!", client, [255, 200, 100, 255]);
|
||||
messageClient("[SERVER] You have been given weapons!", client, COLOUR_ORANGE);
|
||||
break;
|
||||
|
||||
case "flip":
|
||||
if (client.player && client.player.vehicle) {
|
||||
let veh = client.player.vehicle;
|
||||
let rot = veh.rotation;
|
||||
veh.rotation = [0, 0, rot[2]];
|
||||
messageClient("[SERVER] Vehicle flipped!", client, [100, 255, 100, 255]);
|
||||
veh.rotation = new Vec3(0, 0, rot.z);
|
||||
messageClient("[SERVER] Vehicle flipped!", client, COLOUR_GREEN);
|
||||
} else {
|
||||
messageClient("[SERVER] You need to be in a vehicle!", client, [255, 100, 100, 255]);
|
||||
messageClient("[SERVER] You need to be in a vehicle!", client, COLOUR_RED);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -194,16 +204,16 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
case "repair":
|
||||
if (client.player && client.player.vehicle) {
|
||||
client.player.vehicle.health = 1000;
|
||||
messageClient("[SERVER] Vehicle repaired!", client, [100, 255, 100, 255]);
|
||||
messageClient("[SERVER] Vehicle repaired!", client, COLOUR_GREEN);
|
||||
} else {
|
||||
messageClient("[SERVER] You need to be in a vehicle!", client, [255, 100, 100, 255]);
|
||||
messageClient("[SERVER] You need to be in a vehicle!", client, COLOUR_RED);
|
||||
}
|
||||
break;
|
||||
|
||||
case "eject":
|
||||
if (client.player && client.player.vehicle) {
|
||||
client.player.removeFromVehicle();
|
||||
messageClient("[SERVER] Ejected from vehicle!", client, [200, 200, 255, 255]);
|
||||
messageClient("[SERVER] Ejected from vehicle!", client, COLOUR_BLUE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -217,15 +227,19 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
// FUNCTIONS
|
||||
// ============================================================================
|
||||
|
||||
function spawnPlayer(client) {
|
||||
function spawnPlayerAtRandom(client) {
|
||||
// Select random spawn point
|
||||
let spawn = spawnPoints[Math.floor(Math.random() * spawnPoints.length)];
|
||||
|
||||
// Select random skin
|
||||
let skin = playerSkins[Math.floor(Math.random() * playerSkins.length)];
|
||||
|
||||
// Spawn the player
|
||||
client.spawn([spawn.x, spawn.y, spawn.z], 0, skin);
|
||||
// Create spawn position vector
|
||||
let spawnPos = new Vec3(spawn.x, spawn.y, spawn.z);
|
||||
|
||||
// Spawn the player using the correct function
|
||||
client.despawnPlayer();
|
||||
client.spawnPlayer(spawnPos, 0.0, skin);
|
||||
|
||||
// Give basic weapons after short delay
|
||||
setTimeout(function() {
|
||||
@@ -245,76 +259,74 @@ function giveStarterWeapons(client) {
|
||||
if (!client || !client.player) return;
|
||||
|
||||
// Give basic starter weapons (GTA IV weapon IDs)
|
||||
// Pistol
|
||||
client.giveWeapon(5, 100); // Pistol with 100 ammo
|
||||
// SMG
|
||||
client.giveWeapon(11, 200); // Micro SMG with 200 ammo
|
||||
client.player.giveWeapon(5, 100); // Pistol with 100 ammo
|
||||
client.player.giveWeapon(11, 200); // Micro SMG with 200 ammo
|
||||
}
|
||||
|
||||
function giveWeapons(client) {
|
||||
if (!client || !client.player) return;
|
||||
|
||||
// GTA IV Weapon IDs
|
||||
client.giveWeapon(1, 1); // Baseball Bat
|
||||
client.giveWeapon(2, 1); // Knife
|
||||
client.giveWeapon(5, 500); // Pistol
|
||||
client.giveWeapon(6, 500); // Desert Eagle
|
||||
client.giveWeapon(9, 200); // Shotgun
|
||||
client.giveWeapon(10, 200); // Combat Shotgun
|
||||
client.giveWeapon(11, 500); // Micro SMG
|
||||
client.giveWeapon(12, 500); // SMG
|
||||
client.giveWeapon(14, 500); // Assault Rifle
|
||||
client.giveWeapon(15, 500); // Carbine Rifle
|
||||
client.giveWeapon(16, 100); // Sniper Rifle
|
||||
client.giveWeapon(18, 20); // RPG
|
||||
client.giveWeapon(19, 20); // Grenades
|
||||
client.giveWeapon(20, 20); // Molotov
|
||||
client.player.giveWeapon(1, 1); // Baseball Bat
|
||||
client.player.giveWeapon(2, 1); // Knife
|
||||
client.player.giveWeapon(5, 500); // Pistol
|
||||
client.player.giveWeapon(6, 500); // Desert Eagle
|
||||
client.player.giveWeapon(9, 200); // Shotgun
|
||||
client.player.giveWeapon(10, 200); // Combat Shotgun
|
||||
client.player.giveWeapon(11, 500); // Micro SMG
|
||||
client.player.giveWeapon(12, 500); // SMG
|
||||
client.player.giveWeapon(14, 500); // Assault Rifle
|
||||
client.player.giveWeapon(15, 500); // Carbine Rifle
|
||||
client.player.giveWeapon(16, 100); // Sniper Rifle
|
||||
client.player.giveWeapon(18, 20); // RPG
|
||||
client.player.giveWeapon(19, 20); // Grenades
|
||||
client.player.giveWeapon(20, 20); // Molotov
|
||||
}
|
||||
|
||||
function showHelp(client) {
|
||||
messageClient("=== AVAILABLE COMMANDS ===", client, [255, 200, 100, 255]);
|
||||
messageClient("/spawn - Respawn at a random location", client, [200, 200, 200, 255]);
|
||||
messageClient("/kill - Kill yourself", client, [200, 200, 200, 255]);
|
||||
messageClient("/pos - Show your current position", client, [200, 200, 200, 255]);
|
||||
messageClient("/stats - Show your statistics", client, [200, 200, 200, 255]);
|
||||
messageClient("/players - Show online players", client, [200, 200, 200, 255]);
|
||||
messageClient("/heal - Restore your health", client, [200, 200, 200, 255]);
|
||||
messageClient("/armour - Give yourself armour", client, [200, 200, 200, 255]);
|
||||
messageClient("/weapons - Get all weapons", client, [200, 200, 200, 255]);
|
||||
messageClient("/skin <id> - Change your skin", client, [200, 200, 200, 255]);
|
||||
messageClient("/flip - Flip your vehicle", client, [200, 200, 200, 255]);
|
||||
messageClient("/fix - Repair your vehicle", client, [200, 200, 200, 255]);
|
||||
messageClient("/eject - Exit vehicle", client, [200, 200, 200, 255]);
|
||||
messageClient("=== VEHICLE COMMANDS ===", client, [255, 200, 100, 255]);
|
||||
messageClient("/v <name> - Spawn a vehicle", client, [200, 200, 200, 255]);
|
||||
messageClient("/dv - Delete your vehicle", client, [200, 200, 200, 255]);
|
||||
messageClient("=== TELEPORT COMMANDS ===", client, [255, 200, 100, 255]);
|
||||
messageClient("/tp <location> - Teleport to location", client, [200, 200, 200, 255]);
|
||||
messageClient("/tplist - List teleport locations", client, [200, 200, 200, 255]);
|
||||
messageClient("=== WORLD COMMANDS ===", client, [255, 200, 100, 255]);
|
||||
messageClient("/weather <id> - Change weather", client, [200, 200, 200, 255]);
|
||||
messageClient("/time <hour> - Change time", client, [200, 200, 200, 255]);
|
||||
messageClient("=== AVAILABLE COMMANDS ===", client, COLOUR_ORANGE);
|
||||
messageClient("/spawn - Respawn at a random location", client, COLOUR_GREY);
|
||||
messageClient("/kill - Kill yourself", client, COLOUR_GREY);
|
||||
messageClient("/pos - Show your current position", client, COLOUR_GREY);
|
||||
messageClient("/stats - Show your statistics", client, COLOUR_GREY);
|
||||
messageClient("/players - Show online players", client, COLOUR_GREY);
|
||||
messageClient("/heal - Restore your health", client, COLOUR_GREY);
|
||||
messageClient("/armour - Give yourself armour", client, COLOUR_GREY);
|
||||
messageClient("/weapons - Get all weapons", client, COLOUR_GREY);
|
||||
messageClient("/skin <id> - Change your skin", client, COLOUR_GREY);
|
||||
messageClient("/flip - Flip your vehicle", client, COLOUR_GREY);
|
||||
messageClient("/fix - Repair your vehicle", client, COLOUR_GREY);
|
||||
messageClient("/eject - Exit vehicle", client, COLOUR_GREY);
|
||||
messageClient("=== VEHICLE COMMANDS ===", client, COLOUR_ORANGE);
|
||||
messageClient("/v <name> - Spawn a vehicle", client, COLOUR_GREY);
|
||||
messageClient("/dv - Delete your vehicle", client, COLOUR_GREY);
|
||||
messageClient("=== TELEPORT COMMANDS ===", client, COLOUR_ORANGE);
|
||||
messageClient("/tp <location> - Teleport to location", client, COLOUR_GREY);
|
||||
messageClient("/tplist - List teleport locations", client, COLOUR_GREY);
|
||||
messageClient("=== WORLD COMMANDS ===", client, COLOUR_ORANGE);
|
||||
messageClient("/weather <id> - Change weather", client, COLOUR_GREY);
|
||||
messageClient("/time <hour> - Change time", client, COLOUR_GREY);
|
||||
}
|
||||
|
||||
function showStats(client) {
|
||||
let data = playerData[client.index];
|
||||
if (data) {
|
||||
messageClient("=== YOUR STATISTICS ===", client, [255, 200, 100, 255]);
|
||||
messageClient("Kills: " + data.kills, client, [100, 255, 100, 255]);
|
||||
messageClient("Deaths: " + data.deaths, client, [255, 100, 100, 255]);
|
||||
messageClient("=== YOUR STATISTICS ===", client, COLOUR_ORANGE);
|
||||
messageClient("Kills: " + data.kills, client, COLOUR_GREEN);
|
||||
messageClient("Deaths: " + data.deaths, client, COLOUR_RED);
|
||||
let kd = data.deaths > 0 ? (data.kills / data.deaths).toFixed(2) : data.kills.toFixed(2);
|
||||
messageClient("K/D Ratio: " + kd, client, [200, 200, 255, 255]);
|
||||
messageClient("K/D Ratio: " + kd, client, COLOUR_BLUE);
|
||||
}
|
||||
}
|
||||
|
||||
function showOnlinePlayers(client) {
|
||||
let clients = getClients();
|
||||
messageClient("=== ONLINE PLAYERS (" + clients.length + ") ===", client, [255, 200, 100, 255]);
|
||||
messageClient("=== ONLINE PLAYERS (" + clients.length + ") ===", client, COLOUR_ORANGE);
|
||||
|
||||
for (let i = 0; i < clients.length; i++) {
|
||||
let c = clients[i];
|
||||
let data = playerData[c.index] || { kills: 0, deaths: 0 };
|
||||
messageClient(c.name + " - K: " + data.kills + " D: " + data.deaths, client, [200, 200, 200, 255]);
|
||||
messageClient(c.name + " - K: " + data.kills + " D: " + data.deaths, client, COLOUR_GREY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
// Handles all server-side actions triggered from the client menu
|
||||
// ============================================================================
|
||||
|
||||
// Color constants using toColour for integer format
|
||||
const COLOUR_ORANGE = toColour(255, 200, 100, 255);
|
||||
const COLOUR_WORLD = toColour(100, 200, 255, 255);
|
||||
|
||||
// Vehicle model hashes for spawning
|
||||
const vehicleModels = {
|
||||
// Sports Cars
|
||||
@@ -137,7 +141,7 @@ addEventHandler("OnPlayerJoined", function(event, client) {
|
||||
playerToggles[client.index] = {};
|
||||
|
||||
// Inform player about the menu
|
||||
messageClient("[MOD MENU] Press F5 to open the mod menu!", client, [255, 200, 100, 255]);
|
||||
messageClient("[MOD MENU] Press F5 to open the mod menu!", client, COLOUR_ORANGE);
|
||||
});
|
||||
|
||||
addEventHandler("OnPlayerQuit", function(event, client, reason) {
|
||||
@@ -195,7 +199,9 @@ addNetworkHandler("ModMenu:SelfOption", function(client, option) {
|
||||
{ x: 1243.0, y: -196.0, z: 26.0 }
|
||||
];
|
||||
let spawn = spawns[Math.floor(Math.random() * spawns.length)];
|
||||
client.spawn([spawn.x, spawn.y, spawn.z], 0, -1667301416);
|
||||
let spawnPos = new Vec3(spawn.x, spawn.y, spawn.z);
|
||||
client.despawnPlayer();
|
||||
client.spawnPlayer(spawnPos, 0.0, -1667301416);
|
||||
break;
|
||||
|
||||
case "suicide":
|
||||
@@ -260,12 +266,13 @@ addNetworkHandler("ModMenu:SpawnVehicle", function(client, vehicleName) {
|
||||
let pos = client.player.position;
|
||||
let heading = client.player.heading;
|
||||
|
||||
let spawnX = pos[0] + (Math.sin(heading) * 4);
|
||||
let spawnY = pos[1] + (Math.cos(heading) * 4);
|
||||
let spawnZ = pos[2] + 1;
|
||||
let spawnX = pos.x + (Math.sin(heading) * 4);
|
||||
let spawnY = pos.y + (Math.cos(heading) * 4);
|
||||
let spawnZ = pos.z + 1;
|
||||
|
||||
// Create vehicle
|
||||
let vehicle = gta.createVehicle(modelHash, [spawnX, spawnY, spawnZ], heading);
|
||||
let spawnPos = new Vec3(spawnX, spawnY, spawnZ);
|
||||
let vehicle = gta.createVehicle(modelHash, spawnPos, heading);
|
||||
|
||||
if (vehicle) {
|
||||
if (!playerVehicles[client.index]) {
|
||||
@@ -327,7 +334,7 @@ addNetworkHandler("ModMenu:VehicleOption", function(client, option) {
|
||||
|
||||
case "flip":
|
||||
let rot = vehicle.rotation;
|
||||
vehicle.rotation = [0, 0, rot[2]];
|
||||
vehicle.rotation = new Vec3(0, 0, rot.z);
|
||||
break;
|
||||
|
||||
case "clean":
|
||||
@@ -344,11 +351,12 @@ addNetworkHandler("ModMenu:VehicleOption", function(client, option) {
|
||||
let pos = vehicle.position;
|
||||
let heading = vehicle.heading;
|
||||
let boost = 50;
|
||||
vehicle.position = [
|
||||
pos[0] + (Math.sin(heading) * boost),
|
||||
pos[1] + (Math.cos(heading) * boost),
|
||||
pos[2]
|
||||
];
|
||||
let newPos = new Vec3(
|
||||
pos.x + (Math.sin(heading) * boost),
|
||||
pos.y + (Math.cos(heading) * boost),
|
||||
pos.z
|
||||
);
|
||||
vehicle.position = newPos;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -396,10 +404,11 @@ addNetworkHandler("ModMenu:Teleport", function(client, x, y, z) {
|
||||
return;
|
||||
}
|
||||
|
||||
let newPos = new Vec3(x, y, z);
|
||||
if (client.player.vehicle) {
|
||||
client.player.vehicle.position = [x, y, z];
|
||||
client.player.vehicle.position = newPos;
|
||||
} else {
|
||||
client.player.position = [x, y, z];
|
||||
client.player.position = newPos;
|
||||
}
|
||||
|
||||
console.log("[ModMenu] " + client.name + " teleported to: " + x + ", " + y + ", " + z);
|
||||
@@ -428,10 +437,11 @@ addNetworkHandler("ModMenu:TeleportToPlayer", function(client, targetId) {
|
||||
|
||||
if (target && target.player) {
|
||||
let pos = target.player.position;
|
||||
let newPos = new Vec3(pos.x + 3, pos.y, pos.z);
|
||||
if (client.player.vehicle) {
|
||||
client.player.vehicle.position = [pos[0] + 3, pos[1], pos[2]];
|
||||
client.player.vehicle.position = newPos;
|
||||
} else {
|
||||
client.player.position = [pos[0] + 3, pos[1], pos[2]];
|
||||
client.player.position = newPos;
|
||||
}
|
||||
triggerNetworkEvent("ModMenu:Notification", client, "Teleported to: " + target.name);
|
||||
console.log("[ModMenu] " + client.name + " teleported to " + target.name);
|
||||
@@ -465,13 +475,13 @@ addNetworkHandler("ModMenu:GetPlayers", function(client) {
|
||||
|
||||
addNetworkHandler("ModMenu:WorldTime", function(client, hour) {
|
||||
gta.time = [hour, 0];
|
||||
message("[WORLD] " + client.name + " changed time to: " + hour + ":00", [100, 200, 255, 255]);
|
||||
message("[WORLD] " + client.name + " changed time to: " + hour + ":00", COLOUR_WORLD);
|
||||
console.log("[ModMenu] " + client.name + " changed time to: " + hour);
|
||||
});
|
||||
|
||||
addNetworkHandler("ModMenu:WorldWeather", function(client, weatherId) {
|
||||
gta.weather = weatherId;
|
||||
message("[WORLD] " + client.name + " changed the weather", [100, 200, 255, 255]);
|
||||
message("[WORLD] " + client.name + " changed the weather", COLOUR_WORLD);
|
||||
console.log("[ModMenu] " + client.name + " changed weather to: " + weatherId);
|
||||
});
|
||||
|
||||
@@ -485,7 +495,7 @@ addNetworkHandler("ModMenu:GiveWeapon", function(client, weaponId) {
|
||||
return;
|
||||
}
|
||||
|
||||
client.giveWeapon(weaponId, 500);
|
||||
client.player.giveWeapon(weaponId, 500);
|
||||
console.log("[ModMenu] " + client.name + " got weapon: " + weaponId);
|
||||
});
|
||||
|
||||
@@ -493,20 +503,20 @@ function giveAllWeapons(client) {
|
||||
if (!client.player) return;
|
||||
|
||||
// GTA IV Weapons
|
||||
client.giveWeapon(1, 1); // Bat
|
||||
client.giveWeapon(2, 1); // Knife
|
||||
client.giveWeapon(5, 500); // Pistol
|
||||
client.giveWeapon(6, 500); // Deagle
|
||||
client.giveWeapon(9, 200); // Shotgun
|
||||
client.giveWeapon(10, 200); // Combat Shotgun
|
||||
client.giveWeapon(11, 500); // Micro SMG
|
||||
client.giveWeapon(12, 500); // SMG
|
||||
client.giveWeapon(14, 500); // AK47
|
||||
client.giveWeapon(15, 500); // M4
|
||||
client.giveWeapon(16, 100); // Sniper
|
||||
client.giveWeapon(18, 20); // RPG
|
||||
client.giveWeapon(19, 20); // Grenades
|
||||
client.giveWeapon(20, 20); // Molotov
|
||||
client.player.giveWeapon(1, 1); // Bat
|
||||
client.player.giveWeapon(2, 1); // Knife
|
||||
client.player.giveWeapon(5, 500); // Pistol
|
||||
client.player.giveWeapon(6, 500); // Deagle
|
||||
client.player.giveWeapon(9, 200); // Shotgun
|
||||
client.player.giveWeapon(10, 200); // Combat Shotgun
|
||||
client.player.giveWeapon(11, 500); // Micro SMG
|
||||
client.player.giveWeapon(12, 500); // SMG
|
||||
client.player.giveWeapon(14, 500); // AK47
|
||||
client.player.giveWeapon(15, 500); // M4
|
||||
client.player.giveWeapon(16, 100); // Sniper
|
||||
client.player.giveWeapon(18, 20); // RPG
|
||||
client.player.giveWeapon(19, 20); // Grenades
|
||||
client.player.giveWeapon(20, 20); // Molotov
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@@ -523,7 +533,8 @@ addNetworkHandler("ModMenu:Fun", function(client, option) {
|
||||
|
||||
switch(option) {
|
||||
case "launch":
|
||||
client.player.position = [pos[0], pos[1], pos[2] + 50];
|
||||
let launchPos = new Vec3(pos.x, pos.y, pos.z + 50);
|
||||
client.player.position = launchPos;
|
||||
break;
|
||||
|
||||
case "explode":
|
||||
@@ -533,7 +544,8 @@ addNetworkHandler("ModMenu:Fun", function(client, option) {
|
||||
case "ped":
|
||||
// Spawn a random ped near player
|
||||
let pedSkin = skinModels[Math.floor(Math.random() * skinModels.length)];
|
||||
let ped = gta.createPed(pedSkin, [pos[0] + 3, pos[1] + 3, pos[2]], 0);
|
||||
let pedPos = new Vec3(pos.x + 3, pos.y + 3, pos.z);
|
||||
let ped = gta.createPed(pedSkin, pedPos, 0);
|
||||
if (ped) {
|
||||
console.log("[ModMenu] " + client.name + " spawned a ped");
|
||||
}
|
||||
|
||||
@@ -3,6 +3,13 @@
|
||||
// Teleportation system with Liberty City (GTA IV) locations
|
||||
// ============================================================================
|
||||
|
||||
// Color constants using toColour for integer format
|
||||
const COLOUR_SUCCESS = toColour(100, 255, 100, 255);
|
||||
const COLOUR_ORANGE = toColour(255, 200, 100, 255);
|
||||
const COLOUR_ERROR = toColour(255, 100, 100, 255);
|
||||
const COLOUR_GRAY = toColour(200, 200, 200, 255);
|
||||
const COLOUR_INFO = toColour(100, 200, 255, 255);
|
||||
|
||||
// Liberty City Teleport Locations
|
||||
const locations = {
|
||||
// Algonquin (Manhattan)
|
||||
@@ -81,8 +88,8 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
let locationName = params.toLowerCase().split(" ")[0];
|
||||
teleportToLocation(client, locationName);
|
||||
} else {
|
||||
messageClient("[USAGE] /tp <location>", client, [255, 200, 100, 255]);
|
||||
messageClient("[TIP] Use /tplist to see available locations", client, [200, 200, 200, 255]);
|
||||
messageClient("[USAGE] /tp <location>", client, COLOUR_ORANGE);
|
||||
messageClient("[TIP] Use /tplist to see available locations", client, COLOUR_GRAY);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -96,7 +103,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
searchLocations(client, params.toLowerCase());
|
||||
} else {
|
||||
messageClient("[USAGE] /tpsearch <partial_name>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /tpsearch <partial_name>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -112,13 +119,13 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (!isNaN(x) && !isNaN(y) && !isNaN(z)) {
|
||||
teleportToCoords(client, x, y, z);
|
||||
} else {
|
||||
messageClient("[TELEPORT] Invalid coordinates!", client, [255, 100, 100, 255]);
|
||||
messageClient("[TELEPORT] Invalid coordinates!", client, COLOUR_ERROR);
|
||||
}
|
||||
} else {
|
||||
messageClient("[USAGE] /setpos <x> <y> <z>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /setpos <x> <y> <z>", client, COLOUR_ORANGE);
|
||||
}
|
||||
} else {
|
||||
messageClient("[USAGE] /setpos <x> <y> <z>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /setpos <x> <y> <z>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -127,7 +134,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
saveWaypoint(client, params.toLowerCase());
|
||||
} else {
|
||||
messageClient("[USAGE] /savewaypoint <name>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /savewaypoint <name>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -136,7 +143,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
deleteWaypoint(client, params.toLowerCase());
|
||||
} else {
|
||||
messageClient("[USAGE] /delwaypoint <name>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /delwaypoint <name>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -150,7 +157,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
teleportToWaypoint(client, params.toLowerCase());
|
||||
} else {
|
||||
messageClient("[USAGE] /tpwp <waypoint_name>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /tpwp <waypoint_name>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -182,7 +189,7 @@ function teleportToLocation(client, locationName) {
|
||||
if (locations[locationName]) {
|
||||
let loc = locations[locationName];
|
||||
teleportPlayer(client, loc.x, loc.y, loc.z);
|
||||
messageClient("[TELEPORT] Teleported to: " + loc.name, client, [100, 255, 100, 255]);
|
||||
messageClient("[TELEPORT] Teleported to: " + loc.name, client, COLOUR_SUCCESS);
|
||||
console.log("[Teleport] " + client.name + " teleported to " + loc.name);
|
||||
return;
|
||||
}
|
||||
@@ -191,50 +198,51 @@ function teleportToLocation(client, locationName) {
|
||||
if (playerWaypoints[client.index] && playerWaypoints[client.index][locationName]) {
|
||||
let wp = playerWaypoints[client.index][locationName];
|
||||
teleportPlayer(client, wp.x, wp.y, wp.z);
|
||||
messageClient("[TELEPORT] Teleported to waypoint: " + locationName, client, [100, 255, 100, 255]);
|
||||
messageClient("[TELEPORT] Teleported to waypoint: " + locationName, client, COLOUR_SUCCESS);
|
||||
return;
|
||||
}
|
||||
|
||||
messageClient("[TELEPORT] Location '" + locationName + "' not found!", client, [255, 100, 100, 255]);
|
||||
messageClient("[TIP] Use /tplist or /tpsearch <name>", client, [200, 200, 200, 255]);
|
||||
messageClient("[TELEPORT] Location '" + locationName + "' not found!", client, COLOUR_ERROR);
|
||||
messageClient("[TIP] Use /tplist or /tpsearch <name>", client, COLOUR_GRAY);
|
||||
}
|
||||
|
||||
function teleportToCoords(client, x, y, z) {
|
||||
teleportPlayer(client, x, y, z);
|
||||
messageClient("[TELEPORT] Teleported to: X:" + x.toFixed(1) + " Y:" + y.toFixed(1) + " Z:" + z.toFixed(1), client, [100, 255, 100, 255]);
|
||||
messageClient("[TELEPORT] Teleported to: X:" + x.toFixed(1) + " Y:" + y.toFixed(1) + " Z:" + z.toFixed(1), client, COLOUR_SUCCESS);
|
||||
}
|
||||
|
||||
function teleportPlayer(client, x, y, z) {
|
||||
if (client.player) {
|
||||
let newPos = new Vec3(x, y, z);
|
||||
// If in vehicle, teleport vehicle
|
||||
if (client.player.vehicle) {
|
||||
client.player.vehicle.position = [x, y, z];
|
||||
client.player.vehicle.position = newPos;
|
||||
} else {
|
||||
client.player.position = [x, y, z];
|
||||
client.player.position = newPos;
|
||||
}
|
||||
} else {
|
||||
messageClient("[TELEPORT] You need to spawn first!", client, [255, 100, 100, 255]);
|
||||
messageClient("[TELEPORT] You need to spawn first!", client, COLOUR_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
function showLocationList(client) {
|
||||
messageClient("=== TELEPORT LOCATIONS ===", client, [255, 200, 100, 255]);
|
||||
messageClient("-- Algonquin --", client, [100, 200, 255, 255]);
|
||||
messageClient("starjunction, middlepark, rotterdam, chinatown, exchange, happiness", client, [200, 200, 200, 255]);
|
||||
messageClient("=== TELEPORT LOCATIONS ===", client, COLOUR_ORANGE);
|
||||
messageClient("-- Algonquin --", client, COLOUR_INFO);
|
||||
messageClient("starjunction, middlepark, rotterdam, chinatown, exchange, happiness", client, COLOUR_GRAY);
|
||||
|
||||
messageClient("-- Broker/Dukes --", client, [100, 200, 255, 255]);
|
||||
messageClient("broker, firefly, outlook, beach, hove, meadows, willis, airport", client, [200, 200, 200, 255]);
|
||||
messageClient("-- Broker/Dukes --", client, COLOUR_INFO);
|
||||
messageClient("broker, firefly, outlook, beach, hove, meadows, willis, airport", client, COLOUR_GRAY);
|
||||
|
||||
messageClient("-- Bohan --", client, [100, 200, 255, 255]);
|
||||
messageClient("bohan, northholland, industrial", client, [200, 200, 200, 255]);
|
||||
messageClient("-- Bohan --", client, COLOUR_INFO);
|
||||
messageClient("bohan, northholland, industrial", client, COLOUR_GRAY);
|
||||
|
||||
messageClient("-- Alderney --", client, [100, 200, 255, 255]);
|
||||
messageClient("alderney, alderneyport, westdyke, acter, berchem, tudor, leftwood", client, [200, 200, 200, 255]);
|
||||
messageClient("-- Alderney --", client, COLOUR_INFO);
|
||||
messageClient("alderney, alderneyport, westdyke, acter, berchem, tudor, leftwood", client, COLOUR_GRAY);
|
||||
|
||||
messageClient("-- Points of Interest --", client, [100, 200, 255, 255]);
|
||||
messageClient("hospital, hospitalalg, police, bowling, cabaret, burgershot, helipad", client, [200, 200, 200, 255]);
|
||||
messageClient("-- Points of Interest --", client, COLOUR_INFO);
|
||||
messageClient("hospital, hospitalalg, police, bowling, cabaret, burgershot, helipad", client, COLOUR_GRAY);
|
||||
|
||||
messageClient("[TIP] Use /tpsearch <name> to find specific locations", client, [255, 200, 100, 255]);
|
||||
messageClient("[TIP] Use /tpsearch <name> to find specific locations", client, COLOUR_ORANGE);
|
||||
}
|
||||
|
||||
function searchLocations(client, searchTerm) {
|
||||
@@ -247,18 +255,18 @@ function searchLocations(client, searchTerm) {
|
||||
}
|
||||
|
||||
if (found.length > 0) {
|
||||
messageClient("=== LOCATIONS MATCHING '" + searchTerm.toUpperCase() + "' ===", client, [255, 200, 100, 255]);
|
||||
messageClient("=== LOCATIONS MATCHING '" + searchTerm.toUpperCase() + "' ===", client, COLOUR_ORANGE);
|
||||
for (let i = 0; i < found.length; i++) {
|
||||
messageClient(found[i], client, [200, 200, 200, 255]);
|
||||
messageClient(found[i], client, COLOUR_GRAY);
|
||||
}
|
||||
} else {
|
||||
messageClient("[TELEPORT] No locations found matching '" + searchTerm + "'", client, [255, 100, 100, 255]);
|
||||
messageClient("[TELEPORT] No locations found matching '" + searchTerm + "'", client, COLOUR_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
function saveWaypoint(client, waypointName) {
|
||||
if (!client.player) {
|
||||
messageClient("[WAYPOINT] You need to spawn first!", client, [255, 100, 100, 255]);
|
||||
messageClient("[WAYPOINT] You need to spawn first!", client, COLOUR_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -269,35 +277,35 @@ function saveWaypoint(client, waypointName) {
|
||||
}
|
||||
|
||||
playerWaypoints[client.index][waypointName] = {
|
||||
x: pos[0],
|
||||
y: pos[1],
|
||||
z: pos[2]
|
||||
x: pos.x,
|
||||
y: pos.y,
|
||||
z: pos.z
|
||||
};
|
||||
|
||||
messageClient("[WAYPOINT] Saved waypoint: " + waypointName, client, [100, 255, 100, 255]);
|
||||
messageClient("[WAYPOINT] Use /tpwp " + waypointName + " to teleport here", client, [200, 200, 200, 255]);
|
||||
messageClient("[WAYPOINT] Saved waypoint: " + waypointName, client, COLOUR_SUCCESS);
|
||||
messageClient("[WAYPOINT] Use /tpwp " + waypointName + " to teleport here", client, COLOUR_GRAY);
|
||||
}
|
||||
|
||||
function deleteWaypoint(client, waypointName) {
|
||||
if (playerWaypoints[client.index] && playerWaypoints[client.index][waypointName]) {
|
||||
delete playerWaypoints[client.index][waypointName];
|
||||
messageClient("[WAYPOINT] Deleted waypoint: " + waypointName, client, [100, 255, 100, 255]);
|
||||
messageClient("[WAYPOINT] Deleted waypoint: " + waypointName, client, COLOUR_SUCCESS);
|
||||
} else {
|
||||
messageClient("[WAYPOINT] Waypoint not found: " + waypointName, client, [255, 100, 100, 255]);
|
||||
messageClient("[WAYPOINT] Waypoint not found: " + waypointName, client, COLOUR_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
function showWaypoints(client) {
|
||||
if (!playerWaypoints[client.index] || Object.keys(playerWaypoints[client.index]).length === 0) {
|
||||
messageClient("[WAYPOINT] You have no saved waypoints", client, [255, 200, 100, 255]);
|
||||
messageClient("[TIP] Use /savewaypoint <name> to save your current position", client, [200, 200, 200, 255]);
|
||||
messageClient("[WAYPOINT] You have no saved waypoints", client, COLOUR_ORANGE);
|
||||
messageClient("[TIP] Use /savewaypoint <name> to save your current position", client, COLOUR_GRAY);
|
||||
return;
|
||||
}
|
||||
|
||||
messageClient("=== YOUR WAYPOINTS ===", client, [255, 200, 100, 255]);
|
||||
messageClient("=== YOUR WAYPOINTS ===", client, COLOUR_ORANGE);
|
||||
for (let name in playerWaypoints[client.index]) {
|
||||
let wp = playerWaypoints[client.index][name];
|
||||
messageClient(name + " - X:" + wp.x.toFixed(1) + " Y:" + wp.y.toFixed(1) + " Z:" + wp.z.toFixed(1), client, [200, 200, 200, 255]);
|
||||
messageClient(name + " - X:" + wp.x.toFixed(1) + " Y:" + wp.y.toFixed(1) + " Z:" + wp.z.toFixed(1), client, COLOUR_GRAY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,9 +313,9 @@ function teleportToWaypoint(client, waypointName) {
|
||||
if (playerWaypoints[client.index] && playerWaypoints[client.index][waypointName]) {
|
||||
let wp = playerWaypoints[client.index][waypointName];
|
||||
teleportPlayer(client, wp.x, wp.y, wp.z);
|
||||
messageClient("[WAYPOINT] Teleported to: " + waypointName, client, [100, 255, 100, 255]);
|
||||
messageClient("[WAYPOINT] Teleported to: " + waypointName, client, COLOUR_SUCCESS);
|
||||
} else {
|
||||
messageClient("[WAYPOINT] Waypoint not found: " + waypointName, client, [255, 100, 100, 255]);
|
||||
messageClient("[WAYPOINT] Waypoint not found: " + waypointName, client, COLOUR_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,13 @@
|
||||
// Handles vehicle spawning and management for GTA IV
|
||||
// ============================================================================
|
||||
|
||||
// Color constants using toColour for integer format
|
||||
const COLOUR_SUCCESS = toColour(100, 255, 100, 255);
|
||||
const COLOUR_ORANGE = toColour(255, 200, 100, 255);
|
||||
const COLOUR_ERROR = toColour(255, 100, 100, 255);
|
||||
const COLOUR_GRAY = toColour(200, 200, 200, 255);
|
||||
const COLOUR_MAGENTA = toColour(255, 100, 255, 255);
|
||||
|
||||
// GTA IV Vehicle Database - Model names and their hash IDs
|
||||
const vehicles = {
|
||||
// Sports Cars
|
||||
@@ -57,7 +64,6 @@ const vehicles = {
|
||||
"premier": -1883869285,
|
||||
"primo": -1150599089,
|
||||
"stratum": 1723137093,
|
||||
"sultan": 970598228,
|
||||
|
||||
// Compacts
|
||||
"blista": -344943009,
|
||||
@@ -178,8 +184,8 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
let vehicleName = params.toLowerCase().split(" ")[0];
|
||||
spawnVehicleForPlayer(client, vehicleName);
|
||||
} else {
|
||||
messageClient("[USAGE] /v <vehicle_name>", client, [255, 200, 100, 255]);
|
||||
messageClient("[TIP] Use /vlist to see available vehicles", client, [200, 200, 200, 255]);
|
||||
messageClient("[USAGE] /v <vehicle_name>", client, COLOUR_ORANGE);
|
||||
messageClient("[TIP] Use /vlist to see available vehicles", client, COLOUR_GRAY);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -187,7 +193,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
case "deletevehicle":
|
||||
case "destroyvehicle":
|
||||
deletePlayerVehicles(client);
|
||||
messageClient("[VEHICLES] Your vehicles have been deleted!", client, [100, 255, 100, 255]);
|
||||
messageClient("[VEHICLES] Your vehicles have been deleted!", client, COLOUR_SUCCESS);
|
||||
break;
|
||||
|
||||
case "vlist":
|
||||
@@ -201,7 +207,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (params && params.length > 0) {
|
||||
searchVehicles(client, params.toLowerCase());
|
||||
} else {
|
||||
messageClient("[USAGE] /vsearch <partial_name>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /vsearch <partial_name>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -212,11 +218,11 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (colors.length >= 2) {
|
||||
setVehicleColor(client, parseInt(colors[0]), parseInt(colors[1]));
|
||||
} else {
|
||||
messageClient("[USAGE] /vcolor <color1> <color2>", client, [255, 200, 100, 255]);
|
||||
messageClient("[TIP] Colors are 0-131 for GTA IV", client, [200, 200, 200, 255]);
|
||||
messageClient("[USAGE] /vcolor <color1> <color2>", client, COLOUR_ORANGE);
|
||||
messageClient("[TIP] Colors are 0-131 for GTA IV", client, COLOUR_GRAY);
|
||||
}
|
||||
} else {
|
||||
messageClient("[USAGE] /vcolor <color1> <color2>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /vcolor <color1> <color2>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -225,9 +231,9 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
if (client.player && client.player.vehicle) {
|
||||
// Simulate nitro boost by increasing vehicle speed
|
||||
let veh = client.player.vehicle;
|
||||
messageClient("[VEHICLES] NITRO! Vehicle boosted!", client, [255, 100, 255, 255]);
|
||||
messageClient("[VEHICLES] NITRO! Vehicle boosted!", client, COLOUR_MAGENTA);
|
||||
} else {
|
||||
messageClient("[VEHICLES] You need to be in a vehicle!", client, [255, 100, 100, 255]);
|
||||
messageClient("[VEHICLES] You need to be in a vehicle!", client, COLOUR_ERROR);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -240,13 +246,13 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
function spawnVehicleForPlayer(client, vehicleName) {
|
||||
// Check if vehicle exists
|
||||
if (!vehicles[vehicleName]) {
|
||||
messageClient("[VEHICLES] Vehicle '" + vehicleName + "' not found!", client, [255, 100, 100, 255]);
|
||||
messageClient("[TIP] Use /vlist or /vsearch <name> to find vehicles", client, [200, 200, 200, 255]);
|
||||
messageClient("[VEHICLES] Vehicle '" + vehicleName + "' not found!", client, COLOUR_ERROR);
|
||||
messageClient("[TIP] Use /vlist or /vsearch <name> to find vehicles", client, COLOUR_GRAY);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!client.player) {
|
||||
messageClient("[VEHICLES] You need to spawn first!", client, [255, 100, 100, 255]);
|
||||
messageClient("[VEHICLES] You need to spawn first!", client, COLOUR_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -258,13 +264,14 @@ function spawnVehicleForPlayer(client, vehicleName) {
|
||||
let heading = client.player.heading;
|
||||
|
||||
// Spawn slightly in front of player
|
||||
let spawnX = pos[0] + (Math.sin(heading) * 3);
|
||||
let spawnY = pos[1] + (Math.cos(heading) * 3);
|
||||
let spawnZ = pos[2] + 1;
|
||||
let spawnX = pos.x + (Math.sin(heading) * 3);
|
||||
let spawnY = pos.y + (Math.cos(heading) * 3);
|
||||
let spawnZ = pos.z + 1;
|
||||
|
||||
// Create the vehicle
|
||||
let modelHash = vehicles[vehicleName];
|
||||
let vehicle = gta.createVehicle(modelHash, [spawnX, spawnY, spawnZ], heading);
|
||||
let spawnPos = new Vec3(spawnX, spawnY, spawnZ);
|
||||
let vehicle = gta.createVehicle(modelHash, spawnPos, heading);
|
||||
|
||||
if (vehicle) {
|
||||
// Store vehicle for this player
|
||||
@@ -284,10 +291,10 @@ function spawnVehicleForPlayer(client, vehicleName) {
|
||||
vehicle.colour1 = color1;
|
||||
vehicle.colour2 = color2;
|
||||
|
||||
messageClient("[VEHICLES] Spawned: " + vehicleName.toUpperCase(), client, [100, 255, 100, 255]);
|
||||
messageClient("[VEHICLES] Spawned: " + vehicleName.toUpperCase(), client, COLOUR_SUCCESS);
|
||||
console.log("[Vehicles] " + client.name + " spawned " + vehicleName);
|
||||
} else {
|
||||
messageClient("[VEHICLES] Failed to spawn vehicle!", client, [255, 100, 100, 255]);
|
||||
messageClient("[VEHICLES] Failed to spawn vehicle!", client, COLOUR_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,17 +311,17 @@ function deletePlayerVehicles(client) {
|
||||
}
|
||||
|
||||
function showVehicleList(client) {
|
||||
messageClient("=== VEHICLE CATEGORIES ===", client, [255, 200, 100, 255]);
|
||||
messageClient("Sports: infernus, turismo, comet, banshee, sultan, coquette, feltzer", client, [200, 200, 200, 255]);
|
||||
messageClient("Muscle: sabregt, stalion, vigero, dukes, ruiner, phoenix", client, [200, 200, 200, 255]);
|
||||
messageClient("Super: entityxf, adder, vacca, bullet, cheetah", client, [200, 200, 200, 255]);
|
||||
messageClient("SUV: patriot, cavalcade, granger, huntley, landstalker", client, [200, 200, 200, 255]);
|
||||
messageClient("Sedan: oracle, schafter, admiral, vincent, presidente", client, [200, 200, 200, 255]);
|
||||
messageClient("Emergency: police, fbi, noose, ambulance, firetruk", client, [200, 200, 200, 255]);
|
||||
messageClient("Bikes: nrg900, pcj600, sanchez, faggio, bati, akuma", client, [200, 200, 200, 255]);
|
||||
messageClient("Air: annihilator, maverick, polmav, buzzard, shamal", client, [200, 200, 200, 255]);
|
||||
messageClient("Boats: jetmax, marquis, predator, tropic, dinghy", client, [200, 200, 200, 255]);
|
||||
messageClient("[TIP] Use /vsearch <name> to search for specific vehicles", client, [255, 200, 100, 255]);
|
||||
messageClient("=== VEHICLE CATEGORIES ===", client, COLOUR_ORANGE);
|
||||
messageClient("Sports: infernus, turismo, comet, banshee, sultan, coquette, feltzer", client, COLOUR_GRAY);
|
||||
messageClient("Muscle: sabregt, stalion, vigero, dukes, ruiner, phoenix", client, COLOUR_GRAY);
|
||||
messageClient("Super: entityxf, adder, vacca, bullet, cheetah", client, COLOUR_GRAY);
|
||||
messageClient("SUV: patriot, cavalcade, granger, huntley, landstalker", client, COLOUR_GRAY);
|
||||
messageClient("Sedan: oracle, schafter, admiral, vincent, presidente", client, COLOUR_GRAY);
|
||||
messageClient("Emergency: police, fbi, noose, ambulance, firetruk", client, COLOUR_GRAY);
|
||||
messageClient("Bikes: nrg900, pcj600, sanchez, faggio, bati, akuma", client, COLOUR_GRAY);
|
||||
messageClient("Air: annihilator, maverick, polmav, buzzard, shamal", client, COLOUR_GRAY);
|
||||
messageClient("Boats: jetmax, marquis, predator, tropic, dinghy", client, COLOUR_GRAY);
|
||||
messageClient("[TIP] Use /vsearch <name> to search for specific vehicles", client, COLOUR_ORANGE);
|
||||
}
|
||||
|
||||
function searchVehicles(client, searchTerm) {
|
||||
@@ -326,10 +333,10 @@ function searchVehicles(client, searchTerm) {
|
||||
}
|
||||
|
||||
if (found.length > 0) {
|
||||
messageClient("=== VEHICLES MATCHING '" + searchTerm.toUpperCase() + "' ===", client, [255, 200, 100, 255]);
|
||||
messageClient(found.join(", "), client, [200, 200, 200, 255]);
|
||||
messageClient("=== VEHICLES MATCHING '" + searchTerm.toUpperCase() + "' ===", client, COLOUR_ORANGE);
|
||||
messageClient(found.join(", "), client, COLOUR_GRAY);
|
||||
} else {
|
||||
messageClient("[VEHICLES] No vehicles found matching '" + searchTerm + "'", client, [255, 100, 100, 255]);
|
||||
messageClient("[VEHICLES] No vehicles found matching '" + searchTerm + "'", client, COLOUR_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,9 +345,9 @@ function setVehicleColor(client, color1, color2) {
|
||||
let veh = client.player.vehicle;
|
||||
veh.colour1 = color1;
|
||||
veh.colour2 = color2;
|
||||
messageClient("[VEHICLES] Vehicle color changed to: " + color1 + ", " + color2, client, [100, 255, 100, 255]);
|
||||
messageClient("[VEHICLES] Vehicle color changed to: " + color1 + ", " + color2, client, COLOUR_SUCCESS);
|
||||
} else {
|
||||
messageClient("[VEHICLES] You need to be in a vehicle!", client, [255, 100, 100, 255]);
|
||||
messageClient("[VEHICLES] You need to be in a vehicle!", client, COLOUR_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
// Handles weather, time, and world environment controls
|
||||
// ============================================================================
|
||||
|
||||
// Color constants using toColour for integer format
|
||||
const COLOUR_WORLD = toColour(100, 200, 255, 255);
|
||||
const COLOUR_ORANGE = toColour(255, 200, 100, 255);
|
||||
const COLOUR_ERROR = toColour(255, 100, 100, 255);
|
||||
const COLOUR_GRAY = toColour(200, 200, 200, 255);
|
||||
|
||||
// GTA IV Weather Types
|
||||
const weatherTypes = {
|
||||
0: "Extra Sunny",
|
||||
@@ -68,12 +74,12 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
let weatherId = parseInt(params);
|
||||
if (!isNaN(weatherId) && weatherId >= 0 && weatherId <= 9) {
|
||||
setWeather(weatherId);
|
||||
message("[WORLD] Weather changed to: " + weatherTypes[weatherId], [100, 200, 255, 255]);
|
||||
message("[WORLD] Weather changed to: " + weatherTypes[weatherId], COLOUR_WORLD);
|
||||
} else {
|
||||
messageClient("[WORLD] Invalid weather ID (0-9)", client, [255, 100, 100, 255]);
|
||||
messageClient("[WORLD] Invalid weather ID (0-9)", client, COLOUR_ERROR);
|
||||
}
|
||||
} else {
|
||||
messageClient("[USAGE] /weather <0-9>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /weather <0-9>", client, COLOUR_ORANGE);
|
||||
showWeatherList(client);
|
||||
}
|
||||
break;
|
||||
@@ -87,78 +93,78 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
|
||||
if (!isNaN(hour) && hour >= 0 && hour <= 23) {
|
||||
setTime(hour, minute);
|
||||
message("[WORLD] Time changed to: " + formatTime(hour, minute), [100, 200, 255, 255]);
|
||||
message("[WORLD] Time changed to: " + formatTime(hour, minute), COLOUR_WORLD);
|
||||
} else {
|
||||
messageClient("[WORLD] Invalid time (0-23 hours)", client, [255, 100, 100, 255]);
|
||||
messageClient("[WORLD] Invalid time (0-23 hours)", client, COLOUR_ERROR);
|
||||
}
|
||||
} else {
|
||||
messageClient("[USAGE] /time <hour> or /time <hour:minute>", client, [255, 200, 100, 255]);
|
||||
messageClient("[USAGE] /time <hour> or /time <hour:minute>", client, COLOUR_ORANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
case "morning":
|
||||
setTime(8, 0);
|
||||
message("[WORLD] Time set to morning (8:00)", [100, 200, 255, 255]);
|
||||
message("[WORLD] Time set to morning (8:00)", COLOUR_WORLD);
|
||||
break;
|
||||
|
||||
case "noon":
|
||||
case "midday":
|
||||
setTime(12, 0);
|
||||
message("[WORLD] Time set to noon (12:00)", [100, 200, 255, 255]);
|
||||
message("[WORLD] Time set to noon (12:00)", COLOUR_WORLD);
|
||||
break;
|
||||
|
||||
case "evening":
|
||||
setTime(18, 0);
|
||||
message("[WORLD] Time set to evening (18:00)", [100, 200, 255, 255]);
|
||||
message("[WORLD] Time set to evening (18:00)", COLOUR_WORLD);
|
||||
break;
|
||||
|
||||
case "night":
|
||||
case "midnight":
|
||||
setTime(0, 0);
|
||||
message("[WORLD] Time set to midnight (0:00)", [100, 200, 255, 255]);
|
||||
message("[WORLD] Time set to midnight (0:00)", COLOUR_WORLD);
|
||||
break;
|
||||
|
||||
case "sunny":
|
||||
setWeather(1);
|
||||
message("[WORLD] Weather set to Sunny", [100, 200, 255, 255]);
|
||||
message("[WORLD] Weather set to Sunny", COLOUR_WORLD);
|
||||
break;
|
||||
|
||||
case "cloudy":
|
||||
setWeather(3);
|
||||
message("[WORLD] Weather set to Cloudy", [100, 200, 255, 255]);
|
||||
message("[WORLD] Weather set to Cloudy", COLOUR_WORLD);
|
||||
break;
|
||||
|
||||
case "rain":
|
||||
case "rainy":
|
||||
setWeather(4);
|
||||
message("[WORLD] Weather set to Raining", [100, 200, 255, 255]);
|
||||
message("[WORLD] Weather set to Raining", COLOUR_WORLD);
|
||||
break;
|
||||
|
||||
case "thunder":
|
||||
case "storm":
|
||||
setWeather(7);
|
||||
message("[WORLD] Weather set to Thunder", [100, 200, 255, 255]);
|
||||
message("[WORLD] Weather set to Thunder", COLOUR_WORLD);
|
||||
break;
|
||||
|
||||
case "foggy":
|
||||
case "fog":
|
||||
setWeather(6);
|
||||
message("[WORLD] Weather set to Foggy", [100, 200, 255, 255]);
|
||||
message("[WORLD] Weather set to Foggy", COLOUR_WORLD);
|
||||
break;
|
||||
|
||||
case "freezetime":
|
||||
case "stoptime":
|
||||
worldState.timeFrozen = !worldState.timeFrozen;
|
||||
let status = worldState.timeFrozen ? "frozen" : "unfrozen";
|
||||
message("[WORLD] Time has been " + status, [100, 200, 255, 255]);
|
||||
message("[WORLD] Time has been " + status, COLOUR_WORLD);
|
||||
break;
|
||||
|
||||
case "gettime":
|
||||
messageClient("[WORLD] Current time: " + formatTime(worldState.hour, worldState.minute), client, [100, 200, 255, 255]);
|
||||
messageClient("[WORLD] Current time: " + formatTime(worldState.hour, worldState.minute), client, COLOUR_WORLD);
|
||||
break;
|
||||
|
||||
case "getweather":
|
||||
messageClient("[WORLD] Current weather: " + weatherTypes[worldState.weather] + " (" + worldState.weather + ")", client, [100, 200, 255, 255]);
|
||||
messageClient("[WORLD] Current weather: " + weatherTypes[worldState.weather] + " (" + worldState.weather + ")", client, COLOUR_WORLD);
|
||||
break;
|
||||
|
||||
case "weatherlist":
|
||||
@@ -169,7 +175,7 @@ addEventHandler("OnPlayerCommand", function(event, client, command, params) {
|
||||
case "randomweather":
|
||||
let randomWeather = Math.floor(Math.random() * 10);
|
||||
setWeather(randomWeather);
|
||||
message("[WORLD] Random weather: " + weatherTypes[randomWeather], [100, 200, 255, 255]);
|
||||
message("[WORLD] Random weather: " + weatherTypes[randomWeather], COLOUR_WORLD);
|
||||
break;
|
||||
}
|
||||
});
|
||||
@@ -215,9 +221,9 @@ function formatTime(hour, minute) {
|
||||
}
|
||||
|
||||
function showWeatherList(client) {
|
||||
messageClient("=== WEATHER TYPES ===", client, [255, 200, 100, 255]);
|
||||
messageClient("=== WEATHER TYPES ===", client, COLOUR_ORANGE);
|
||||
for (let id in weatherTypes) {
|
||||
messageClient(id + " - " + weatherTypes[id], client, [200, 200, 200, 255]);
|
||||
messageClient(id + " - " + weatherTypes[id], client, COLOUR_GRAY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user